diff --git a/modules/openapi-generator/src/main/resources/erlang-server/api.mustache b/modules/openapi-generator/src/main/resources/erlang-server/api.mustache index 157e2b7a39ef..7726cc3e07df 100644 --- a/modules/openapi-generator/src/main/resources/erlang-server/api.mustache +++ b/modules/openapi-generator/src/main/resources/erlang-server/api.mustache @@ -179,7 +179,7 @@ populate_request_params(_, [], Req, _, Model) -> populate_request_params(OperationID, [ReqParamName | T], Req0, ValidatorState, Model0) -> case populate_request_param(OperationID, ReqParamName, Req0, ValidatorState) of {ok, V, Req} -> - Model = maps:put(ReqParamName, V, Model0), + Model = Model0#{ReqParamName => V}, populate_request_params(OperationID, T, Req, ValidatorState, Model); Error -> Error diff --git a/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache b/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache index f20db0f4f711..be706ca18ef4 100644 --- a/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache +++ b/modules/openapi-generator/src/main/resources/erlang-server/handler.mustache @@ -36,7 +36,7 @@ Exposes the following operation IDs: {operation_id :: operation_id(), accept_callback :: {{packageName}}_logic_handler:accept_callback(), provide_callback :: {{packageName}}_logic_handler:provide_callback(), - api_key_handler :: {{packageName}}_logic_handler:api_key_callback(), + api_key_callback :: {{packageName}}_logic_handler:api_key_callback(), context = #{} :: {{packageName}}_logic_handler:context()}). -type state() :: #state{}. @@ -52,7 +52,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> @@ -69,8 +69,8 @@ init(Req, {Operations, Module}) -> {{#authMethods.size}} is_authorized(Req0, #state{operation_id = '{{operationIdOriginal}}' = OperationID, - api_key_handler = Handler} = State) -> - case {{packageName}}_auth:authorize_api_key(Handler, OperationID, {{#isApiKey.isKeyInQuery}}qs_val, {{/isApiKey.isKeyInQuery}}{{^isApiKey.isKeyInQuery}}header, {{/isApiKey.isKeyInQuery}}{{#isApiKey}}"{{keyParamName}}", {{/isApiKey}}{{^isApiKey}}"authorization", {{/isApiKey}}Req0) of + api_key_callback = Handler} = State) -> + case {{packageName}}_auth:authorize_api_key(Handler, OperationID, {{#isApiKey.isKeyInQuery}}qs_val, {{/isApiKey.isKeyInQuery}}{{^isApiKey.isKeyInQuery}}header, {{/isApiKey.isKeyInQuery}}{{#isApiKey}}"{{keyParamName}}", {{/isApiKey}}{{^isApiKey}}<<"authorization">>, {{/isApiKey}}Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> diff --git a/modules/openapi-generator/src/main/resources/erlang-server/server.mustache b/modules/openapi-generator/src/main/resources/erlang-server/server.mustache index 86b4654a02a1..ec8789a5b34d 100644 --- a/modules/openapi-generator/src/main/resources/erlang-server/server.mustache +++ b/modules/openapi-generator/src/main/resources/erlang-server/server.mustache @@ -33,12 +33,12 @@ get_cowboy_config(LogicHandler, ExtraOpts) -> maps:fold(fun get_cowboy_config/3, DefaultOpts, ExtraOpts). get_cowboy_config(env, #{dispatch := _Dispatch} = Env, AccIn) -> - maps:put(env, Env, AccIn); + AccIn#{env => Env}; get_cowboy_config(env, NewEnv, #{env := OldEnv} = AccIn) -> Env = maps:merge(OldEnv, NewEnv), - maps:put(env, Env, AccIn); + AccIn#{env => Env}; get_cowboy_config(Key, Value, AccIn) -> - maps:put(Key, Value, AccIn). + AccIn#{Key => Value}. get_default_dispatch(LogicHandler) -> Paths = {{packageName}}_router:get_paths(LogicHandler), diff --git a/samples/server/echo_api/erlang-server/src/openapi_api.erl b/samples/server/echo_api/erlang-server/src/openapi_api.erl index f528518af8c5..3ff344a87066 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_api.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_api.erl @@ -686,7 +686,7 @@ populate_request_params(_, [], Req, _, Model) -> populate_request_params(OperationID, [ReqParamName | T], Req0, ValidatorState, Model0) -> case populate_request_param(OperationID, ReqParamName, Req0, ValidatorState) of {ok, V, Req} -> - Model = maps:put(ReqParamName, V, Model0), + Model = Model0#{ReqParamName => V}, populate_request_params(OperationID, T, Req, ValidatorState, Model); Error -> Error diff --git a/samples/server/echo_api/erlang-server/src/openapi_auth_handler.erl b/samples/server/echo_api/erlang-server/src/openapi_auth_handler.erl index 0e70c3490c85..4366a625181e 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_auth_handler.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_auth_handler.erl @@ -41,7 +41,7 @@ To test HTTP bearer authentication {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -57,7 +57,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> @@ -73,8 +73,8 @@ allowed_methods(Req, State) -> {true | {false, iodata()}, cowboy_req:req(), state()}. is_authorized(Req0, #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 + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -82,8 +82,8 @@ is_authorized(Req0, end; is_authorized(Req0, #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 + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> diff --git a/samples/server/echo_api/erlang-server/src/openapi_body_handler.erl b/samples/server/echo_api/erlang-server/src/openapi_body_handler.erl index 507d97bdf448..f5530a195a15 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_body_handler.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_body_handler.erl @@ -81,7 +81,7 @@ Test empty json (request body) {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -97,7 +97,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> diff --git a/samples/server/echo_api/erlang-server/src/openapi_form_handler.erl b/samples/server/echo_api/erlang-server/src/openapi_form_handler.erl index f3e03126345b..bcc90de5cdd8 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_form_handler.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_form_handler.erl @@ -46,7 +46,7 @@ Test form parameter(s) for oneOf schema {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -62,7 +62,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> diff --git a/samples/server/echo_api/erlang-server/src/openapi_header_handler.erl b/samples/server/echo_api/erlang-server/src/openapi_header_handler.erl index aab73009b0f1..0a6a929c02ea 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_header_handler.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_header_handler.erl @@ -36,7 +36,7 @@ Test header parameter(s) {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -52,7 +52,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> diff --git a/samples/server/echo_api/erlang-server/src/openapi_path_handler.erl b/samples/server/echo_api/erlang-server/src/openapi_path_handler.erl index 823e8dc9226e..2ab2c032b8f0 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_path_handler.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_path_handler.erl @@ -36,7 +36,7 @@ Test path parameter(s) {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -52,7 +52,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> diff --git a/samples/server/echo_api/erlang-server/src/openapi_query_handler.erl b/samples/server/echo_api/erlang-server/src/openapi_query_handler.erl index 253740c663d5..25811927d234 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_query_handler.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_query_handler.erl @@ -81,7 +81,7 @@ Test query parameter(s) {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -97,7 +97,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> diff --git a/samples/server/echo_api/erlang-server/src/openapi_server.erl b/samples/server/echo_api/erlang-server/src/openapi_server.erl index 7670f1df06f4..d68df327cac7 100644 --- a/samples/server/echo_api/erlang-server/src/openapi_server.erl +++ b/samples/server/echo_api/erlang-server/src/openapi_server.erl @@ -31,12 +31,12 @@ get_cowboy_config(LogicHandler, ExtraOpts) -> maps:fold(fun get_cowboy_config/3, DefaultOpts, ExtraOpts). get_cowboy_config(env, #{dispatch := _Dispatch} = Env, AccIn) -> - maps:put(env, Env, AccIn); + AccIn#{env => Env}; get_cowboy_config(env, NewEnv, #{env := OldEnv} = AccIn) -> Env = maps:merge(OldEnv, NewEnv), - maps:put(env, Env, AccIn); + AccIn#{env => Env}; get_cowboy_config(Key, Value, AccIn) -> - maps:put(Key, Value, AccIn). + AccIn#{Key => Value}. get_default_dispatch(LogicHandler) -> Paths = openapi_router:get_paths(LogicHandler), diff --git a/samples/server/petstore/erlang-server/src/openapi_api.erl b/samples/server/petstore/erlang-server/src/openapi_api.erl index f8922a379cf2..f384249228bb 100644 --- a/samples/server/petstore/erlang-server/src/openapi_api.erl +++ b/samples/server/petstore/erlang-server/src/openapi_api.erl @@ -525,7 +525,7 @@ populate_request_params(_, [], Req, _, Model) -> populate_request_params(OperationID, [ReqParamName | T], Req0, ValidatorState, Model0) -> case populate_request_param(OperationID, ReqParamName, Req0, ValidatorState) of {ok, V, Req} -> - Model = maps:put(ReqParamName, V, Model0), + Model = Model0#{ReqParamName => V}, populate_request_params(OperationID, T, Req, ValidatorState, Model); Error -> Error diff --git a/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl b/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl index 595319e056e7..5418ef5bfc9d 100644 --- a/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl +++ b/samples/server/petstore/erlang-server/src/openapi_pet_handler.erl @@ -71,7 +71,7 @@ uploads an image. {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -87,7 +87,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> @@ -115,8 +115,8 @@ allowed_methods(Req, State) -> {true | {false, iodata()}, cowboy_req:req(), state()}. is_authorized(Req0, #state{operation_id = 'addPet' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -124,8 +124,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'deletePet' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -133,8 +133,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'findPetsByStatus' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -142,8 +142,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'findPetsByTags' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -151,8 +151,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'getPetById' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -160,8 +160,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'updatePet' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -169,8 +169,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'updatePetWithForm' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -178,8 +178,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'uploadFile' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> diff --git a/samples/server/petstore/erlang-server/src/openapi_server.erl b/samples/server/petstore/erlang-server/src/openapi_server.erl index f3cd231b0d54..4bc8d7be0627 100644 --- a/samples/server/petstore/erlang-server/src/openapi_server.erl +++ b/samples/server/petstore/erlang-server/src/openapi_server.erl @@ -31,12 +31,12 @@ get_cowboy_config(LogicHandler, ExtraOpts) -> maps:fold(fun get_cowboy_config/3, DefaultOpts, ExtraOpts). get_cowboy_config(env, #{dispatch := _Dispatch} = Env, AccIn) -> - maps:put(env, Env, AccIn); + AccIn#{env => Env}; get_cowboy_config(env, NewEnv, #{env := OldEnv} = AccIn) -> Env = maps:merge(OldEnv, NewEnv), - maps:put(env, Env, AccIn); + AccIn#{env => Env}; get_cowboy_config(Key, Value, AccIn) -> - maps:put(Key, Value, AccIn). + AccIn#{Key => Value}. get_default_dispatch(LogicHandler) -> Paths = openapi_router:get_paths(LogicHandler), diff --git a/samples/server/petstore/erlang-server/src/openapi_store_handler.erl b/samples/server/petstore/erlang-server/src/openapi_store_handler.erl index c85b1acde557..6c65931f7b34 100644 --- a/samples/server/petstore/erlang-server/src/openapi_store_handler.erl +++ b/samples/server/petstore/erlang-server/src/openapi_store_handler.erl @@ -51,7 +51,7 @@ Place an order for a pet. {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -67,7 +67,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> @@ -87,8 +87,8 @@ allowed_methods(Req, State) -> {true | {false, iodata()}, cowboy_req:req(), state()}. is_authorized(Req0, #state{operation_id = 'getInventory' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> diff --git a/samples/server/petstore/erlang-server/src/openapi_user_handler.erl b/samples/server/petstore/erlang-server/src/openapi_user_handler.erl index 5da69dfec2ad..4327923bd518 100644 --- a/samples/server/petstore/erlang-server/src/openapi_user_handler.erl +++ b/samples/server/petstore/erlang-server/src/openapi_user_handler.erl @@ -71,7 +71,7 @@ This can only be done by the logged in user. {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(), + api_key_callback :: openapi_logic_handler:api_key_callback(), context = #{} :: openapi_logic_handler:context()}). -type state() :: #state{}. @@ -87,7 +87,7 @@ init(Req, {Operations, Module}) -> State = #state{operation_id = OperationID, accept_callback = fun Module:accept_callback/4, provide_callback = fun Module:provide_callback/4, - api_key_handler = fun Module:authorize_api_key/2}, + api_key_callback = fun Module:api_key_callback/2}, {cowboy_rest, Req, State}. -spec allowed_methods(cowboy_req:req(), state()) -> @@ -115,8 +115,8 @@ allowed_methods(Req, State) -> {true | {false, iodata()}, cowboy_req:req(), state()}. is_authorized(Req0, #state{operation_id = 'createUser' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -124,8 +124,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'createUsersWithArrayInput' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -133,8 +133,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'createUsersWithListInput' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -142,8 +142,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'deleteUser' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -151,8 +151,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'logoutUser' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} -> @@ -160,8 +160,8 @@ is_authorized(Req0, end; is_authorized(Req0, #state{operation_id = 'updateUser' = OperationID, - api_key_handler = Handler} = State) -> - case openapi_auth:authorize_api_key(Handler, OperationID, header, "authorization", Req0) of + api_key_callback = Handler} = State) -> + case openapi_auth:authorize_api_key(Handler, OperationID, header, <<"authorization">>, Req0) of {true, Context, Req} -> {true, Req, State#state{context = Context}}; {false, AuthHeader, Req} ->