From 38d9dc1f36bf5b1f1d5ccd1ee1e25ebdab68ada3 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Wed, 22 Mar 2023 00:26:36 +0800 Subject: [PATCH] update erlang samples --- .../petstore/erlang-client/.openapi-generator/VERSION | 2 +- .../petstore/erlang-client/src/petstore_pet_api.erl | 5 ----- .../petstore/erlang-client/src/petstore_store_api.erl | 1 - .../petstore/erlang-client/src/petstore_user_api.erl | 5 ----- .../client/petstore/erlang-client/src/petstore_utils.erl | 8 ++++---- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/samples/client/petstore/erlang-client/.openapi-generator/VERSION b/samples/client/petstore/erlang-client/.openapi-generator/VERSION index 4b448de535c..7f4d792ec2c 100644 --- a/samples/client/petstore/erlang-client/.openapi-generator/VERSION +++ b/samples/client/petstore/erlang-client/.openapi-generator/VERSION @@ -1 +1 @@ -5.3.0-SNAPSHOT \ No newline at end of file +6.5.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/erlang-client/src/petstore_pet_api.erl b/samples/client/petstore/erlang-client/src/petstore_pet_api.erl index e406257a76e..7466253bb67 100644 --- a/samples/client/petstore/erlang-client/src/petstore_pet_api.erl +++ b/samples/client/petstore/erlang-client/src/petstore_pet_api.erl @@ -12,7 +12,6 @@ -define(BASE_URL, <<"/v2">>). %% @doc Add a new pet to the store -%% -spec add_pet(ctx:ctx(), petstore_pet:petstore_pet()) -> {ok, petstore_pet:petstore_pet(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. add_pet(Ctx, PetstorePet) -> add_pet(Ctx, PetstorePet, #{}). @@ -33,7 +32,6 @@ add_pet(Ctx, PetstorePet, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Deletes a pet -%% -spec delete_pet(ctx:ctx(), integer()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. delete_pet(Ctx, PetId) -> delete_pet(Ctx, PetId, #{}). @@ -117,7 +115,6 @@ get_pet_by_id(Ctx, PetId, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Update an existing pet -%% -spec update_pet(ctx:ctx(), petstore_pet:petstore_pet()) -> {ok, petstore_pet:petstore_pet(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. update_pet(Ctx, PetstorePet) -> update_pet(Ctx, PetstorePet, #{}). @@ -138,7 +135,6 @@ update_pet(Ctx, PetstorePet, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Updates a pet in the store with form data -%% -spec update_pet_with_form(ctx:ctx(), integer()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. update_pet_with_form(Ctx, PetId) -> update_pet_with_form(Ctx, PetId, #{}). @@ -159,7 +155,6 @@ update_pet_with_form(Ctx, PetId, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc uploads an image -%% -spec upload_file(ctx:ctx(), integer()) -> {ok, petstore_api_response:petstore_api_response(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. upload_file(Ctx, PetId) -> upload_file(Ctx, PetId, #{}). diff --git a/samples/client/petstore/erlang-client/src/petstore_store_api.erl b/samples/client/petstore/erlang-client/src/petstore_store_api.erl index bc45dce6a7d..6000a98469b 100644 --- a/samples/client/petstore/erlang-client/src/petstore_store_api.erl +++ b/samples/client/petstore/erlang-client/src/petstore_store_api.erl @@ -71,7 +71,6 @@ get_order_by_id(Ctx, OrderId, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Place an order for a pet -%% -spec place_order(ctx:ctx(), petstore_order:petstore_order()) -> {ok, petstore_order:petstore_order(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. place_order(Ctx, PetstoreOrder) -> place_order(Ctx, PetstoreOrder, #{}). diff --git a/samples/client/petstore/erlang-client/src/petstore_user_api.erl b/samples/client/petstore/erlang-client/src/petstore_user_api.erl index 14c52af676f..b1fea505c62 100644 --- a/samples/client/petstore/erlang-client/src/petstore_user_api.erl +++ b/samples/client/petstore/erlang-client/src/petstore_user_api.erl @@ -33,7 +33,6 @@ create_user(Ctx, PetstoreUser, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Creates list of users with given input array -%% -spec create_users_with_array_input(ctx:ctx(), list()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. create_users_with_array_input(Ctx, PetstoreUserArray) -> create_users_with_array_input(Ctx, PetstoreUserArray, #{}). @@ -54,7 +53,6 @@ create_users_with_array_input(Ctx, PetstoreUserArray, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Creates list of users with given input array -%% -spec create_users_with_list_input(ctx:ctx(), list()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. create_users_with_list_input(Ctx, PetstoreUserArray) -> create_users_with_list_input(Ctx, PetstoreUserArray, #{}). @@ -96,7 +94,6 @@ delete_user(Ctx, Username, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Get user by user name -%% -spec get_user_by_name(ctx:ctx(), binary()) -> {ok, petstore_user:petstore_user(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. get_user_by_name(Ctx, Username) -> get_user_by_name(Ctx, Username, #{}). @@ -117,7 +114,6 @@ get_user_by_name(Ctx, Username, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Logs user into the system -%% -spec login_user(ctx:ctx(), binary(), binary()) -> {ok, binary(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. login_user(Ctx, Username, Password) -> login_user(Ctx, Username, Password, #{}). @@ -138,7 +134,6 @@ login_user(Ctx, Username, Password, Optional) -> petstore_utils:request(Ctx, Method, Path, QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). %% @doc Logs out current logged in user session -%% -spec logout_user(ctx:ctx()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. logout_user(Ctx) -> logout_user(Ctx, #{}). diff --git a/samples/client/petstore/erlang-client/src/petstore_utils.erl b/samples/client/petstore/erlang-client/src/petstore_utils.erl index e2d843841f9..ec44cf3068b 100644 --- a/samples/client/petstore/erlang-client/src/petstore_utils.erl +++ b/samples/client/petstore/erlang-client/src/petstore_utils.erl @@ -81,12 +81,12 @@ auth_with_prefix(Cfg, Key, Token) -> update_params_with_auth(Cfg, Headers, QS) -> AuthSettings = maps:get(auth, Cfg, #{}), - Auths = #{ 'api_key' => - #{type => 'apiKey', - key => <<"api_key">>, - in => header}, 'petstore_auth' => + Auths = #{ 'petstore_auth' => #{type => 'oauth2', key => <<"Authorization">>, + in => header}, 'api_key' => + #{type => 'apiKey', + key => <<"api_key">>, in => header}}, maps:fold(fun(AuthName, #{type := _Type,