forked from loafle/openapi-generator-original
Update Erlang server samples with Petstore OAS2 (#150)
* update erlang server samples with petstore oas2 * fix compilation in erlang server
This commit is contained in:
parent
e1a0355398
commit
df26bcb40c
4
.gitignore
vendored
4
.gitignore
vendored
@ -191,3 +191,7 @@ samples/client/petstore/elixir/mix.lock
|
||||
|
||||
# groovy
|
||||
samples/client/petstore/groovy/build
|
||||
|
||||
# erlang
|
||||
samples/server/petstore/erlang-server/_build/
|
||||
samples/server/petstore/erlang-server/rebar.lock
|
||||
|
@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/erlang-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l erlang-server -o samples/server/petstore/erlang-server"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/erlang-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l erlang-server -o samples/server/petstore/erlang-server $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
@ -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 => {{#isQueryParam}}qs_val{{/isQueryParam}} {{#isPathParam}}binding{{/isPathParam}} {{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}{{#isFormParam}}body{{/isFormParam}},
|
||||
rules => [{{#isString}}
|
||||
{type, 'binary'},{{/isString}}{{#isInteger}}
|
||||
{type, 'integer'},{{/isInteger}}{{#isLong}}
|
||||
|
@ -70,7 +70,8 @@ allowed_methods(Req, State) ->
|
||||
Req :: cowboy_req:req(),
|
||||
State :: state()
|
||||
}.
|
||||
{{#operations}}{{#operation}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
{{#authMethods}}
|
||||
is_authorized(
|
||||
Req0,
|
||||
@ -93,8 +94,23 @@ is_authorized(
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
From = header,
|
||||
Result = {{packageName}}_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/operation}}{{/operations}}
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{^authMethods}}
|
||||
is_authorized(Req, State) ->
|
||||
{true, Req, State}.
|
||||
|
@ -1 +1 @@
|
||||
2.2.3-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
1014
samples/server/petstore/erlang-server/priv/openapi.json
Normal file
1014
samples/server/petstore/erlang-server/priv/openapi.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -225,7 +225,7 @@ request_param_info('UpdatePetWithForm', 'petId') ->
|
||||
|
||||
request_param_info('UpdatePetWithForm', 'name') ->
|
||||
#{
|
||||
source => ,
|
||||
source => body,
|
||||
rules => [
|
||||
{type, 'binary'},
|
||||
not_required
|
||||
@ -234,7 +234,7 @@ request_param_info('UpdatePetWithForm', 'name') ->
|
||||
|
||||
request_param_info('UpdatePetWithForm', 'status') ->
|
||||
#{
|
||||
source => ,
|
||||
source => body,
|
||||
rules => [
|
||||
{type, 'binary'},
|
||||
not_required
|
||||
@ -252,7 +252,7 @@ request_param_info('UploadFile', 'petId') ->
|
||||
|
||||
request_param_info('UploadFile', 'additionalMetadata') ->
|
||||
#{
|
||||
source => ,
|
||||
source => body,
|
||||
rules => [
|
||||
{type, 'binary'},
|
||||
not_required
|
||||
@ -261,8 +261,9 @@ request_param_info('UploadFile', 'additionalMetadata') ->
|
||||
|
||||
request_param_info('UploadFile', 'file') ->
|
||||
#{
|
||||
source => ,
|
||||
source => body,
|
||||
rules => [
|
||||
{type, 'binary'},
|
||||
not_required
|
||||
]
|
||||
};
|
||||
|
@ -126,7 +126,6 @@ allowed_methods(Req, State) ->
|
||||
Req :: cowboy_req:req(),
|
||||
State :: state()
|
||||
}.
|
||||
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -134,7 +133,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -142,7 +152,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -150,7 +171,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -158,7 +190,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -178,7 +221,6 @@ is_authorized(
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -186,7 +228,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -194,7 +247,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -202,7 +266,18 @@ is_authorized(
|
||||
logic_handler = LogicHandler
|
||||
}
|
||||
) ->
|
||||
|
||||
From = header,
|
||||
Result = swagger_auth:authorize_api_key(
|
||||
LogicHandler,
|
||||
OperationID,
|
||||
From,
|
||||
"Authorization",
|
||||
Req0
|
||||
),
|
||||
case Result of
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
is_authorized(Req, State) ->
|
||||
{true, Req, State}.
|
||||
|
||||
|
@ -164,6 +164,6 @@ prepare_validator() ->
|
||||
|
||||
get_swagger_path() ->
|
||||
{ok, AppName} = application:get_application(?MODULE),
|
||||
filename:join(swagger_utils:priv_dir(AppName), "swagger.json").
|
||||
filename:join(swagger_utils:priv_dir(AppName), "openapi.json").
|
||||
|
||||
|
||||
|
@ -94,8 +94,6 @@ allowed_methods(Req, State) ->
|
||||
Req :: cowboy_req:req(),
|
||||
State :: state()
|
||||
}.
|
||||
|
||||
|
||||
is_authorized(
|
||||
Req0,
|
||||
State = #state{
|
||||
@ -115,9 +113,6 @@ is_authorized(
|
||||
{true, Context, Req} -> {true, Req, State#state{context = Context}};
|
||||
{false, AuthHeader, Req} -> {{false, AuthHeader}, Req, State}
|
||||
end;
|
||||
|
||||
|
||||
|
||||
is_authorized(Req, State) ->
|
||||
{true, Req, State}.
|
||||
|
||||
|
@ -126,15 +126,6 @@ allowed_methods(Req, State) ->
|
||||
Req :: cowboy_req:req(),
|
||||
State :: state()
|
||||
}.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
is_authorized(Req, State) ->
|
||||
{true, Req, State}.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user