forked from loafle/openapi-generator-original
update samples
This commit is contained in:
parent
43697d2cfb
commit
6d71db3d6d
@ -1 +1 @@
|
||||
5.3.0-SNAPSHOT
|
||||
6.5.0-SNAPSHOT
|
@ -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, #{}).
|
||||
@ -23,7 +22,7 @@ add_pet(Ctx, PetstorePet, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/pet">>],
|
||||
Path = ["/pet"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstorePet,
|
||||
@ -33,7 +32,6 @@ add_pet(Ctx, PetstorePet, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -44,7 +42,7 @@ delete_pet(Ctx, PetId, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = delete,
|
||||
Path = [<<"/pet/", PetId, "">>],
|
||||
Path = ["/pet/", PetId, ""],
|
||||
QS = [],
|
||||
Headers = []++petstore_utils:optional_params(['api_key'], _OptionalParams),
|
||||
Body1 = [],
|
||||
@ -65,7 +63,7 @@ find_pets_by_status(Ctx, Status, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/pet/findByStatus">>],
|
||||
Path = ["/pet/findByStatus"],
|
||||
QS = lists:flatten([[{<<"status">>, X} || X <- Status]])++petstore_utils:optional_params([], _OptionalParams),
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -86,7 +84,7 @@ find_pets_by_tags(Ctx, Tags, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/pet/findByTags">>],
|
||||
Path = ["/pet/findByTags"],
|
||||
QS = lists:flatten([[{<<"tags">>, X} || X <- Tags]])++petstore_utils:optional_params([], _OptionalParams),
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -107,7 +105,7 @@ get_pet_by_id(Ctx, PetId, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/pet/", PetId, "">>],
|
||||
Path = ["/pet/", PetId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -117,7 +115,6 @@ get_pet_by_id(Ctx, PetId, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -128,7 +125,7 @@ update_pet(Ctx, PetstorePet, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = put,
|
||||
Path = [<<"/pet">>],
|
||||
Path = ["/pet"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstorePet,
|
||||
@ -138,7 +135,6 @@ update_pet(Ctx, PetstorePet, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -149,7 +145,7 @@ update_pet_with_form(Ctx, PetId, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/pet/", PetId, "">>],
|
||||
Path = ["/pet/", PetId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = {form, []++petstore_utils:optional_params(['name', 'status'], _OptionalParams)},
|
||||
@ -159,7 +155,6 @@ update_pet_with_form(Ctx, PetId, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -170,7 +165,7 @@ upload_file(Ctx, PetId, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/pet/", PetId, "/uploadImage">>],
|
||||
Path = ["/pet/", PetId, "/uploadImage"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = {form, []++petstore_utils:optional_params(['additionalMetadata', 'file'], _OptionalParams)},
|
||||
|
@ -19,7 +19,7 @@ delete_order(Ctx, OrderId, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = delete,
|
||||
Path = [<<"/store/order/", OrderId, "">>],
|
||||
Path = ["/store/order/", OrderId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -40,7 +40,7 @@ get_inventory(Ctx, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/store/inventory">>],
|
||||
Path = ["/store/inventory"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -61,7 +61,7 @@ get_order_by_id(Ctx, OrderId, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/store/order/", OrderId, "">>],
|
||||
Path = ["/store/order/", OrderId, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -71,7 +71,6 @@ get_order_by_id(Ctx, OrderId, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -82,7 +81,7 @@ place_order(Ctx, PetstoreOrder, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/store/order">>],
|
||||
Path = ["/store/order"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstoreOrder,
|
||||
|
@ -23,7 +23,7 @@ create_user(Ctx, PetstoreUser, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/user">>],
|
||||
Path = ["/user"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstoreUser,
|
||||
@ -33,7 +33,6 @@ create_user(Ctx, PetstoreUser, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -44,7 +43,7 @@ create_users_with_array_input(Ctx, PetstoreUserArray, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/user/createWithArray">>],
|
||||
Path = ["/user/createWithArray"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstoreUserArray,
|
||||
@ -54,7 +53,6 @@ create_users_with_array_input(Ctx, PetstoreUserArray, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -65,7 +63,7 @@ create_users_with_list_input(Ctx, PetstoreUserArray, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = post,
|
||||
Path = [<<"/user/createWithList">>],
|
||||
Path = ["/user/createWithList"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstoreUserArray,
|
||||
@ -86,7 +84,7 @@ delete_user(Ctx, Username, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = delete,
|
||||
Path = [<<"/user/", Username, "">>],
|
||||
Path = ["/user/", Username, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -96,7 +94,6 @@ delete_user(Ctx, Username, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -107,7 +104,7 @@ get_user_by_name(Ctx, Username, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/user/", Username, "">>],
|
||||
Path = ["/user/", Username, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -117,7 +114,6 @@ get_user_by_name(Ctx, Username, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -128,7 +124,7 @@ login_user(Ctx, Username, Password, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/user/login">>],
|
||||
Path = ["/user/login"],
|
||||
QS = lists:flatten([{<<"username">>, Username}, {<<"password">>, Password}])++petstore_utils:optional_params([], _OptionalParams),
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -138,7 +134,6 @@ login_user(Ctx, Username, Password, Optional) ->
|
||||
petstore_utils:request(Ctx, Method, [?BASE_URL, 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, #{}).
|
||||
@ -149,7 +144,7 @@ logout_user(Ctx, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = get,
|
||||
Path = [<<"/user/logout">>],
|
||||
Path = ["/user/logout"],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = [],
|
||||
@ -170,7 +165,7 @@ update_user(Ctx, Username, PetstoreUser, Optional) ->
|
||||
Cfg = maps:get(cfg, Optional, application:get_env(petstore_api, config, #{})),
|
||||
|
||||
Method = put,
|
||||
Path = [<<"/user/", Username, "">>],
|
||||
Path = ["/user/", Username, ""],
|
||||
QS = [],
|
||||
Headers = [],
|
||||
Body1 = PetstoreUser,
|
||||
|
@ -72,12 +72,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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user