Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
{{#apiInfo}}{{#apis}}
{{#operations}}{{#operation}}
request_params('{{operationId}}') ->
[{{#allParams}}{{^isBodyParam}}
'{{baseName}}'{{/isBodyParam}}{{#isBodyParam}}
'{{dataType}}'{{/isBodyParam}}{{#hasMore}},{{/hasMore}}{{/allParams}}
[{{#allParams}}{{#isNot this 'body-param'}}
'{{baseName}}'{{/isNot}}{{#is this 'body-param'}}
'{{dataType}}'{{/is}}{{#has this 'more'}},{{/has}}{{/allParams}}
];
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
request_params(_) ->
Expand Down Expand Up @@ -53,7 +53,7 @@ request_params(_) ->
{{#operations}}{{#operation}}{{#allParams}}
request_param_info('{{operationId}}', {{^isBodyParam}}'{{baseName}}'{{/isBodyParam}}{{#isBodyParam}}'{{dataType}}'{{/isBodyParam}}) ->
#{
source => {{#isQueryParam}}qs_val{{/isQueryParam}} {{#isPathParam}}binding{{/isPathParam}} {{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}},
source => {{#is this 'query-param'}}qs_val{{/is}} {{#isPathParam}}binding{{/isPathParam}} {{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}},
rules => [{{#isString}}
{type, 'binary'},{{/isString}}{{#isInteger}}
{type, 'integer'},{{/isInteger}}{{#isLong}}
Expand All @@ -65,7 +65,7 @@ request_param_info('{{operationId}}', {{^isBodyParam}}'{{baseName}}'{{/isBodyPar
{type, 'boolean'},{{/isBoolean}}{{#isDate}}
{type, 'date'},{{/isDate}}{{#isDateTime}}
{type, 'datetime'},{{/isDateTime}}{{#isEnum}}
{enum, [{{#allowableValues}}{{#values}}'{{.}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] },{{/isEnum}}{{#maximum}}
{enum, [{{#allowableValues}}{{#values}}'{{.}}'{{^@last}}, {{/@last}}{{/values}}{{/allowableValues}}] },{{/isEnum}}{{#maximum}}
{max, {{maximum}} }, {{/maximum}}{{#exclusiveMaximum}}
{exclusive_max, {{exclusiveMaximum}} },{{/exclusiveMaximum}}{{#minimum}}
{min, {{minimum}} },{{/minimum}}{{#exclusiveMinimum}}
Expand Down Expand Up @@ -261,7 +261,7 @@ validate(Rule = {pattern, Pattern}, Name, Value, _ValidatorState) ->
end;

validate(Rule = schema, Name, Value, ValidatorState) ->
Definition = list_to_binary("#/definitions/" ++ {{packageName}}_utils:to_list(Name)),
Definition = list_to_binary("#/components/schemas/" ++ {{packageName}}_utils:to_list(Name)),
try
_ = validate_with_schema(Value, Definition, ValidatorState),
ok
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{application, {{packageName}}, [
{description, {{#appDescription}}"{{appDescription}}"{{/appDescription}}{{^appDescription}}"Swagger rest server library"{{/appDescription}}},
{description, {{#appDescription}}"{{appDescription}}"{{/appDescription}}{{^appDescription}}"Swagger rest server library"{{/appDescription~}} },
{vsn, "{{apiVersion}}"},
{registered, []},
{applications, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ is_authorized(
),
case Result of
{true, Context, Req} -> {true, Req, State#state{context = Context}};
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
{false, AuthHeader, Req} -> { {false, AuthHeader}, Req, State}
end;
{{/isApiKey}}
{{/authMethods}}
Expand All @@ -101,7 +101,7 @@ is_authorized(Req, State) ->
{{/authMethods}}
{{#authMethods}}
is_authorized(Req, State) ->
{{false, <<"">>}, Req, State}.
{ {false, <<"">>}, Req, State}.
{{/authMethods}}

-spec content_types_accepted(Req :: cowboy_req:req(), State :: state()) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ get_operations() ->
path => "{{{basePathWithoutHost}}}{{{path}}}",
method => <<"{{httpMethod}}">>,
handler => '{{classname}}'
}{{#hasMore}},{{/hasMore}}{{/operation}}{{#hasMore}},{{/hasMore}}{{/operations}}{{/apis}}{{/apiInfo}}
}{{^@last}},{{/@last}}{{/operation}}{{^@last}},{{/@last}}{{/operations}}{{/apis}}{{/apiInfo}}
}.

prepare_validator() ->
Expand Down