forked from loafle/openapi-generator-original
[Erlang Server] Add more type information and fix minor bugs (#19792)
* Add type information about classes and operation-ids * Remove unused logger included header * Bugfix badmatch in delete_resource handler * Bugfix: respect original indentation of operation_ids * Bugfix json schema correct refs * Add a bit more documentation * Regenerate erlang-server handlers
This commit is contained in:
@@ -8,29 +8,32 @@ and `validate_response/4` respectively.
|
||||
|
||||
For example, the user-defined `Module:accept_callback/4` can be implemented as follows:
|
||||
```
|
||||
-spec accept_callback(atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{cowboy:http_status(), cowboy:http_headers(), json:encode_value()}.
|
||||
accept_callback(Class, OperationID, Req, Context) ->
|
||||
-spec accept_callback(
|
||||
Class :: openapi_api:class(),
|
||||
OperationID :: openapi_api:operation_id(),
|
||||
Req :: cowboy_req:req(),
|
||||
Context :: openapi_logic_handler:context()) ->
|
||||
{openapi_logic_handler:accept_callback_return(),
|
||||
cowboy_req:req(),
|
||||
openapi_logic_handler:context()}.
|
||||
accept_callback(Class, OperationID, Req0, Context0) ->
|
||||
ValidatorState = openapi_api:prepare_validator(),
|
||||
case openapi_api:populate_request(OperationID, Req0, ValidatorState) of
|
||||
{ok, Populated, Req1} ->
|
||||
{Code, Headers, Body} = openapi_logic_handler:handle_request(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
Req1,
|
||||
maps:merge(State#state.context, Populated)
|
||||
),
|
||||
_ = openapi_api:validate_response(
|
||||
OperationID,
|
||||
Code,
|
||||
Body,
|
||||
ValidatorState
|
||||
),
|
||||
PreparedBody = prepare_body(Code, Body),
|
||||
Response = {ok, {Code, Headers, PreparedBody}},
|
||||
process_response(Response, Req1, State);
|
||||
{ok, Model, Req1} ->
|
||||
Context1 = maps:merge(Context0, Model),
|
||||
case do_accept_callback(Class, OperationID, Req1, Context1) of
|
||||
{false, Req2, Context2} ->
|
||||
{false, Req2, Context2};
|
||||
{{true, Code, Body}, Req2, Context2} ->
|
||||
case validate_response(OperationID, Code, Body, ValidatorState) of
|
||||
ok ->
|
||||
process_response({ok, Code, Body}, Req2, Context2);
|
||||
{error, Reason} ->
|
||||
process_response({error, Reason}, Req2, Context2)
|
||||
end
|
||||
end;
|
||||
{error, Reason, Req1} ->
|
||||
process_response({error, Reason}, Req1, State)
|
||||
process_response({error, Reason}, Req1, Context0)
|
||||
end.
|
||||
```
|
||||
""".
|
||||
@@ -41,10 +44,48 @@ accept_callback(Class, OperationID, Req, Context) ->
|
||||
-ignore_xref([populate_request/3, validate_response/4]).
|
||||
-ignore_xref([prepare_validator/0, prepare_validator/1, prepare_validator/2]).
|
||||
|
||||
-type operation_id() :: atom().
|
||||
-type class() ::
|
||||
'auth'
|
||||
| 'body'
|
||||
| 'form'
|
||||
| 'header'
|
||||
| 'path'
|
||||
| 'query'.
|
||||
|
||||
|
||||
-type operation_id() ::
|
||||
'test/auth/http/basic' | %% To test HTTP basic authentication
|
||||
'test/auth/http/bearer' | %% To test HTTP bearer authentication
|
||||
'test/binary/gif' | %% Test binary (gif) response body
|
||||
'test/body/application/octetstream/binary' | %% Test body parameter(s)
|
||||
'test/body/multipart/formdata/array_of_binary' | %% Test array of binary in multipart mime
|
||||
'test/body/multipart/formdata/single_binary' | %% Test single binary in multipart mime
|
||||
'test/echo/body/allOf/Pet' | %% Test body parameter(s)
|
||||
'test/echo/body/FreeFormObject/response_string' | %% Test free form object
|
||||
'test/echo/body/Pet' | %% Test body parameter(s)
|
||||
'test/echo/body/Pet/response_string' | %% Test empty response body
|
||||
'test/echo/body/string_enum' | %% Test string enum response body
|
||||
'test/echo/body/Tag/response_string' | %% Test empty json (request body)
|
||||
'test/form/integer/boolean/string' | %% Test form parameter(s)
|
||||
'test/form/object/multipart' | %% Test form parameter(s) for multipart schema
|
||||
'test/form/oneof' | %% Test form parameter(s) for oneOf schema
|
||||
'test/header/integer/boolean/string/enums' | %% Test header parameter(s)
|
||||
'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}' | %% Test path parameter(s)
|
||||
'test/enum_ref_string' | %% Test query parameter(s)
|
||||
'test/query/datetime/date/string' | %% Test query parameter(s)
|
||||
'test/query/integer/boolean/string' | %% Test query parameter(s)
|
||||
'test/query/style_deepObject/explode_true/object' | %% Test query parameter(s)
|
||||
'test/query/style_deepObject/explode_true/object/allOf' | %% Test query parameter(s)
|
||||
'test/query/style_form/explode_false/array_integer' | %% Test query parameter(s)
|
||||
'test/query/style_form/explode_false/array_string' | %% Test query parameter(s)
|
||||
'test/query/style_form/explode_true/array_string' | %% Test query parameter(s)
|
||||
'test/query/style_form/explode_true/object' | %% Test query parameter(s)
|
||||
'test/query/style_form/explode_true/object/allOf' | %% Test query parameter(s)
|
||||
{error, unknown_operation}.
|
||||
|
||||
-type request_param() :: atom().
|
||||
|
||||
-export_type([operation_id/0]).
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-dialyzer({nowarn_function, [validate_response_body/4]}).
|
||||
|
||||
@@ -64,6 +105,7 @@ accept_callback(Class, OperationID, Req, Context) ->
|
||||
{max_length, MaxLength :: integer()} |
|
||||
{min_length, MaxLength :: integer()} |
|
||||
{pattern, Pattern :: string()} |
|
||||
{schema, object | list, binary()} |
|
||||
schema |
|
||||
required |
|
||||
not_required.
|
||||
@@ -111,121 +153,121 @@ for the `OperationID` operation.
|
||||
Body :: jesse:json_term(),
|
||||
ValidatorState :: jesse_state:state()) ->
|
||||
ok | {ok, term()} | [ok | {ok, term()}] | no_return().
|
||||
validate_response('TestAuthHttpBasic', 200, Body, ValidatorState) ->
|
||||
validate_response('test/auth/http/basic', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestAuthHttpBearer', 200, Body, ValidatorState) ->
|
||||
validate_response('test/auth/http/bearer', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestBinaryGif', 200, Body, ValidatorState) ->
|
||||
validate_response('test/binary/gif', 200, Body, ValidatorState) ->
|
||||
validate_response_body('file', 'file', Body, ValidatorState);
|
||||
validate_response('TestBodyApplicationOctetstreamBinary', 200, Body, ValidatorState) ->
|
||||
validate_response('test/body/application/octetstream/binary', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestBodyMultipartFormdataArrayOfBinary', 200, Body, ValidatorState) ->
|
||||
validate_response('test/body/multipart/formdata/array_of_binary', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestBodyMultipartFormdataSingleBinary', 200, Body, ValidatorState) ->
|
||||
validate_response('test/body/multipart/formdata/single_binary', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestEchoBodyAllOfPet', 200, Body, ValidatorState) ->
|
||||
validate_response('test/echo/body/allOf/Pet', 200, Body, ValidatorState) ->
|
||||
validate_response_body('Pet', 'Pet', Body, ValidatorState);
|
||||
validate_response('TestEchoBodyFreeFormObjectResponseString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/echo/body/FreeFormObject/response_string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestEchoBodyPet', 200, Body, ValidatorState) ->
|
||||
validate_response('test/echo/body/Pet', 200, Body, ValidatorState) ->
|
||||
validate_response_body('Pet', 'Pet', Body, ValidatorState);
|
||||
validate_response('TestEchoBodyPetResponseString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/echo/body/Pet/response_string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestEchoBodyStringEnum', 200, Body, ValidatorState) ->
|
||||
validate_response('test/echo/body/string_enum', 200, Body, ValidatorState) ->
|
||||
validate_response_body('StringEnumRef', 'StringEnumRef', Body, ValidatorState);
|
||||
validate_response('TestEchoBodyTagResponseString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/echo/body/Tag/response_string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestFormIntegerBooleanString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/form/integer/boolean/string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestFormObjectMultipart', 200, Body, ValidatorState) ->
|
||||
validate_response('test/form/object/multipart', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestFormOneof', 200, Body, ValidatorState) ->
|
||||
validate_response('test/form/oneof', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestHeaderIntegerBooleanStringEnums', 200, Body, ValidatorState) ->
|
||||
validate_response('test/header/integer/boolean/string/enums', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}', 200, Body, ValidatorState) ->
|
||||
validate_response('tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestEnumRefString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/enum_ref_string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryDatetimeDateString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/datetime/date/string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryIntegerBooleanString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/integer/boolean/string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleDeepObjectExplodeTrueObject', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_deepObject/explode_true/object', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleDeepObjectExplodeTrueObjectAllOf', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_deepObject/explode_true/object/allOf', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleFormExplodeFalseArrayInteger', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_form/explode_false/array_integer', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleFormExplodeFalseArrayString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_form/explode_false/array_string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleFormExplodeTrueArrayString', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_form/explode_true/array_string', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleFormExplodeTrueObject', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_form/explode_true/object', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response('TestQueryStyleFormExplodeTrueObjectAllOf', 200, Body, ValidatorState) ->
|
||||
validate_response('test/query/style_form/explode_true/object/allOf', 200, Body, ValidatorState) ->
|
||||
validate_response_body('binary', 'string', Body, ValidatorState);
|
||||
validate_response(_OperationID, _Code, _Body, _ValidatorState) ->
|
||||
ok.
|
||||
|
||||
%%%
|
||||
-spec request_params(OperationID :: operation_id()) -> [Param :: request_param()].
|
||||
request_params('TestAuthHttpBasic') ->
|
||||
request_params('test/auth/http/basic') ->
|
||||
[
|
||||
];
|
||||
request_params('TestAuthHttpBearer') ->
|
||||
request_params('test/auth/http/bearer') ->
|
||||
[
|
||||
];
|
||||
request_params('TestBinaryGif') ->
|
||||
request_params('test/binary/gif') ->
|
||||
[
|
||||
];
|
||||
request_params('TestBodyApplicationOctetstreamBinary') ->
|
||||
request_params('test/body/application/octetstream/binary') ->
|
||||
[
|
||||
'file'
|
||||
];
|
||||
request_params('TestBodyMultipartFormdataArrayOfBinary') ->
|
||||
request_params('test/body/multipart/formdata/array_of_binary') ->
|
||||
[
|
||||
'files'
|
||||
];
|
||||
request_params('TestBodyMultipartFormdataSingleBinary') ->
|
||||
request_params('test/body/multipart/formdata/single_binary') ->
|
||||
[
|
||||
'my-file'
|
||||
];
|
||||
request_params('TestEchoBodyAllOfPet') ->
|
||||
request_params('test/echo/body/allOf/Pet') ->
|
||||
[
|
||||
'Pet'
|
||||
];
|
||||
request_params('TestEchoBodyFreeFormObjectResponseString') ->
|
||||
request_params('test/echo/body/FreeFormObject/response_string') ->
|
||||
[
|
||||
'object'
|
||||
];
|
||||
request_params('TestEchoBodyPet') ->
|
||||
request_params('test/echo/body/Pet') ->
|
||||
[
|
||||
'Pet'
|
||||
];
|
||||
request_params('TestEchoBodyPetResponseString') ->
|
||||
request_params('test/echo/body/Pet/response_string') ->
|
||||
[
|
||||
'Pet'
|
||||
];
|
||||
request_params('TestEchoBodyStringEnum') ->
|
||||
request_params('test/echo/body/string_enum') ->
|
||||
[
|
||||
'binary'
|
||||
'StringEnumRef'
|
||||
];
|
||||
request_params('TestEchoBodyTagResponseString') ->
|
||||
request_params('test/echo/body/Tag/response_string') ->
|
||||
[
|
||||
'Tag'
|
||||
];
|
||||
request_params('TestFormIntegerBooleanString') ->
|
||||
request_params('test/form/integer/boolean/string') ->
|
||||
[
|
||||
'integer_form',
|
||||
'boolean_form',
|
||||
'string_form'
|
||||
];
|
||||
request_params('TestFormObjectMultipart') ->
|
||||
request_params('test/form/object/multipart') ->
|
||||
[
|
||||
'marker'
|
||||
];
|
||||
request_params('TestFormOneof') ->
|
||||
request_params('test/form/oneof') ->
|
||||
[
|
||||
'form1',
|
||||
'form2',
|
||||
@@ -234,7 +276,7 @@ request_params('TestFormOneof') ->
|
||||
'id',
|
||||
'name'
|
||||
];
|
||||
request_params('TestHeaderIntegerBooleanStringEnums') ->
|
||||
request_params('test/header/integer/boolean/string/enums') ->
|
||||
[
|
||||
'integer_header',
|
||||
'boolean_header',
|
||||
@@ -242,55 +284,55 @@ request_params('TestHeaderIntegerBooleanStringEnums') ->
|
||||
'enum_nonref_string_header',
|
||||
'enum_ref_string_header'
|
||||
];
|
||||
request_params('TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}') ->
|
||||
request_params('tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}') ->
|
||||
[
|
||||
'path_string',
|
||||
'path_integer',
|
||||
'enum_nonref_string_path',
|
||||
'enum_ref_string_path'
|
||||
];
|
||||
request_params('TestEnumRefString') ->
|
||||
request_params('test/enum_ref_string') ->
|
||||
[
|
||||
'enum_nonref_string_query',
|
||||
'enum_ref_string_query'
|
||||
];
|
||||
request_params('TestQueryDatetimeDateString') ->
|
||||
request_params('test/query/datetime/date/string') ->
|
||||
[
|
||||
'datetime_query',
|
||||
'date_query',
|
||||
'string_query'
|
||||
];
|
||||
request_params('TestQueryIntegerBooleanString') ->
|
||||
request_params('test/query/integer/boolean/string') ->
|
||||
[
|
||||
'integer_query',
|
||||
'boolean_query',
|
||||
'string_query'
|
||||
];
|
||||
request_params('TestQueryStyleDeepObjectExplodeTrueObject') ->
|
||||
request_params('test/query/style_deepObject/explode_true/object') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
request_params('TestQueryStyleDeepObjectExplodeTrueObjectAllOf') ->
|
||||
request_params('test/query/style_deepObject/explode_true/object/allOf') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
request_params('TestQueryStyleFormExplodeFalseArrayInteger') ->
|
||||
request_params('test/query/style_form/explode_false/array_integer') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
request_params('TestQueryStyleFormExplodeFalseArrayString') ->
|
||||
request_params('test/query/style_form/explode_false/array_string') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
request_params('TestQueryStyleFormExplodeTrueArrayString') ->
|
||||
request_params('test/query/style_form/explode_true/array_string') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
request_params('TestQueryStyleFormExplodeTrueObject') ->
|
||||
request_params('test/query/style_form/explode_true/object') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
request_params('TestQueryStyleFormExplodeTrueObjectAllOf') ->
|
||||
request_params('test/query/style_form/explode_true/object/allOf') ->
|
||||
[
|
||||
'query_object'
|
||||
];
|
||||
@@ -299,23 +341,22 @@ request_params(_) ->
|
||||
|
||||
-spec request_param_info(OperationID :: operation_id(), Name :: request_param()) ->
|
||||
#{source => qs_val | binding | header | body, rules => [rule()]}.
|
||||
request_param_info('TestBodyApplicationOctetstreamBinary', 'file') ->
|
||||
request_param_info('test/body/application/octetstream/binary', 'file') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
{type, binary},
|
||||
schema,
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestBodyMultipartFormdataArrayOfBinary', 'files') ->
|
||||
request_param_info('test/body/multipart/formdata/array_of_binary', 'files') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
required
|
||||
]
|
||||
};
|
||||
request_param_info('TestBodyMultipartFormdataSingleBinary', 'my-file') ->
|
||||
request_param_info('test/body/multipart/formdata/single_binary', 'my-file') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -323,55 +364,54 @@ request_param_info('TestBodyMultipartFormdataSingleBinary', 'my-file') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEchoBodyAllOfPet', 'Pet') ->
|
||||
request_param_info('test/echo/body/allOf/Pet', 'Pet') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
schema,
|
||||
{schema, object, <<"#/components/schemas/Pet">>},
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEchoBodyFreeFormObjectResponseString', 'object') ->
|
||||
request_param_info('test/echo/body/FreeFormObject/response_string', 'object') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
schema,
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEchoBodyPet', 'Pet') ->
|
||||
request_param_info('test/echo/body/Pet', 'Pet') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
schema,
|
||||
{schema, object, <<"#/components/schemas/Pet">>},
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEchoBodyPetResponseString', 'Pet') ->
|
||||
request_param_info('test/echo/body/Pet/response_string', 'Pet') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
schema,
|
||||
{schema, object, <<"#/components/schemas/Pet">>},
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEchoBodyStringEnum', 'binary') ->
|
||||
request_param_info('test/echo/body/string_enum', 'StringEnumRef') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
schema,
|
||||
{schema, object, <<"#/components/schemas/StringEnumRef">>},
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEchoBodyTagResponseString', 'Tag') ->
|
||||
request_param_info('test/echo/body/Tag/response_string', 'Tag') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
schema,
|
||||
{schema, object, <<"#/components/schemas/Tag">>},
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormIntegerBooleanString', 'integer_form') ->
|
||||
request_param_info('test/form/integer/boolean/string', 'integer_form') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -379,7 +419,7 @@ request_param_info('TestFormIntegerBooleanString', 'integer_form') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormIntegerBooleanString', 'boolean_form') ->
|
||||
request_param_info('test/form/integer/boolean/string', 'boolean_form') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -387,7 +427,7 @@ request_param_info('TestFormIntegerBooleanString', 'boolean_form') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormIntegerBooleanString', 'string_form') ->
|
||||
request_param_info('test/form/integer/boolean/string', 'string_form') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -395,14 +435,14 @@ request_param_info('TestFormIntegerBooleanString', 'string_form') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormObjectMultipart', 'marker') ->
|
||||
request_param_info('test/form/object/multipart', 'marker') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormOneof', 'form1') ->
|
||||
request_param_info('test/form/oneof', 'form1') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -410,7 +450,7 @@ request_param_info('TestFormOneof', 'form1') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormOneof', 'form2') ->
|
||||
request_param_info('test/form/oneof', 'form2') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -418,7 +458,7 @@ request_param_info('TestFormOneof', 'form2') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormOneof', 'form3') ->
|
||||
request_param_info('test/form/oneof', 'form3') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -426,7 +466,7 @@ request_param_info('TestFormOneof', 'form3') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormOneof', 'form4') ->
|
||||
request_param_info('test/form/oneof', 'form4') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -434,7 +474,7 @@ request_param_info('TestFormOneof', 'form4') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormOneof', 'id') ->
|
||||
request_param_info('test/form/oneof', 'id') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -442,7 +482,7 @@ request_param_info('TestFormOneof', 'id') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestFormOneof', 'name') ->
|
||||
request_param_info('test/form/oneof', 'name') ->
|
||||
#{
|
||||
source => body,
|
||||
rules => [
|
||||
@@ -450,7 +490,7 @@ request_param_info('TestFormOneof', 'name') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestHeaderIntegerBooleanStringEnums', 'integer_header') ->
|
||||
request_param_info('test/header/integer/boolean/string/enums', 'integer_header') ->
|
||||
#{
|
||||
source => header,
|
||||
rules => [
|
||||
@@ -458,7 +498,7 @@ request_param_info('TestHeaderIntegerBooleanStringEnums', 'integer_header') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestHeaderIntegerBooleanStringEnums', 'boolean_header') ->
|
||||
request_param_info('test/header/integer/boolean/string/enums', 'boolean_header') ->
|
||||
#{
|
||||
source => header,
|
||||
rules => [
|
||||
@@ -466,7 +506,7 @@ request_param_info('TestHeaderIntegerBooleanStringEnums', 'boolean_header') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestHeaderIntegerBooleanStringEnums', 'string_header') ->
|
||||
request_param_info('test/header/integer/boolean/string/enums', 'string_header') ->
|
||||
#{
|
||||
source => header,
|
||||
rules => [
|
||||
@@ -474,7 +514,7 @@ request_param_info('TestHeaderIntegerBooleanStringEnums', 'string_header') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestHeaderIntegerBooleanStringEnums', 'enum_nonref_string_header') ->
|
||||
request_param_info('test/header/integer/boolean/string/enums', 'enum_nonref_string_header') ->
|
||||
#{
|
||||
source => header,
|
||||
rules => [
|
||||
@@ -483,14 +523,14 @@ request_param_info('TestHeaderIntegerBooleanStringEnums', 'enum_nonref_string_he
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestHeaderIntegerBooleanStringEnums', 'enum_ref_string_header') ->
|
||||
request_param_info('test/header/integer/boolean/string/enums', 'enum_ref_string_header') ->
|
||||
#{
|
||||
source => header,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}', 'path_string') ->
|
||||
request_param_info('tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}', 'path_string') ->
|
||||
#{
|
||||
source => binding,
|
||||
rules => [
|
||||
@@ -498,7 +538,7 @@ request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefSt
|
||||
required
|
||||
]
|
||||
};
|
||||
request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}', 'path_integer') ->
|
||||
request_param_info('tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}', 'path_integer') ->
|
||||
#{
|
||||
source => binding,
|
||||
rules => [
|
||||
@@ -506,7 +546,7 @@ request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefSt
|
||||
required
|
||||
]
|
||||
};
|
||||
request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}', 'enum_nonref_string_path') ->
|
||||
request_param_info('tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}', 'enum_nonref_string_path') ->
|
||||
#{
|
||||
source => binding,
|
||||
rules => [
|
||||
@@ -515,14 +555,14 @@ request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefSt
|
||||
required
|
||||
]
|
||||
};
|
||||
request_param_info('TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}', 'enum_ref_string_path') ->
|
||||
request_param_info('tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}', 'enum_ref_string_path') ->
|
||||
#{
|
||||
source => binding,
|
||||
rules => [
|
||||
required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEnumRefString', 'enum_nonref_string_query') ->
|
||||
request_param_info('test/enum_ref_string', 'enum_nonref_string_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -531,14 +571,14 @@ request_param_info('TestEnumRefString', 'enum_nonref_string_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestEnumRefString', 'enum_ref_string_query') ->
|
||||
request_param_info('test/enum_ref_string', 'enum_ref_string_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryDatetimeDateString', 'datetime_query') ->
|
||||
request_param_info('test/query/datetime/date/string', 'datetime_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -546,7 +586,7 @@ request_param_info('TestQueryDatetimeDateString', 'datetime_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryDatetimeDateString', 'date_query') ->
|
||||
request_param_info('test/query/datetime/date/string', 'date_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -554,7 +594,7 @@ request_param_info('TestQueryDatetimeDateString', 'date_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryDatetimeDateString', 'string_query') ->
|
||||
request_param_info('test/query/datetime/date/string', 'string_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -562,7 +602,7 @@ request_param_info('TestQueryDatetimeDateString', 'string_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryIntegerBooleanString', 'integer_query') ->
|
||||
request_param_info('test/query/integer/boolean/string', 'integer_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -570,7 +610,7 @@ request_param_info('TestQueryIntegerBooleanString', 'integer_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryIntegerBooleanString', 'boolean_query') ->
|
||||
request_param_info('test/query/integer/boolean/string', 'boolean_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -578,7 +618,7 @@ request_param_info('TestQueryIntegerBooleanString', 'boolean_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryIntegerBooleanString', 'string_query') ->
|
||||
request_param_info('test/query/integer/boolean/string', 'string_query') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -586,49 +626,49 @@ request_param_info('TestQueryIntegerBooleanString', 'string_query') ->
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleDeepObjectExplodeTrueObject', 'query_object') ->
|
||||
request_param_info('test/query/style_deepObject/explode_true/object', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleDeepObjectExplodeTrueObjectAllOf', 'query_object') ->
|
||||
request_param_info('test/query/style_deepObject/explode_true/object/allOf', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleFormExplodeFalseArrayInteger', 'query_object') ->
|
||||
request_param_info('test/query/style_form/explode_false/array_integer', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleFormExplodeFalseArrayString', 'query_object') ->
|
||||
request_param_info('test/query/style_form/explode_false/array_string', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleFormExplodeTrueArrayString', 'query_object') ->
|
||||
request_param_info('test/query/style_form/explode_true/array_string', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleFormExplodeTrueObject', 'query_object') ->
|
||||
request_param_info('test/query/style_form/explode_true/object', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
not_required
|
||||
]
|
||||
};
|
||||
request_param_info('TestQueryStyleFormExplodeTrueObjectAllOf', 'query_object') ->
|
||||
request_param_info('test/query/style_form/explode_true/object/allOf', 'query_object') ->
|
||||
#{
|
||||
source => qs_val,
|
||||
rules => [
|
||||
@@ -668,8 +708,6 @@ populate_request_param(OperationID, ReqParamName, Req0, ValidatorState) ->
|
||||
end
|
||||
end.
|
||||
|
||||
-include_lib("kernel/include/logger.hrl").
|
||||
|
||||
validate_response_body(list, ReturnBaseType, Body, ValidatorState) ->
|
||||
[
|
||||
validate(schema, Item, ReturnBaseType, ValidatorState)
|
||||
@@ -760,8 +798,15 @@ validate(Rule = {pattern, Pattern}, Value, ReqParamName, _) ->
|
||||
{match, _} -> ok;
|
||||
_ -> validation_error(Rule, ReqParamName, Value)
|
||||
end;
|
||||
validate(Rule = schema, Value, ReqParamName, ValidatorState) ->
|
||||
validate(schema, Value, ReqParamName, ValidatorState) ->
|
||||
Definition = iolist_to_binary(["#/components/schemas/", atom_to_binary(ReqParamName, utf8)]),
|
||||
validate({schema, object, Definition}, Value, ReqParamName, ValidatorState);
|
||||
validate({schema, list, Definition}, Value, ReqParamName, ValidatorState) ->
|
||||
lists:foreach(
|
||||
fun(Item) ->
|
||||
validate({schema, object, Definition}, Item, ReqParamName, ValidatorState)
|
||||
end, Value);
|
||||
validate(Rule = {schema, object, Definition}, Value, ReqParamName, ValidatorState) ->
|
||||
try
|
||||
_ = validate_with_schema(Value, Definition, ValidatorState),
|
||||
ok
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
-moduledoc """
|
||||
Exposes the following operation IDs:
|
||||
|
||||
- `POST` to `/auth/http/basic`, OperationId: `TestAuthHttpBasic`:
|
||||
- `POST` to `/auth/http/basic`, OperationId: `test/auth/http/basic`:
|
||||
To test HTTP basic authentication.
|
||||
To test HTTP basic authentication
|
||||
|
||||
- `POST` to `/auth/http/bearer`, OperationId: `TestAuthHttpBearer`:
|
||||
- `POST` to `/auth/http/bearer`, OperationId: `test/auth/http/bearer`:
|
||||
To test HTTP bearer authentication.
|
||||
To test HTTP bearer authentication
|
||||
|
||||
""".
|
||||
|
||||
@@ -26,8 +28,17 @@ To test HTTP bearer authentication.
|
||||
|
||||
-ignore_xref([handle_type_accepted/2, handle_type_provided/2]).
|
||||
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-type class() :: 'auth'.
|
||||
|
||||
-type operation_id() ::
|
||||
'test/auth/http/basic' %% To test HTTP basic authentication
|
||||
| 'test/auth/http/bearer'. %% To test HTTP bearer authentication
|
||||
|
||||
|
||||
-record(state,
|
||||
{operation_id :: openapi_api:operation_id(),
|
||||
{operation_id :: operation_id(),
|
||||
accept_callback :: openapi_logic_handler:accept_callback(),
|
||||
provide_callback :: openapi_logic_handler:provide_callback(),
|
||||
api_key_handler :: openapi_logic_handler:api_key_callback(),
|
||||
@@ -51,9 +62,9 @@ init(Req, {Operations, Module}) ->
|
||||
|
||||
-spec allowed_methods(cowboy_req:req(), state()) ->
|
||||
{[binary()], cowboy_req:req(), state()}.
|
||||
allowed_methods(Req, #state{operation_id = 'TestAuthHttpBasic'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/auth/http/basic'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestAuthHttpBearer'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/auth/http/bearer'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, State) ->
|
||||
{[], Req, State}.
|
||||
@@ -61,7 +72,7 @@ allowed_methods(Req, State) ->
|
||||
-spec is_authorized(cowboy_req:req(), state()) ->
|
||||
{true | {false, iodata()}, cowboy_req:req(), state()}.
|
||||
is_authorized(Req0,
|
||||
#state{operation_id = 'TestAuthHttpBasic' = OperationID,
|
||||
#state{operation_id = 'test/auth/http/basic' = OperationID,
|
||||
api_key_handler = Handler} = State) ->
|
||||
case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of
|
||||
{true, Context, Req} ->
|
||||
@@ -70,7 +81,7 @@ is_authorized(Req0,
|
||||
{{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(Req0,
|
||||
#state{operation_id = 'TestAuthHttpBearer' = OperationID,
|
||||
#state{operation_id = 'test/auth/http/bearer' = OperationID,
|
||||
api_key_handler = Handler} = State) ->
|
||||
case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of
|
||||
{true, Context, Req} ->
|
||||
@@ -83,29 +94,29 @@ is_authorized(Req, State) ->
|
||||
|
||||
-spec content_types_accepted(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_accepted(Req, #state{operation_id = 'TestAuthHttpBasic'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/auth/http/basic'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestAuthHttpBearer'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/auth/http/bearer'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, State) ->
|
||||
{[], Req, State}.
|
||||
|
||||
-spec valid_content_headers(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
valid_content_headers(Req, #state{operation_id = 'TestAuthHttpBasic'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/auth/http/basic'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestAuthHttpBearer'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/auth/http/bearer'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, State) ->
|
||||
{false, Req, State}.
|
||||
|
||||
-spec content_types_provided(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_provided(Req, #state{operation_id = 'TestAuthHttpBasic'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/auth/http/basic'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestAuthHttpBearer'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/auth/http/bearer'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
@@ -115,8 +126,8 @@ content_types_provided(Req, State) ->
|
||||
-spec delete_resource(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
delete_resource(Req, State) ->
|
||||
{Res, Req1, State} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State}.
|
||||
{Res, Req1, State1} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State1}.
|
||||
|
||||
-spec handle_type_accepted(cowboy_req:req(), state()) ->
|
||||
{ openapi_logic_handler:accept_callback_return(), cowboy_req:req(), state()}.
|
||||
|
||||
@@ -2,35 +2,45 @@
|
||||
-moduledoc """
|
||||
Exposes the following operation IDs:
|
||||
|
||||
- `POST` to `/binary/gif`, OperationId: `TestBinaryGif`:
|
||||
- `POST` to `/binary/gif`, OperationId: `test/binary/gif`:
|
||||
Test binary (gif) response body.
|
||||
Test binary (gif) response body
|
||||
|
||||
- `POST` to `/body/application/octetstream/binary`, OperationId: `TestBodyApplicationOctetstreamBinary`:
|
||||
- `POST` to `/body/application/octetstream/binary`, OperationId: `test/body/application/octetstream/binary`:
|
||||
Test body parameter(s).
|
||||
Test body parameter(s)
|
||||
|
||||
- `POST` to `/body/application/octetstream/array_of_binary`, OperationId: `TestBodyMultipartFormdataArrayOfBinary`:
|
||||
- `POST` to `/body/application/octetstream/array_of_binary`, OperationId: `test/body/multipart/formdata/array_of_binary`:
|
||||
Test array of binary in multipart mime.
|
||||
Test array of binary in multipart mime
|
||||
|
||||
- `POST` to `/body/application/octetstream/single_binary`, OperationId: `TestBodyMultipartFormdataSingleBinary`:
|
||||
- `POST` to `/body/application/octetstream/single_binary`, OperationId: `test/body/multipart/formdata/single_binary`:
|
||||
Test single binary in multipart mime.
|
||||
Test single binary in multipart mime
|
||||
|
||||
- `POST` to `/echo/body/allOf/Pet`, OperationId: `TestEchoBodyAllOfPet`:
|
||||
- `POST` to `/echo/body/allOf/Pet`, OperationId: `test/echo/body/allOf/Pet`:
|
||||
Test body parameter(s).
|
||||
Test body parameter(s)
|
||||
|
||||
- `POST` to `/echo/body/FreeFormObject/response_string`, OperationId: `TestEchoBodyFreeFormObjectResponseString`:
|
||||
- `POST` to `/echo/body/FreeFormObject/response_string`, OperationId: `test/echo/body/FreeFormObject/response_string`:
|
||||
Test free form object.
|
||||
Test free form object
|
||||
|
||||
- `POST` to `/echo/body/Pet`, OperationId: `TestEchoBodyPet`:
|
||||
- `POST` to `/echo/body/Pet`, OperationId: `test/echo/body/Pet`:
|
||||
Test body parameter(s).
|
||||
Test body parameter(s)
|
||||
|
||||
- `POST` to `/echo/body/Pet/response_string`, OperationId: `TestEchoBodyPetResponseString`:
|
||||
- `POST` to `/echo/body/Pet/response_string`, OperationId: `test/echo/body/Pet/response_string`:
|
||||
Test empty response body.
|
||||
Test empty response body
|
||||
|
||||
- `POST` to `/echo/body/string_enum`, OperationId: `TestEchoBodyStringEnum`:
|
||||
- `POST` to `/echo/body/string_enum`, OperationId: `test/echo/body/string_enum`:
|
||||
Test string enum response body.
|
||||
Test string enum response body
|
||||
|
||||
- `POST` to `/echo/body/Tag/response_string`, OperationId: `TestEchoBodyTagResponseString`:
|
||||
- `POST` to `/echo/body/Tag/response_string`, OperationId: `test/echo/body/Tag/response_string`:
|
||||
Test empty json (request body).
|
||||
Test empty json (request body)
|
||||
|
||||
""".
|
||||
|
||||
@@ -50,8 +60,25 @@ Test empty json (request body).
|
||||
|
||||
-ignore_xref([handle_type_accepted/2, handle_type_provided/2]).
|
||||
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-type class() :: 'body'.
|
||||
|
||||
-type operation_id() ::
|
||||
'test/binary/gif' %% Test binary (gif) response body
|
||||
| 'test/body/application/octetstream/binary' %% Test body parameter(s)
|
||||
| 'test/body/multipart/formdata/array_of_binary' %% Test array of binary in multipart mime
|
||||
| 'test/body/multipart/formdata/single_binary' %% Test single binary in multipart mime
|
||||
| 'test/echo/body/allOf/Pet' %% Test body parameter(s)
|
||||
| 'test/echo/body/FreeFormObject/response_string' %% Test free form object
|
||||
| 'test/echo/body/Pet' %% Test body parameter(s)
|
||||
| 'test/echo/body/Pet/response_string' %% Test empty response body
|
||||
| 'test/echo/body/string_enum' %% Test string enum response body
|
||||
| 'test/echo/body/Tag/response_string'. %% Test empty json (request body)
|
||||
|
||||
|
||||
-record(state,
|
||||
{operation_id :: openapi_api:operation_id(),
|
||||
{operation_id :: operation_id(),
|
||||
accept_callback :: openapi_logic_handler:accept_callback(),
|
||||
provide_callback :: openapi_logic_handler:provide_callback(),
|
||||
api_key_handler :: openapi_logic_handler:api_key_callback(),
|
||||
@@ -75,25 +102,25 @@ init(Req, {Operations, Module}) ->
|
||||
|
||||
-spec allowed_methods(cowboy_req:req(), state()) ->
|
||||
{[binary()], cowboy_req:req(), state()}.
|
||||
allowed_methods(Req, #state{operation_id = 'TestBinaryGif'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/binary/gif'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestBodyApplicationOctetstreamBinary'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/body/application/octetstream/binary'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestBodyMultipartFormdataArrayOfBinary'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/body/multipart/formdata/array_of_binary'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestBodyMultipartFormdataSingleBinary'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/body/multipart/formdata/single_binary'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestEchoBodyAllOfPet'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/echo/body/allOf/Pet'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestEchoBodyFreeFormObjectResponseString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/echo/body/FreeFormObject/response_string'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestEchoBodyPet'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/echo/body/Pet'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestEchoBodyPetResponseString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/echo/body/Pet/response_string'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestEchoBodyStringEnum'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/echo/body/string_enum'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestEchoBodyTagResponseString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/echo/body/Tag/response_string'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, State) ->
|
||||
{[], Req, State}.
|
||||
@@ -105,41 +132,41 @@ is_authorized(Req, State) ->
|
||||
|
||||
-spec content_types_accepted(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_accepted(Req, #state{operation_id = 'TestBinaryGif'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/binary/gif'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestBodyApplicationOctetstreamBinary'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/body/application/octetstream/binary'} = State) ->
|
||||
{[
|
||||
{<<"application/octet-stream">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestBodyMultipartFormdataArrayOfBinary'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/body/multipart/formdata/array_of_binary'} = State) ->
|
||||
{[
|
||||
{<<"multipart/form-data">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestBodyMultipartFormdataSingleBinary'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/body/multipart/formdata/single_binary'} = State) ->
|
||||
{[
|
||||
{<<"multipart/form-data">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEchoBodyAllOfPet'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/echo/body/allOf/Pet'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEchoBodyFreeFormObjectResponseString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/echo/body/FreeFormObject/response_string'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEchoBodyPet'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/echo/body/Pet'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEchoBodyPetResponseString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/echo/body/Pet/response_string'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEchoBodyStringEnum'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/echo/body/string_enum'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEchoBodyTagResponseString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/echo/body/Tag/response_string'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
@@ -148,68 +175,68 @@ content_types_accepted(Req, State) ->
|
||||
|
||||
-spec valid_content_headers(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
valid_content_headers(Req, #state{operation_id = 'TestBinaryGif'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/binary/gif'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestBodyApplicationOctetstreamBinary'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/body/application/octetstream/binary'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestBodyMultipartFormdataArrayOfBinary'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/body/multipart/formdata/array_of_binary'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestBodyMultipartFormdataSingleBinary'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/body/multipart/formdata/single_binary'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEchoBodyAllOfPet'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/echo/body/allOf/Pet'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEchoBodyFreeFormObjectResponseString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/echo/body/FreeFormObject/response_string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEchoBodyPet'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/echo/body/Pet'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEchoBodyPetResponseString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/echo/body/Pet/response_string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEchoBodyStringEnum'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/echo/body/string_enum'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEchoBodyTagResponseString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/echo/body/Tag/response_string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, State) ->
|
||||
{false, Req, State}.
|
||||
|
||||
-spec content_types_provided(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_provided(Req, #state{operation_id = 'TestBinaryGif'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/binary/gif'} = State) ->
|
||||
{[
|
||||
{<<"image/gif">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestBodyApplicationOctetstreamBinary'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/body/application/octetstream/binary'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestBodyMultipartFormdataArrayOfBinary'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/body/multipart/formdata/array_of_binary'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestBodyMultipartFormdataSingleBinary'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/body/multipart/formdata/single_binary'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestEchoBodyAllOfPet'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/echo/body/allOf/Pet'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestEchoBodyFreeFormObjectResponseString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/echo/body/FreeFormObject/response_string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestEchoBodyPet'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/echo/body/Pet'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestEchoBodyPetResponseString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/echo/body/Pet/response_string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestEchoBodyStringEnum'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/echo/body/string_enum'} = State) ->
|
||||
{[
|
||||
{<<"application/json">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestEchoBodyTagResponseString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/echo/body/Tag/response_string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
@@ -219,8 +246,8 @@ content_types_provided(Req, State) ->
|
||||
-spec delete_resource(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
delete_resource(Req, State) ->
|
||||
{Res, Req1, State} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State}.
|
||||
{Res, Req1, State1} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State1}.
|
||||
|
||||
-spec handle_type_accepted(cowboy_req:req(), state()) ->
|
||||
{ openapi_logic_handler:accept_callback_return(), cowboy_req:req(), state()}.
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
-moduledoc """
|
||||
Exposes the following operation IDs:
|
||||
|
||||
- `POST` to `/form/integer/boolean/string`, OperationId: `TestFormIntegerBooleanString`:
|
||||
- `POST` to `/form/integer/boolean/string`, OperationId: `test/form/integer/boolean/string`:
|
||||
Test form parameter(s).
|
||||
Test form parameter(s)
|
||||
|
||||
- `POST` to `/form/object/multipart`, OperationId: `TestFormObjectMultipart`:
|
||||
- `POST` to `/form/object/multipart`, OperationId: `test/form/object/multipart`:
|
||||
Test form parameter(s) for multipart schema.
|
||||
Test form parameter(s) for multipart schema
|
||||
|
||||
- `POST` to `/form/oneof`, OperationId: `TestFormOneof`:
|
||||
- `POST` to `/form/oneof`, OperationId: `test/form/oneof`:
|
||||
Test form parameter(s) for oneOf schema.
|
||||
Test form parameter(s) for oneOf schema
|
||||
|
||||
""".
|
||||
|
||||
@@ -29,8 +32,18 @@ Test form parameter(s) for oneOf schema.
|
||||
|
||||
-ignore_xref([handle_type_accepted/2, handle_type_provided/2]).
|
||||
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-type class() :: 'form'.
|
||||
|
||||
-type operation_id() ::
|
||||
'test/form/integer/boolean/string' %% Test form parameter(s)
|
||||
| 'test/form/object/multipart' %% Test form parameter(s) for multipart schema
|
||||
| 'test/form/oneof'. %% Test form parameter(s) for oneOf schema
|
||||
|
||||
|
||||
-record(state,
|
||||
{operation_id :: openapi_api:operation_id(),
|
||||
{operation_id :: operation_id(),
|
||||
accept_callback :: openapi_logic_handler:accept_callback(),
|
||||
provide_callback :: openapi_logic_handler:provide_callback(),
|
||||
api_key_handler :: openapi_logic_handler:api_key_callback(),
|
||||
@@ -54,11 +67,11 @@ init(Req, {Operations, Module}) ->
|
||||
|
||||
-spec allowed_methods(cowboy_req:req(), state()) ->
|
||||
{[binary()], cowboy_req:req(), state()}.
|
||||
allowed_methods(Req, #state{operation_id = 'TestFormIntegerBooleanString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/form/integer/boolean/string'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestFormObjectMultipart'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/form/object/multipart'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestFormOneof'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/form/oneof'} = State) ->
|
||||
{[<<"POST">>], Req, State};
|
||||
allowed_methods(Req, State) ->
|
||||
{[], Req, State}.
|
||||
@@ -70,15 +83,15 @@ is_authorized(Req, State) ->
|
||||
|
||||
-spec content_types_accepted(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_accepted(Req, #state{operation_id = 'TestFormIntegerBooleanString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/form/integer/boolean/string'} = State) ->
|
||||
{[
|
||||
{<<"application/x-www-form-urlencoded">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestFormObjectMultipart'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/form/object/multipart'} = State) ->
|
||||
{[
|
||||
{<<"multipart/form-data">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestFormOneof'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/form/oneof'} = State) ->
|
||||
{[
|
||||
{<<"application/x-www-form-urlencoded">>, handle_type_accepted}
|
||||
], Req, State};
|
||||
@@ -87,26 +100,26 @@ content_types_accepted(Req, State) ->
|
||||
|
||||
-spec valid_content_headers(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
valid_content_headers(Req, #state{operation_id = 'TestFormIntegerBooleanString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/form/integer/boolean/string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestFormObjectMultipart'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/form/object/multipart'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestFormOneof'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/form/oneof'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, State) ->
|
||||
{false, Req, State}.
|
||||
|
||||
-spec content_types_provided(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_provided(Req, #state{operation_id = 'TestFormIntegerBooleanString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/form/integer/boolean/string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestFormObjectMultipart'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/form/object/multipart'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestFormOneof'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/form/oneof'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
@@ -116,8 +129,8 @@ content_types_provided(Req, State) ->
|
||||
-spec delete_resource(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
delete_resource(Req, State) ->
|
||||
{Res, Req1, State} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State}.
|
||||
{Res, Req1, State1} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State1}.
|
||||
|
||||
-spec handle_type_accepted(cowboy_req:req(), state()) ->
|
||||
{ openapi_logic_handler:accept_callback_return(), cowboy_req:req(), state()}.
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
-moduledoc """
|
||||
Exposes the following operation IDs:
|
||||
|
||||
- `GET` to `/header/integer/boolean/string/enums`, OperationId: `TestHeaderIntegerBooleanStringEnums`:
|
||||
- `GET` to `/header/integer/boolean/string/enums`, OperationId: `test/header/integer/boolean/string/enums`:
|
||||
Test header parameter(s).
|
||||
Test header parameter(s)
|
||||
|
||||
""".
|
||||
|
||||
@@ -23,8 +24,16 @@ Test header parameter(s).
|
||||
|
||||
-ignore_xref([handle_type_accepted/2, handle_type_provided/2]).
|
||||
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-type class() :: 'header'.
|
||||
|
||||
-type operation_id() ::
|
||||
'test/header/integer/boolean/string/enums'. %% Test header parameter(s)
|
||||
|
||||
|
||||
-record(state,
|
||||
{operation_id :: openapi_api:operation_id(),
|
||||
{operation_id :: operation_id(),
|
||||
accept_callback :: openapi_logic_handler:accept_callback(),
|
||||
provide_callback :: openapi_logic_handler:provide_callback(),
|
||||
api_key_handler :: openapi_logic_handler:api_key_callback(),
|
||||
@@ -48,7 +57,7 @@ init(Req, {Operations, Module}) ->
|
||||
|
||||
-spec allowed_methods(cowboy_req:req(), state()) ->
|
||||
{[binary()], cowboy_req:req(), state()}.
|
||||
allowed_methods(Req, #state{operation_id = 'TestHeaderIntegerBooleanStringEnums'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/header/integer/boolean/string/enums'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, State) ->
|
||||
{[], Req, State}.
|
||||
@@ -60,21 +69,21 @@ is_authorized(Req, State) ->
|
||||
|
||||
-spec content_types_accepted(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_accepted(Req, #state{operation_id = 'TestHeaderIntegerBooleanStringEnums'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/header/integer/boolean/string/enums'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, State) ->
|
||||
{[], Req, State}.
|
||||
|
||||
-spec valid_content_headers(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
valid_content_headers(Req, #state{operation_id = 'TestHeaderIntegerBooleanStringEnums'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/header/integer/boolean/string/enums'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, State) ->
|
||||
{false, Req, State}.
|
||||
|
||||
-spec content_types_provided(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_provided(Req, #state{operation_id = 'TestHeaderIntegerBooleanStringEnums'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/header/integer/boolean/string/enums'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
@@ -84,8 +93,8 @@ content_types_provided(Req, State) ->
|
||||
-spec delete_resource(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
delete_resource(Req, State) ->
|
||||
{Res, Req1, State} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State}.
|
||||
{Res, Req1, State1} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State1}.
|
||||
|
||||
-spec handle_type_accepted(cowboy_req:req(), state()) ->
|
||||
{ openapi_logic_handler:accept_callback_return(), cowboy_req:req(), state()}.
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
-type api_key_callback() ::
|
||||
fun((openapi_api:operation_id(), binary()) -> {true, context()} | {false, iodata()}).
|
||||
-type accept_callback() ::
|
||||
fun((atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
fun((openapi_api:class(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{accept_callback_return(), cowboy_req:req(), context()}).
|
||||
-type provide_callback() ::
|
||||
fun((atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
fun((openapi_api:class(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{cowboy_req:resp_body(), cowboy_req:req(), context()}).
|
||||
-type context() :: #{_ := _}.
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
-callback api_key_callback(openapi_api:operation_id(), binary()) ->
|
||||
{true, context()} | {false, iodata()}.
|
||||
|
||||
-callback accept_callback(atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
-callback accept_callback(openapi_api:class(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{accept_callback_return(), cowboy_req:req(), context()}.
|
||||
|
||||
-callback provide_callback(atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
-callback provide_callback(openapi_api:class(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{cowboy_req:resp_body(), cowboy_req:req(), context()}.
|
||||
|
||||
-export([api_key_callback/2, accept_callback/4, provide_callback/4]).
|
||||
@@ -42,7 +42,7 @@ api_key_callback(OperationID, ApiKey) ->
|
||||
api_key => ApiKey}),
|
||||
{true, #{}}.
|
||||
|
||||
-spec accept_callback(atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
-spec accept_callback(openapi_api:class(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{accept_callback_return(), cowboy_req:req(), context()}.
|
||||
accept_callback(Class, OperationID, Req, Context) ->
|
||||
?LOG_ERROR(#{what => "Got not implemented request to process",
|
||||
@@ -52,7 +52,7 @@ accept_callback(Class, OperationID, Req, Context) ->
|
||||
context => Context}),
|
||||
{false, Req, Context}.
|
||||
|
||||
-spec provide_callback(atom(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
-spec provide_callback(openapi_api:class(), openapi_api:operation_id(), cowboy_req:req(), context()) ->
|
||||
{cowboy_req:resp_body(), cowboy_req:req(), context()}.
|
||||
provide_callback(Class, OperationID, Req, Context) ->
|
||||
?LOG_ERROR(#{what => "Got not implemented request to process",
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
-moduledoc """
|
||||
Exposes the following operation IDs:
|
||||
|
||||
- `GET` to `/path/string/:path_string/integer/:path_integer/:enum_nonref_string_path/:enum_ref_string_path`, OperationId: `TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}`:
|
||||
- `GET` to `/path/string/:path_string/integer/:path_integer/:enum_nonref_string_path/:enum_ref_string_path`, OperationId: `tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}`:
|
||||
Test path parameter(s).
|
||||
Test path parameter(s)
|
||||
|
||||
""".
|
||||
|
||||
@@ -23,8 +24,16 @@ Test path parameter(s).
|
||||
|
||||
-ignore_xref([handle_type_accepted/2, handle_type_provided/2]).
|
||||
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-type class() :: 'path'.
|
||||
|
||||
-type operation_id() ::
|
||||
'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}'. %% Test path parameter(s)
|
||||
|
||||
|
||||
-record(state,
|
||||
{operation_id :: openapi_api:operation_id(),
|
||||
{operation_id :: operation_id(),
|
||||
accept_callback :: openapi_logic_handler:accept_callback(),
|
||||
provide_callback :: openapi_logic_handler:provide_callback(),
|
||||
api_key_handler :: openapi_logic_handler:api_key_callback(),
|
||||
@@ -48,7 +57,7 @@ init(Req, {Operations, Module}) ->
|
||||
|
||||
-spec allowed_methods(cowboy_req:req(), state()) ->
|
||||
{[binary()], cowboy_req:req(), state()}.
|
||||
allowed_methods(Req, #state{operation_id = 'TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, State) ->
|
||||
{[], Req, State}.
|
||||
@@ -60,21 +69,21 @@ is_authorized(Req, State) ->
|
||||
|
||||
-spec content_types_accepted(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_accepted(Req, #state{operation_id = 'TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, State) ->
|
||||
{[], Req, State}.
|
||||
|
||||
-spec valid_content_headers(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
valid_content_headers(Req, #state{operation_id = 'TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, State) ->
|
||||
{false, Req, State}.
|
||||
|
||||
-spec content_types_provided(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_provided(Req, #state{operation_id = 'TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
@@ -84,8 +93,8 @@ content_types_provided(Req, State) ->
|
||||
-spec delete_resource(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
delete_resource(Req, State) ->
|
||||
{Res, Req1, State} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State}.
|
||||
{Res, Req1, State1} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State1}.
|
||||
|
||||
-spec handle_type_accepted(cowboy_req:req(), state()) ->
|
||||
{ openapi_logic_handler:accept_callback_return(), cowboy_req:req(), state()}.
|
||||
|
||||
@@ -2,35 +2,45 @@
|
||||
-moduledoc """
|
||||
Exposes the following operation IDs:
|
||||
|
||||
- `GET` to `/query/enum_ref_string`, OperationId: `TestEnumRefString`:
|
||||
- `GET` to `/query/enum_ref_string`, OperationId: `test/enum_ref_string`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/datetime/date/string`, OperationId: `TestQueryDatetimeDateString`:
|
||||
- `GET` to `/query/datetime/date/string`, OperationId: `test/query/datetime/date/string`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/integer/boolean/string`, OperationId: `TestQueryIntegerBooleanString`:
|
||||
- `GET` to `/query/integer/boolean/string`, OperationId: `test/query/integer/boolean/string`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_deepObject/explode_true/object`, OperationId: `TestQueryStyleDeepObjectExplodeTrueObject`:
|
||||
- `GET` to `/query/style_deepObject/explode_true/object`, OperationId: `test/query/style_deepObject/explode_true/object`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_deepObject/explode_true/object/allOf`, OperationId: `TestQueryStyleDeepObjectExplodeTrueObjectAllOf`:
|
||||
- `GET` to `/query/style_deepObject/explode_true/object/allOf`, OperationId: `test/query/style_deepObject/explode_true/object/allOf`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_form/explode_false/array_integer`, OperationId: `TestQueryStyleFormExplodeFalseArrayInteger`:
|
||||
- `GET` to `/query/style_form/explode_false/array_integer`, OperationId: `test/query/style_form/explode_false/array_integer`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_form/explode_false/array_string`, OperationId: `TestQueryStyleFormExplodeFalseArrayString`:
|
||||
- `GET` to `/query/style_form/explode_false/array_string`, OperationId: `test/query/style_form/explode_false/array_string`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_form/explode_true/array_string`, OperationId: `TestQueryStyleFormExplodeTrueArrayString`:
|
||||
- `GET` to `/query/style_form/explode_true/array_string`, OperationId: `test/query/style_form/explode_true/array_string`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_form/explode_true/object`, OperationId: `TestQueryStyleFormExplodeTrueObject`:
|
||||
- `GET` to `/query/style_form/explode_true/object`, OperationId: `test/query/style_form/explode_true/object`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
- `GET` to `/query/style_form/explode_true/object/allOf`, OperationId: `TestQueryStyleFormExplodeTrueObjectAllOf`:
|
||||
- `GET` to `/query/style_form/explode_true/object/allOf`, OperationId: `test/query/style_form/explode_true/object/allOf`:
|
||||
Test query parameter(s).
|
||||
Test query parameter(s)
|
||||
|
||||
""".
|
||||
|
||||
@@ -50,8 +60,25 @@ Test query parameter(s).
|
||||
|
||||
-ignore_xref([handle_type_accepted/2, handle_type_provided/2]).
|
||||
|
||||
-export_type([class/0, operation_id/0]).
|
||||
|
||||
-type class() :: 'query'.
|
||||
|
||||
-type operation_id() ::
|
||||
'test/enum_ref_string' %% Test query parameter(s)
|
||||
| 'test/query/datetime/date/string' %% Test query parameter(s)
|
||||
| 'test/query/integer/boolean/string' %% Test query parameter(s)
|
||||
| 'test/query/style_deepObject/explode_true/object' %% Test query parameter(s)
|
||||
| 'test/query/style_deepObject/explode_true/object/allOf' %% Test query parameter(s)
|
||||
| 'test/query/style_form/explode_false/array_integer' %% Test query parameter(s)
|
||||
| 'test/query/style_form/explode_false/array_string' %% Test query parameter(s)
|
||||
| 'test/query/style_form/explode_true/array_string' %% Test query parameter(s)
|
||||
| 'test/query/style_form/explode_true/object' %% Test query parameter(s)
|
||||
| 'test/query/style_form/explode_true/object/allOf'. %% Test query parameter(s)
|
||||
|
||||
|
||||
-record(state,
|
||||
{operation_id :: openapi_api:operation_id(),
|
||||
{operation_id :: operation_id(),
|
||||
accept_callback :: openapi_logic_handler:accept_callback(),
|
||||
provide_callback :: openapi_logic_handler:provide_callback(),
|
||||
api_key_handler :: openapi_logic_handler:api_key_callback(),
|
||||
@@ -75,25 +102,25 @@ init(Req, {Operations, Module}) ->
|
||||
|
||||
-spec allowed_methods(cowboy_req:req(), state()) ->
|
||||
{[binary()], cowboy_req:req(), state()}.
|
||||
allowed_methods(Req, #state{operation_id = 'TestEnumRefString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/enum_ref_string'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryDatetimeDateString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/datetime/date/string'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryIntegerBooleanString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/integer/boolean/string'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObject'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObjectAllOf'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object/allOf'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayInteger'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_form/explode_false/array_integer'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_form/explode_false/array_string'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueArrayString'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_form/explode_true/array_string'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObject'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_form/explode_true/object'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObjectAllOf'} = State) ->
|
||||
allowed_methods(Req, #state{operation_id = 'test/query/style_form/explode_true/object/allOf'} = State) ->
|
||||
{[<<"GET">>], Req, State};
|
||||
allowed_methods(Req, State) ->
|
||||
{[], Req, State}.
|
||||
@@ -105,93 +132,93 @@ is_authorized(Req, State) ->
|
||||
|
||||
-spec content_types_accepted(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_accepted(Req, #state{operation_id = 'TestEnumRefString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/enum_ref_string'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryDatetimeDateString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/datetime/date/string'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryIntegerBooleanString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/integer/boolean/string'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObject'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObjectAllOf'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object/allOf'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayInteger'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_form/explode_false/array_integer'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_form/explode_false/array_string'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueArrayString'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_form/explode_true/array_string'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObject'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_form/explode_true/object'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObjectAllOf'} = State) ->
|
||||
content_types_accepted(Req, #state{operation_id = 'test/query/style_form/explode_true/object/allOf'} = State) ->
|
||||
{[], Req, State};
|
||||
content_types_accepted(Req, State) ->
|
||||
{[], Req, State}.
|
||||
|
||||
-spec valid_content_headers(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
valid_content_headers(Req, #state{operation_id = 'TestEnumRefString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/enum_ref_string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryDatetimeDateString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/datetime/date/string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryIntegerBooleanString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/integer/boolean/string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObject'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObjectAllOf'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object/allOf'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayInteger'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_form/explode_false/array_integer'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_form/explode_false/array_string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueArrayString'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_form/explode_true/array_string'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObject'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_form/explode_true/object'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObjectAllOf'} = State) ->
|
||||
valid_content_headers(Req, #state{operation_id = 'test/query/style_form/explode_true/object/allOf'} = State) ->
|
||||
{true, Req, State};
|
||||
valid_content_headers(Req, State) ->
|
||||
{false, Req, State}.
|
||||
|
||||
-spec content_types_provided(cowboy_req:req(), state()) ->
|
||||
{[{binary(), atom()}], cowboy_req:req(), state()}.
|
||||
content_types_provided(Req, #state{operation_id = 'TestEnumRefString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/enum_ref_string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryDatetimeDateString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/datetime/date/string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryIntegerBooleanString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/integer/boolean/string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObject'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleDeepObjectExplodeTrueObjectAllOf'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_deepObject/explode_true/object/allOf'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayInteger'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_form/explode_false/array_integer'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleFormExplodeFalseArrayString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_form/explode_false/array_string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueArrayString'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_form/explode_true/array_string'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObject'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_form/explode_true/object'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
content_types_provided(Req, #state{operation_id = 'TestQueryStyleFormExplodeTrueObjectAllOf'} = State) ->
|
||||
content_types_provided(Req, #state{operation_id = 'test/query/style_form/explode_true/object/allOf'} = State) ->
|
||||
{[
|
||||
{<<"text/plain">>, handle_type_provided}
|
||||
], Req, State};
|
||||
@@ -201,8 +228,8 @@ content_types_provided(Req, State) ->
|
||||
-spec delete_resource(cowboy_req:req(), state()) ->
|
||||
{boolean(), cowboy_req:req(), state()}.
|
||||
delete_resource(Req, State) ->
|
||||
{Res, Req1, State} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State}.
|
||||
{Res, Req1, State1} = handle_type_accepted(Req, State),
|
||||
{true =:= Res, Req1, State1}.
|
||||
|
||||
-spec handle_type_accepted(cowboy_req:req(), state()) ->
|
||||
{ openapi_logic_handler:accept_callback_return(), cowboy_req:req(), state()}.
|
||||
|
||||
@@ -47,189 +47,189 @@ merge_paths(FullPaths, OperationID, Method, Handler, Acc) ->
|
||||
|
||||
get_operations() ->
|
||||
#{
|
||||
'TestAuthHttpBasic' => #{
|
||||
'test/auth/http/basic' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/auth/http/basic",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_auth_handler'
|
||||
},
|
||||
'TestAuthHttpBearer' => #{
|
||||
'test/auth/http/bearer' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/auth/http/bearer",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_auth_handler'
|
||||
},
|
||||
'TestBinaryGif' => #{
|
||||
'test/binary/gif' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/binary/gif",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestBodyApplicationOctetstreamBinary' => #{
|
||||
'test/body/application/octetstream/binary' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/body/application/octetstream/binary",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestBodyMultipartFormdataArrayOfBinary' => #{
|
||||
'test/body/multipart/formdata/array_of_binary' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/body/application/octetstream/array_of_binary",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestBodyMultipartFormdataSingleBinary' => #{
|
||||
'test/body/multipart/formdata/single_binary' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/body/application/octetstream/single_binary",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestEchoBodyAllOfPet' => #{
|
||||
'test/echo/body/allOf/Pet' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/echo/body/allOf/Pet",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestEchoBodyFreeFormObjectResponseString' => #{
|
||||
'test/echo/body/FreeFormObject/response_string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/echo/body/FreeFormObject/response_string",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestEchoBodyPet' => #{
|
||||
'test/echo/body/Pet' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/echo/body/Pet",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestEchoBodyPetResponseString' => #{
|
||||
'test/echo/body/Pet/response_string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/echo/body/Pet/response_string",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestEchoBodyStringEnum' => #{
|
||||
'test/echo/body/string_enum' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/echo/body/string_enum",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestEchoBodyTagResponseString' => #{
|
||||
'test/echo/body/Tag/response_string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/echo/body/Tag/response_string",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_body_handler'
|
||||
},
|
||||
'TestFormIntegerBooleanString' => #{
|
||||
'test/form/integer/boolean/string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/form/integer/boolean/string",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_form_handler'
|
||||
},
|
||||
'TestFormObjectMultipart' => #{
|
||||
'test/form/object/multipart' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/form/object/multipart",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_form_handler'
|
||||
},
|
||||
'TestFormOneof' => #{
|
||||
'test/form/oneof' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/form/oneof",
|
||||
method => <<"POST">>,
|
||||
handler => 'openapi_form_handler'
|
||||
},
|
||||
'TestHeaderIntegerBooleanStringEnums' => #{
|
||||
'test/header/integer/boolean/string/enums' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/header/integer/boolean/string/enums",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_header_handler'
|
||||
},
|
||||
'TestsPathString{pathString}Integer{pathInteger}{enumNonrefStringPath}{enumRefStringPath}' => #{
|
||||
'tests/path/string/{path_string}/integer/{path_integer}/{enum_nonref_string_path}/{enum_ref_string_path}' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/path/string/:path_string/integer/:path_integer/:enum_nonref_string_path/:enum_ref_string_path",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_path_handler'
|
||||
},
|
||||
'TestEnumRefString' => #{
|
||||
'test/enum_ref_string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/enum_ref_string",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryDatetimeDateString' => #{
|
||||
'test/query/datetime/date/string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/datetime/date/string",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryIntegerBooleanString' => #{
|
||||
'test/query/integer/boolean/string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/integer/boolean/string",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleDeepObjectExplodeTrueObject' => #{
|
||||
'test/query/style_deepObject/explode_true/object' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_deepObject/explode_true/object",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleDeepObjectExplodeTrueObjectAllOf' => #{
|
||||
'test/query/style_deepObject/explode_true/object/allOf' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_deepObject/explode_true/object/allOf",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleFormExplodeFalseArrayInteger' => #{
|
||||
'test/query/style_form/explode_false/array_integer' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_form/explode_false/array_integer",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleFormExplodeFalseArrayString' => #{
|
||||
'test/query/style_form/explode_false/array_string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_form/explode_false/array_string",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleFormExplodeTrueArrayString' => #{
|
||||
'test/query/style_form/explode_true/array_string' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_form/explode_true/array_string",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleFormExplodeTrueObject' => #{
|
||||
'test/query/style_form/explode_true/object' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_form/explode_true/object",
|
||||
method => <<"GET">>,
|
||||
handler => 'openapi_query_handler'
|
||||
},
|
||||
'TestQueryStyleFormExplodeTrueObjectAllOf' => #{
|
||||
'test/query/style_form/explode_true/object/allOf' => #{
|
||||
servers => [],
|
||||
base_path => "",
|
||||
path => "/query/style_form/explode_true/object/allOf",
|
||||
|
||||
Reference in New Issue
Block a user