Update Erlang client petstore (OAS2) (#147)

* update erlang client, add method to customize array model parameter name

* remvoe debug log
This commit is contained in:
William Cheng 2018-04-19 21:22:24 +08:00 committed by GitHub
parent c20352caab
commit 86f67c6665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 49 deletions

View File

@ -739,6 +739,16 @@ public class DefaultCodegen implements CodegenConfig {
return name; return name;
} }
/**
* Return the parameter name of array of model
*
* @param name name of the array model
* @return the sanitized parameter name
*/
public String toArrayModelParamName(String name) {
return toParamName(name);
}
/** /**
* Return the Enum name (e.g. StatusEnum given 'status') * Return the Enum name (e.g. StatusEnum given 'status')
* *
@ -4232,7 +4242,7 @@ public class DefaultCodegen implements CodegenConfig {
innerCp = innerCp.items; innerCp = innerCp.items;
} }
codegenParameter.baseName = mostInnerItem.complexType; codegenParameter.baseName = mostInnerItem.complexType;
codegenParameter.paramName = toParamName(mostInnerItem.complexType); codegenParameter.paramName = toArrayModelParamName(mostInnerItem.complexType);
codegenParameter.items = codegenProperty.items; codegenParameter.items = codegenProperty.items;
codegenParameter.dataType = getTypeDeclaration(arraySchema); codegenParameter.dataType = getTypeDeclaration(arraySchema);
codegenParameter.baseType = getSchemaType(arraySchema); codegenParameter.baseType = getSchemaType(arraySchema);

View File

@ -113,8 +113,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
type = typeMapping.get(schemaType); type = typeMapping.get(schemaType);
if (languageSpecificPrimitives.contains(type)) if (languageSpecificPrimitives.contains(type))
return (type); return (type);
} } else
else
type = getTypeDeclaration(toModelName(snakeCase(schemaType))); type = getTypeDeclaration(toModelName(snakeCase(schemaType)));
return type; return type;
} }
@ -125,15 +124,13 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} } else {
else {
setPackageName("swagger"); setPackageName("swagger");
} }
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) { if (additionalProperties.containsKey(CodegenConstants.PACKAGE_VERSION)) {
setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION)); setPackageVersion((String) additionalProperties.get(CodegenConstants.PACKAGE_VERSION));
} } else {
else {
setPackageVersion("1.0.0"); setPackageVersion("1.0.0");
} }
@ -177,8 +174,7 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
} }
@Override @Override
public String escapeReservedWord(String name) public String escapeReservedWord(String name) {
{
// Can't start with an underscore, as our fields need to start with an // Can't start with an underscore, as our fields need to start with an
// UppercaseLetter so that Go treats them as public/visible. // UppercaseLetter so that Go treats them as public/visible.
@ -222,6 +218,20 @@ public class ErlangClientCodegen extends DefaultCodegen implements CodegenConfig
return camelize(toVarName(name)); return camelize(toVarName(name));
} }
@Override
public String toArrayModelParamName(String name) {
if (name == null) {
LOGGER.warn("parameter name for array model is null. Default to 'array_model'.");
name = "array_model";
}
if (name.indexOf(":") > 0) {
name = name.substring(0, name.indexOf(":")) + "_array";
}
return toParamName(name);
}
@Override @Override
public String toModelName(String name) { public String toModelName(String name) {
return this.packageName + "_" + underscore(name.replaceAll("-", "_").replaceAll("\\.", "_")); return this.packageName + "_" + underscore(name.replaceAll("-", "_").replaceAll("\\.", "_"));

View File

@ -1 +1 @@
2.3.0 3.0.0-SNAPSHOT

View File

@ -12,12 +12,13 @@
-define(BASE_URL, "/v2"). -define(BASE_URL, "/v2").
%% @doc Add a new pet to the store %% @doc Add a new pet to the store
%%
-spec add_pet(ctx:ctx(), petstore_pet:petstore_pet()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec add_pet(ctx:ctx(), petstore_pet:petstore_pet()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
add_pet(Ctx, Body) -> add_pet(Ctx, PetstorePet) ->
add_pet(Ctx, Body, #{}). add_pet(Ctx, PetstorePet, #{}).
-spec add_pet(ctx:ctx(), petstore_pet:petstore_pet(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec add_pet(ctx:ctx(), petstore_pet:petstore_pet(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
add_pet(Ctx, Body, Optional) -> add_pet(Ctx, PetstorePet, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -25,13 +26,14 @@ add_pet(Ctx, Body, Optional) ->
Path = ["/pet"], Path = ["/pet"],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstorePet,
ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>, <<"application/xml">>]), ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>, <<"application/xml">>]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Deletes a pet %% @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()}. -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) ->
delete_pet(Ctx, PetId, #{}). delete_pet(Ctx, PetId, #{}).
@ -115,12 +117,13 @@ get_pet_by_id(Ctx, PetId, Optional) ->
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Update an existing pet %% @doc Update an existing pet
%%
-spec update_pet(ctx:ctx(), petstore_pet:petstore_pet()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec update_pet(ctx:ctx(), petstore_pet:petstore_pet()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
update_pet(Ctx, Body) -> update_pet(Ctx, PetstorePet) ->
update_pet(Ctx, Body, #{}). update_pet(Ctx, PetstorePet, #{}).
-spec update_pet(ctx:ctx(), petstore_pet:petstore_pet(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec update_pet(ctx:ctx(), petstore_pet:petstore_pet(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
update_pet(Ctx, Body, Optional) -> update_pet(Ctx, PetstorePet, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -128,13 +131,14 @@ update_pet(Ctx, Body, Optional) ->
Path = ["/pet"], Path = ["/pet"],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstorePet,
ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>, <<"application/xml">>]), ContentTypeHeader = petstore_utils:select_header_content_type([<<"application/json">>, <<"application/xml">>]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Updates a pet in the store with form data %% @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()}. -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) ->
update_pet_with_form(Ctx, PetId, #{}). update_pet_with_form(Ctx, PetId, #{}).
@ -155,6 +159,7 @@ update_pet_with_form(Ctx, PetId, Optional) ->
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc uploads an image %% @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()}. -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) ->
upload_file(Ctx, PetId, #{}). upload_file(Ctx, PetId, #{}).

View File

@ -71,12 +71,13 @@ get_order_by_id(Ctx, OrderId, Optional) ->
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Place an order for a pet %% @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()}. -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, Body) -> place_order(Ctx, PetstoreOrder) ->
place_order(Ctx, Body, #{}). place_order(Ctx, PetstoreOrder, #{}).
-spec place_order(ctx:ctx(), petstore_order:petstore_order(), maps:map()) -> {ok, petstore_order:petstore_order(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec place_order(ctx:ctx(), petstore_order:petstore_order(), maps:map()) -> {ok, petstore_order:petstore_order(), petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
place_order(Ctx, Body, Optional) -> place_order(Ctx, PetstoreOrder, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -84,7 +85,7 @@ place_order(Ctx, Body, Optional) ->
Path = ["/store/order"], Path = ["/store/order"],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstoreOrder,
ContentTypeHeader = petstore_utils:select_header_content_type([]), ContentTypeHeader = petstore_utils:select_header_content_type([]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),

View File

@ -14,11 +14,11 @@
%% @doc Create user %% @doc Create user
%% This can only be done by the logged in user. %% This can only be done by the logged in user.
-spec create_user(ctx:ctx(), petstore_user:petstore_user()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec create_user(ctx:ctx(), petstore_user:petstore_user()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
create_user(Ctx, Body) -> create_user(Ctx, PetstoreUser) ->
create_user(Ctx, Body, #{}). create_user(Ctx, PetstoreUser, #{}).
-spec create_user(ctx:ctx(), petstore_user:petstore_user(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec create_user(ctx:ctx(), petstore_user:petstore_user(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
create_user(Ctx, Body, Optional) -> create_user(Ctx, PetstoreUser, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -26,19 +26,20 @@ create_user(Ctx, Body, Optional) ->
Path = ["/user"], Path = ["/user"],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstoreUser,
ContentTypeHeader = petstore_utils:select_header_content_type([]), ContentTypeHeader = petstore_utils:select_header_content_type([]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Creates list of users with given input array %% @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()}. -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, Body) -> create_users_with_array_input(Ctx, PetstoreUserArray) ->
create_users_with_array_input(Ctx, Body, #{}). create_users_with_array_input(Ctx, PetstoreUserArray, #{}).
-spec create_users_with_array_input(ctx:ctx(), list(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec create_users_with_array_input(ctx:ctx(), list(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
create_users_with_array_input(Ctx, Body, Optional) -> create_users_with_array_input(Ctx, PetstoreUserArray, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -46,19 +47,20 @@ create_users_with_array_input(Ctx, Body, Optional) ->
Path = ["/user/createWithArray"], Path = ["/user/createWithArray"],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstoreUserArray,
ContentTypeHeader = petstore_utils:select_header_content_type([]), ContentTypeHeader = petstore_utils:select_header_content_type([]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Creates list of users with given input array %% @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()}. -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, Body) -> create_users_with_list_input(Ctx, PetstoreUserArray) ->
create_users_with_list_input(Ctx, Body, #{}). create_users_with_list_input(Ctx, PetstoreUserArray, #{}).
-spec create_users_with_list_input(ctx:ctx(), list(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec create_users_with_list_input(ctx:ctx(), list(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
create_users_with_list_input(Ctx, Body, Optional) -> create_users_with_list_input(Ctx, PetstoreUserArray, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -66,7 +68,7 @@ create_users_with_list_input(Ctx, Body, Optional) ->
Path = ["/user/createWithList"], Path = ["/user/createWithList"],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstoreUserArray,
ContentTypeHeader = petstore_utils:select_header_content_type([]), ContentTypeHeader = petstore_utils:select_header_content_type([]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),
@ -94,6 +96,7 @@ delete_user(Ctx, Username, Optional) ->
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Get user by user name %% @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()}. -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) ->
get_user_by_name(Ctx, Username, #{}). get_user_by_name(Ctx, Username, #{}).
@ -114,6 +117,7 @@ get_user_by_name(Ctx, Username, Optional) ->
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Logs user into the system %% @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()}. -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) ->
login_user(Ctx, Username, Password, #{}). login_user(Ctx, Username, Password, #{}).
@ -134,6 +138,7 @@ login_user(Ctx, Username, Password, Optional) ->
petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg). petstore_utils:request(Ctx, Method, [?BASE_URL, Path], QS, ContentTypeHeader++Headers, Body1, Opts, Cfg).
%% @doc Logs out current logged in user session %% @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()}. -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) ->
logout_user(Ctx, #{}). logout_user(Ctx, #{}).
@ -156,11 +161,11 @@ logout_user(Ctx, Optional) ->
%% @doc Updated user %% @doc Updated user
%% This can only be done by the logged in user. %% This can only be done by the logged in user.
-spec update_user(ctx:ctx(), binary(), petstore_user:petstore_user()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec update_user(ctx:ctx(), binary(), petstore_user:petstore_user()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
update_user(Ctx, Username, Body) -> update_user(Ctx, Username, PetstoreUser) ->
update_user(Ctx, Username, Body, #{}). update_user(Ctx, Username, PetstoreUser, #{}).
-spec update_user(ctx:ctx(), binary(), petstore_user:petstore_user(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}. -spec update_user(ctx:ctx(), binary(), petstore_user:petstore_user(), maps:map()) -> {ok, [], petstore_utils:response_info()} | {ok, hackney:client_ref()} | {error, term(), petstore_utils:response_info()}.
update_user(Ctx, Username, Body, Optional) -> update_user(Ctx, Username, PetstoreUser, Optional) ->
_OptionalParams = maps:get(params, Optional, #{}), _OptionalParams = maps:get(params, Optional, #{}),
Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})), Cfg = maps:get(cfg, Optional, application:get_env(kuberl, config, #{})),
@ -168,7 +173,7 @@ update_user(Ctx, Username, Body, Optional) ->
Path = ["/user/", Username, ""], Path = ["/user/", Username, ""],
QS = [], QS = [],
Headers = [], Headers = [],
Body1 = Body, Body1 = PetstoreUser,
ContentTypeHeader = petstore_utils:select_header_content_type([]), ContentTypeHeader = petstore_utils:select_header_content_type([]),
Opts = maps:get(hackney_opts, Optional, []), Opts = maps:get(hackney_opts, Optional, []),