diff --git a/modules/openapi-generator/src/main/resources/elixir/README.md.mustache b/modules/openapi-generator/src/main/resources/elixir/README.md.mustache index a7b8e8d6a1..11d51400e8 100644 --- a/modules/openapi-generator/src/main/resources/elixir/README.md.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/README.md.mustache @@ -2,33 +2,46 @@ {{appDescription}} -### Building +## Building To install the required dependencies and to build the elixir project, run: -``` + +```console mix local.hex --force mix do deps.get, compile ``` ## Installation -If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `{{#underscored}}{{packageName}}{{/underscored}}` to your list of dependencies in `mix.exs`: +If [available in Hex][], the package can be installed by adding `{{#underscored}}{{packageName}}{{/underscored}}` to +your list of dependencies in `mix.exs`: ```elixir -def deps do - [{:{{#underscored}}{{packageName}}{{/underscored}}, "~> 0.1.0"}] -end +{{=<% %>=}}def deps do + [{<%#atom%><%#underscored%><%packageName%><%/underscored%><%/atom%>, "~> <%appVersion%>"}] +end<%={{ }}=%> ``` -Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) -and published on [HexDocs](https://hexdocs.pm). Once published, the docs can -be found at [https://hexdocs.pm/{{#underscored}}{{packageName}}{{/underscored}}](https://hexdocs.pm/{{#underscored}}{{packageName}}{{/underscored}}). - +Documentation can be generated with [ExDoc][] and published on [HexDocs][]. Once published, the docs can be found at +[https://hexdocs.pm/{{#underscored}}{{packageName}}{{/underscored}}][docs]. ## Configuration -You can override the URL of your server (e.g. if you have a separate development and production server in your configuration files. +You can override the URL of your server (e.g. if you have a separate development and production server in your +configuration files). + ```elixir -config :{{#underscored}}{{appName}}{{/underscored}}, base_url: "{{{basePath}}}" -``` \ No newline at end of file +config :{{#underscored}}{{packageName}}{{/underscored}}, base_url: "{{{basePath}}}" +``` + +Multiple clients for the same API with different URLs can be created passing different `base_url`s when calling +`{{moduleName}}.Connection.new/1`: + +```elixir +client = {{moduleName}}.Connection.new(base_url: "{{{basePath}}}") +``` + +[exdoc]: https://github.com/elixir-lang/ex_doc +[hexdocs]: https://hexdocs.pm +[available in hex]: https://hex.pm/docs/publish +[docs]: https://hexdocs.pm/{{#underscored}}{{packageName}}{{/underscored}} diff --git a/modules/openapi-generator/src/main/resources/elixir/api.mustache b/modules/openapi-generator/src/main/resources/elixir/api.mustache index 6d5e0d44fa..b2c368ba24 100644 --- a/modules/openapi-generator/src/main/resources/elixir/api.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/api.mustache @@ -6,9 +6,8 @@ defmodule {{moduleName}}.Api.{{classname}} do alias {{moduleName}}.Connection import {{moduleName}}.RequestBuilder - {{#operations}} - {{#operation}} +{{#operation}} @doc """ {{#summary}} @@ -18,25 +17,26 @@ defmodule {{moduleName}}.Api.{{classname}} do {{¬es}} {{/notes}} - ## Parameters + ### Parameters - - connection ({{&moduleName}}.Connection): Connection to server + - `connection` ({{&moduleName}}.Connection): Connection to server {{#requiredParams}} - - {{#underscored}}{{¶mName}}{{/underscored}} ({{&dataType}}): {{&description}} + - `{{#underscored}}{{¶mName}}{{/underscored}}` ({{&dataType}}): {{&description}} {{/requiredParams}} - - opts (KeywordList): [optional] Optional parameters + - `opts` (keyword): Optional parameters {{#optionalParams}} {{#isBodyParam}} - - :body ({{dataType}}): {{&description}} + - `:body` ({{dataType}}): {{&description}} {{/isBodyParam}} {{^isBodyParam}} - - {{#underscored}}:{{¶mName}}{{/underscored}} ({{&dataType}}): {{&description}} + - `{{#atom}}{{#underscored}}{{¶mName}}{{/underscored}}{{/atom}}` ({{&dataType}}): {{&description}} {{/isBodyParam}} {{/optionalParams}} - ## Returns - {:ok, {{#isArray}}[%{{&returnBaseType}}{}, ...]{{/isArray}}{{#isMap}}%{}{{/isMap}}{{^returnType}}nil{{/returnType}}{{#returnSimpleType}}{{#returnType}}{{{.}}}{{/returnType}}{{/returnSimpleType}}} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, {{#isArray}}[%{{&returnBaseType}}{}, ...]{{/isArray}}{{#isMap}}%{}{{/isMap}}{{^returnType}}nil{{/returnType}}{{#returnSimpleType}}{{#returnType}}{{{.}}}{{/returnType}}{{/returnSimpleType}}}` on success + - `{:error, Tesla.Env.t}` on failure """ {{{typespec}}} def {{{operationId}}}(connection, {{#requiredParams}}{{#underscored}}{{{paramName}}}{{/underscored}}, {{/requiredParams}}{{^hasOptionalParams}}_{{/hasOptionalParams}}opts \\ []) do @@ -52,29 +52,33 @@ defmodule {{moduleName}}.Api.{{classname}} do {{/isBodyParam}} {{#-last}} } + {{/-last}} {{/optionalParams}} - %{} - |> method(:{{#underscored}}{{httpMethod}}{{/underscored}}) - |> url("{{replacedPathName}}") + request = + %{} + |> method({{#atom}}{{#underscored}}{{httpMethod}}{{/underscored}}{{/atom}}) + |> url("{{replacedPathName}}") {{#requiredParams}} {{^isPathParam}} - |> add_param({{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}{{#isMultipart}}{{#isFile}}:file{{/isFile}}{{^isFile}}:form{{/isFile}}{{/isMultipart}}{{^isMultipart}}:form{{/isMultipart}}{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}, {{#isBodyParam}}:body, {{/isBodyParam}}{{^isBodyParam}}{{#atom}}{{baseName}}{{/atom}}, {{/isBodyParam}}{{#underscored}}{{paramName}}{{/underscored}}) + |> add_param({{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}{{#isMultipart}}{{#isFile}}:file{{/isFile}}{{^isFile}}:form{{/isFile}}{{/isMultipart}}{{^isMultipart}}:form{{/isMultipart}}{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}, {{#isBodyParam}}:body{{/isBodyParam}}{{^isBodyParam}}{{#atom}}{{baseName}}{{/atom}}{{/isBodyParam}}, {{#underscored}}{{paramName}}{{/underscored}}) {{/isPathParam}} {{/requiredParams}} {{#optionalParams}} {{#-first}} - |> add_optional_params(optional_params, opts) + |> add_optional_params(optional_params, opts) {{/-first}} {{/optionalParams}} {{#requiresHttpcWorkaround}} - |> ensure_body() + |> ensure_body() {{/requiresHttpcWorkaround}} - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response({{#responses}}{{#-first}}[ {{/-first}} - { {{& codeMappingKey}}, {{decodedStruct}}}{{^-last}},{{/-last}} + {{=<% %>=}}{<%& codeMappingKey%>, <%decodedStruct%>}<%={{ }}=%>{{^-last}},{{/-last}} {{#-last}} ]{{/-last}}{{/responses}}) end {{/operation}} diff --git a/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache b/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache index 05fd56545d..3f4b326a26 100644 --- a/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/config.exs.mustache @@ -7,7 +7,7 @@ # General application configuration import Config -config :{{#underscored}}{{appName}}{{/underscored}}, base_url: "{{{basePath}}}" +config {{#atom}}{{#underscored}}{{packageName}}{{/underscored}}{{/atom}}, base_url: "{{{basePath}}}" # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache index 60ec9e3e25..15f29d734c 100644 --- a/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache @@ -2,91 +2,306 @@ defmodule {{moduleName}}.Connection do @moduledoc """ Handle Tesla connections for {{moduleName}}. + + Additional middleware can be set in the compile-time or runtime configuration: + + config :tesla, {{moduleName}}.Connection, + base_url: "{{{basePath}}}", + adapter: Tesla.Adapter.Hackney + + The default base URL can also be set as: + + config {{#atom}}{{#underscored}}{{packageName}}{{/underscored}}{{/atom}}, + :base_url, "{{{basePath}}}" """ - use Tesla + @default_base_url Application.compile_env( + {{#atom}}{{#underscored}}{{packageName}}{{/underscored}}{{/atom}}, + :base_url, + "{{{basePath}}}" + ) - # Add any middleware here (authentication) - plug Tesla.Middleware.BaseUrl, Application.get_env(:{{#underscored}}{{appName}}{{/underscored}}, :base_url, "{{{basePath}}}") - plug Tesla.Middleware.Headers, [{"user-agent", "Elixir"}] - plug Tesla.Middleware.EncodeJson, engine: Poison - - {{#hasAuthMethods}} - {{#authMethods}} - {{#isOAuth}} - @scopes [ + {{#hasOAuthMethods}} + {{#oauthMethods}} + @default_scopes [ {{#scopes}} - "{{scope}}"{{^-last}},{{/-last}} {{#description}}# {{.}}{{/description}} + {{#description}}# {{.}}{{/description}} + "{{scope}}"{{^-last}},{{/-last}} {{/scopes}} ] + {{/oauthMethods}} + + @typedoc """ + An arity-1 function or module/function tuple specification which, given + a list of scopes, obtains an OAuth2 token. + """ + @type token_fetcher :: (scopes :: list(String.t()) -> String.t()) | {module(), atom()} + {{/hasOAuthMethods}} + + @typedoc """ + The list of options that can be passed to new/1. + + - `base_url`: Overrides the base URL on a per-client basis. + - `user_agent`: Overrides the User-Agent header. + {{#hasOAuthMethods}} + - `token`: An OAuth2 token or a token fetcher function. + - `token_scopes`: A list of OAuth2 scope strings for use with a token + fetcher function. + {{/hasOAuthMethods}} + {{#hasHttpBasicMethods}} + - `username`: A username for basic authentication. + - `password`: A password for basic authentication. + {{/hasHttpBasicMethods}} + """ + @type options :: [ + {:base_url, String.t()}, + {:user_agent, String.t()}, + {{#hasOAuthMethods}} + {:token, String.t() | token_fetcher}, + {:token_scopes, list(String.t())}, + {{/hasOAuthMethods}} + {{#hasHttpBasicMethods}} + {:username, String.t() | nil}, + {:password, String.t() | nil}, + {{/hasHttpBasicMethods}} + ] + + @doc "Forward requests to Tesla." + @spec request(Tesla.Client.t(), [Tesla.option()]) :: Tesla.Env.result() + defdelegate request(client, options), to: Tesla @doc """ - Configure a client connection using a provided OAuth2 token as a Bearer token + Configure a client with no authentication. - ## Parameters - - - token (String): Bearer token - - ## Returns + ### Returns Tesla.Env.client """ - @spec new(String.t) :: Tesla.Env.client - def new(token) when is_binary(token) do - Tesla.client([ - {Tesla.Middleware.Headers, [{"authorization", "Bearer #{token}"}]} - ]) - end - - @doc """ - Configure a client connection using a function which yields a Bearer token. - - ## Parameters - - - token_fetcher (function arity of 1): Callback which provides an OAuth2 token - given a list of scopes - - ## Returns - - Tesla.Env.client - """ - @spec new(((list(String.t)) -> String.t)) :: Tesla.Env.client - def new(token_fetcher) when is_function(token_fetcher) do - token_fetcher.(@scopes) - |> new - end - {{/isOAuth}} - {{#isBasic}} - @doc """ - Configure a client connection using Basic authentication. - - ## Parameters - - - username (String): Username used for authentication - - password (String): Password used for authentication - - # Returns - - Tesla.Env.client - """ - @spec new(String.t, String.t) :: Tesla.Env.client - def new(username, password) do - Tesla.client([ - {Tesla.Middleware.BasicAuth, %{username: username, password: password}} - ]) - end - {{/isBasic}} - {{/authMethods}} - {{/hasAuthMethods}} - @doc """ - Configure an authless client connection - - # Returns - - Tesla.Env.client - """ - @spec new() :: Tesla.Env.client + @spec new() :: Tesla.Env.client() def new do - Tesla.client([]) + Tesla.client(middleware(), adapter()) + end + + @doc """ + Configure a client that may have authentication. + + ### Parameters + + {{#hasOAuthMethods}} + The first parameter *may* be a `token` (a string, a token fetcher class, + or a module/function tuple) or a keyword list of `options`. They are + documented separately, but only *one* of them will be passed. + + - `token`: a String or a function of arity one. This value, or the result + of the function call, will be set as a bearer token in the + `authorization` header. + {{/hasOAuthMethods}} + - `options`: a keyword list of OpenAPIPetstore.Connection.options. + + ### Returns + + Tesla.Env.client + """ + {{#hasOAuthMethods}} + @spec new(String.t() | token_fetcher | options) :: Tesla.Env.client() + {{/hasOAuthMethods}} + {{^hasOAuthMethods}} + @spec new(options) :: Tesla.Env.client() + {{/hasOAuthMethods}} + {{#hasOAuthMethods}} + def new(token) when is_binary(token) or is_function(token, 1) or is_tuple(token) do + new(token: token) + end + {{/hasOAuthMethods}} + + def new(options) when is_list(options) do + options + |> middleware() + |> Tesla.client(adapter()) + end + + {{#hasOAuthMethods}} + {{#hasHttpBasicMethods}} + @doc """ + Configure a client using bearer authentication with scopes, or with + username and password for basic authentication. + + ### Parameters + + - `token_or_username`: a String representing a bearer token or a username, + depending on the type of the next parameter, or a function arity one + that returns a bearer token. + - `scopes_or_password`: a list of Strings represenging OAuth2 scopes, or + a single string that is the password for the username provided. + - `options`: a keyword list of OpenAPIPetstore.Connection.options. + + ### Returns + + Tesla.Env.client + """ + @spec new( + token_or_username :: String.t() | token_fetcher, + scopes_or_password :: list(String.t()) | String.t(), + options + ) :: Tesla.Env.client() + {{/hasHttpBasicMethods}} + {{^hasHttpBasicMethods}} + @doc """ + Configure a client using bearer authentication with scopes. + + ### Parameters + + - `token`: a String or a function of arity one. This value, or the result + of the function call, will be set as a bearer token in the + `authorization` header. + - `scopes`: a list of Strings represenging OAuth2 scopes. + - `options`: a keyword list of OpenAPIPetstore.Connection.options. + + ### Returns + + Tesla.Env.client + """ + @spec new(String.t() | token_fetcher, list(String.t()), options) :: Tesla.Env.client() + {{/hasHttpBasicMethods}} + {{/hasOAuthMethods}} + {{^hasOAuthMethods}} + {{#hasHttpBasicMethods}} + @doc """ + Configure a client using username and password for basic authentication. + + ### Parameters + + - `username`: a String representing a username. + - `password`: a String representing a password. + - `options`: a keyword list of {{moduleName}}.Connection.options. + + ### Returns + + Tesla.Env.client + """ + @spec new(String.t(), String.t()), options) :: Tesla.Env.client() + {{/hasHttpBasicMethods}} + {{/hasOAuthMethods}} + + {{#hasOAuthMethods}} + def new(token_or_username, scopes_or_password, options \\ []) + + def new(token, scopes, options) + when (is_binary(token) or is_function(token, 1) or is_tuple(token)) and is_list(scopes) do + options + |> Keyword.merge(token: token, token_scopes: scopes) + |> new() + end + {{/hasOAuthMethods}} + + {{#hasHttpBasicMethods}} + def new(username, password, options) when is_binary(username) and is_binary(password) do + options + |> Keyword.merge(username: username, password: password) + |> new() + end + {{/hasHttpBasicMethods}} + + @doc """ + Returns fully configured middleware for passing to Tesla.client/2. + """ + @spec middleware(options) :: [Tesla.Client.middleware()] + def middleware(options \\ []) do + base_url = + Keyword.get( + options, + :base_url, + Application.get_env({{#atom}}{{#underscored}}{{packageName}}{{/underscored}}{{/atom}}, :base_url, @default_base_url) + ) + + tesla_options = Application.get_env(:tesla, __MODULE__, []) + middleware = Keyword.get(tesla_options, :middleware, []) + json_engine = Keyword.get(tesla_options, :json, Poison) + + user_agent = + Keyword.get( + options, + :user_agent, + Keyword.get( + tesla_options, + :user_agent, + "openapi-generator - {{moduleName}} {{appVersion}} - elixir" + ) + ) + + {{#hasHttpBasicMethods}} + username = Keyword.get(options, :username) + password = Keyword.get(options, :password) + middleware = + if username || password do + [{Tesla.Middleware.BasicAuth, %{username: username, password: password}} | middleware] + else + middleware + end + {{/hasHttpBasicMethods}} + + {{#hasOAuthMethods}} + middleware = + if token = Keyword.get(options, :token) do + scopes = Keyword.get(options, :token_scopes, @default_scopes) + [authorization(token, scopes) | middleware] + else + middleware + end + {{/hasOAuthMethods}} + + [ + {Tesla.Middleware.BaseUrl, base_url}, + {Tesla.Middleware.Headers, [{"user-agent", user_agent}]}, + {Tesla.Middleware.EncodeJson, engine: json_engine} + | middleware + ] + end + + {{#hasOAuthMethods}} + @doc """ + Returns an authentication middleware tuple for a Tesla client that sets + the `authorization` header to the value of the provided bearer token. If + the token is provided as a function of arity one, it will be called with + a list of requested scopes that will obtain an OAuth2 token. + + ### Parameters + + - `token`: a String or a function of arity one. This value, or the result + of the function call, will be set as a bearer token in the + `authorization` header. + + - `scopes`: an optional list of scopes for use with the token fetcher + function. Ignored when `token` is provided as a String. Defaults to + `#{inspect(@default_scopes)}`. + + ### Returns + + `{Tesla.Middleware.Headers, [{"authorization", TOKEN}]}` + """ + @spec authorization(String.t() | token_fetcher, list(String.t())) :: + Tesla.Client.middleware() + def authorization(token, scopes \\ @default_scopes) + + def authorization(token, _scopes) when is_binary(token) do + {Tesla.Middlware.Headers, ["authorization", token]} + end + + def authorization({module, function}, scopes) when is_atom(module) and is_atom(function) do + apply(module, function, [scopes]) + end + + def authorization(token_fetcher, scopes) when is_function(token_fetcher, 1) do + authorization(token_fetcher.(scopes)) + end + {{/hasOAuthMethods}} + + @doc """ + Returns the default adapter for this API. + """ + def adapter do + :tesla + |> Application.get_env(__MODULE__, []) + |> Keyword.get(:adapter, nil) end end diff --git a/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache index ada1cf1346..91e6414afd 100644 --- a/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/deserializer.ex.mustache @@ -12,24 +12,33 @@ defmodule {{moduleName}}.Deserializer do model |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: [struct(mod)]])))) end + def deserialize(model, field, :struct, mod, options) do model |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: struct(mod)])))) end + def deserialize(model, field, :map, mod, options) do model - |> Map.update!(field, &(Map.new(&1, fn {key, val} -> {key, Poison.Decode.decode(val, Keyword.merge(options, [as: struct(mod)]))} end))) + |> Map.update!( + field, + &Map.new(&1, fn {key, val} -> + {key, Poison.Decode.decode(val, Keyword.merge(options, [as: struct(mod)]))} + end) + ) end + def deserialize(model, field, :date, _, _options) do value = Map.get(model, field) case is_binary(value) do - true -> case DateTime.from_iso8601(value) do - {:ok, datetime, _offset} -> - Map.put(model, field, datetime) - _ -> - model - end - false -> model + true -> + case DateTime.from_iso8601(value) do + {:ok, datetime, _offset} -> Map.put(model, field, datetime) + _ -> model + end + + false -> + model end end end diff --git a/modules/openapi-generator/src/main/resources/elixir/gitignore.mustache b/modules/openapi-generator/src/main/resources/elixir/gitignore.mustache index b6012c77a3..5aa3f68181 100644 --- a/modules/openapi-generator/src/main/resources/elixir/gitignore.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/gitignore.mustache @@ -18,3 +18,6 @@ erl_crash.dump # Also ignore archive artifacts (built via "mix archive.build"). *.ez + +# Ignore elixir LS +/.elixir_ls diff --git a/modules/openapi-generator/src/main/resources/elixir/licenseInfo.mustache b/modules/openapi-generator/src/main/resources/elixir/licenseInfo.mustache index 6e4e7a44c6..d1a2fd0a00 100644 --- a/modules/openapi-generator/src/main/resources/elixir/licenseInfo.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/licenseInfo.mustache @@ -1,6 +1,5 @@ {{#licenseHeader}}{{.}} {{/licenseHeader}} -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator {{generatorVersion}} (https://openapi-generator.tech). +# Do not edit this file manually. diff --git a/modules/openapi-generator/src/main/resources/elixir/mix.exs.mustache b/modules/openapi-generator/src/main/resources/elixir/mix.exs.mustache index aa05473908..71b8143b9c 100644 --- a/modules/openapi-generator/src/main/resources/elixir/mix.exs.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/mix.exs.mustache @@ -2,14 +2,16 @@ defmodule {{moduleName}}.Mixfile do use Mix.Project def project do - [app: :{{#underscored}}{{packageName}}{{/underscored}}, - version: "{{appVersion}}", - elixir: "~> {{supportedElixirVersion}}", - build_embedded: Mix.env == :prod, - start_permanent: Mix.env == :prod, - package: package(), - description: "{{appDescription}}", - deps: deps()] + [ + app: {{#atom}}{{#underscored}}{{packageName}}{{/underscored}}{{/atom}}, + version: "{{appVersion}}", + elixir: "~> {{supportedElixirVersion}}", + build_embedded: Mix.env() == :prod, + start_permanent: Mix.env() == :prod, + package: package(), + description: "{{appDescription}}", + deps: deps() + ] end # Configuration for the OTP application @@ -37,11 +39,13 @@ defmodule {{moduleName}}.Mixfile do ] end - defp package() do - [ - name: "{{#underscored}}{{packageName}}{{/underscored}}", - files: ~w(.formatter.exs config lib mix.exs README* LICENSE*), - licenses: ["{{licenseId}}"] - ] + defp package do + [ + name: "{{#underscored}}{{packageName}}{{/underscored}}", + files: ~w(.formatter.exs config lib mix.exs README* LICENSE*), +{{#licenseId}} + licenses: ["{{licenseId}}"] +{{/licenseId}} + ] end end diff --git a/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache b/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache index 70e6fe297c..825beac5a4 100644 --- a/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache @@ -5,113 +5,130 @@ defmodule {{moduleName}}.RequestBuilder do """ @doc """ - Specify the request method when building a request + Specify the request `method` when building a request. - ## Parameters + Does not override the `method` if one has already been specified. - - request (Map) - Collected request options - - m (atom) - Request method + ### Parameters - ## Returns + - `request` (Map) - Collected request options + - `method` (atom) - Request method + + ### Returns Map """ - @spec method(map(), atom) :: map() - def method(request, m) do - Map.put_new(request, :method, m) + @spec method(map(), atom()) :: map() + def method(request, method) do + Map.put_new(request, :method, method) end @doc """ - Specify the request method when building a request + Specify the request URL when building a request. - ## Parameters + Does not override the `url` if one has already been specified. - - request (Map) - Collected request options - - u (String) - Request URL + ### Parameters - ## Returns + - `request` (Map) - Collected request options + - `url` (String) - Request URL + + ### Returns Map """ - @spec url(map(), String.t) :: map() - def url(request, u) do - Map.put_new(request, :url, u) + @spec url(map(), String.t()) :: map() + def url(request, url) do + Map.put_new(request, :url, url) end @doc """ - Add optional parameters to the request + Add optional parameters to the request. - ## Parameters + ### Parameters - - request (Map) - Collected request options - - definitions (Map) - Map of parameter name to parameter location. - - options (KeywordList) - The provided optional parameters + - `request` (Map) - Collected request options + - `definitions` (Map) - Map of parameter name to parameter location. + - `options` (KeywordList) - The provided optional parameters - ## Returns + ### Returns Map """ - @spec add_optional_params(map(), %{optional(atom) => atom}, keyword()) :: map() + @spec add_optional_params(map(), %{optional(atom) => atom()}, keyword()) :: map() def add_optional_params(request, _, []), do: request + def add_optional_params(request, definitions, [{key, value} | tail]) do case definitions do %{^key => location} -> request |> add_param(location, key, value) |> add_optional_params(definitions, tail) + _ -> add_optional_params(request, definitions, tail) end end @doc """ - Add optional parameters to the request + Add non-optional parameters to the request. - ## Parameters + ### Parameters - - request (Map) - Collected request options - - location (atom) - Where to put the parameter - - key (atom) - The name of the parameter - - value (any) - The value of the parameter + - `request` (Map) - Collected request options + - `location` (atom) - Where to put the parameter + - `key` (atom) - The name of the parameter + - `value` (any) - The value of the parameter - ## Returns + ### Returns Map """ - @spec add_param(map(), atom, atom, any()) :: map() + @spec add_param(map(), atom(), atom(), any()) :: map() def add_param(request, :body, :body, value), do: Map.put(request, :body, value) + def add_param(request, :body, key, value) do request |> Map.put_new_lazy(:body, &Tesla.Multipart.new/0) - |> Map.update!(:body, &(Tesla.Multipart.add_field(&1, key, Poison.encode!(value), headers: [{:"Content-Type", "application/json"}]))) + |> Map.update!(:body, fn multipart -> + Tesla.Multipart.add_field( + multipart, + key, + Poison.encode!(value), + headers: [{:"Content-Type", "application/json"}] + ) + end) end + def add_param(request, :headers, key, value) do - request - |> Tesla.put_header(key, value) + Tesla.put_header(request, key, value) end + def add_param(request, :file, name, path) do request |> Map.put_new_lazy(:body, &Tesla.Multipart.new/0) |> Map.update!(:body, &(Tesla.Multipart.add_file(&1, path, name: name))) end + def add_param(request, :form, name, value) do - request - |> Map.update(:body, %{name => value}, &(Map.put(&1, name, value))) + Map.update(request, :body, %{name => value}, &(Map.put(&1, name, value))) end + def add_param(request, location, key, value) do Map.update(request, location, [{key, value}], &(&1 ++ [{key, value}])) end @doc """ - Due to a bug in httpc, POST, PATCH and PUT requests will fail, if the body is empty + This function ensures that the `body` parameter is always set. - This function will ensure, that the body param is always set + When using Tesla with the `httpc` adapter (the default adapter), there is a + bug where POST, PATCH and PUT requests will fail if the body is empty. - ## Parameters + ### Parameters - - request (Map) - Collected request options + - `request` (Map) - Collected request options - ## Returns + ### Returns Map """ @@ -124,39 +141,44 @@ defmodule {{moduleName}}.RequestBuilder do Map.put_new(request, :body, "") end + @type status_code :: 100..599 + @type response_mapping :: [{status_code, struct() | false}] + @doc """ - Handle the response for a Tesla request + Evaluate the response from a Tesla request. + Decode the response for a Tesla request. - ## Parameters + ### Parameters - - arg1 (Tesla.Env.t | term) - The response object - - arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into + - `result` (Tesla.Env.result()): The response from Tesla.request/2. + - `mapping` ([{http_status, struct}]): The mapping for status to struct for decoding. - ## Returns + ### Returns - {:ok, struct} on success - {:error, term} on failure + - `{:ok, struct}` or `{:ok, Tesla.Env.t()}` on success + - `{:error, term}` on failure """ - @spec decode(Tesla.Env.t() | term(), false | struct() | [struct()]) :: - {:ok, struct()} | {:ok, Tesla.Env.t()} | {:error, any} - def decode(%Tesla.Env{} = env, false), do: {:ok, env} - def decode(%Tesla.Env{body: body}, struct), do: Poison.decode(body, as: struct) - + @spec evaluate_response(Tesla.Env.result(), response_mapping) :: {:ok, struct()} | Tesla.Env.result() def evaluate_response({:ok, %Tesla.Env{} = env}, mapping) do - resolve_mapping(env, mapping) + resolve_mapping(env, mapping, nil) end def evaluate_response({:error, _} = error, _), do: error - def resolve_mapping(env, mapping, default \\ nil) - - def resolve_mapping(%Tesla.Env{status: status} = env, [{mapping_status, struct} | _], _) + defp resolve_mapping(%Tesla.Env{status: status} = env, [{mapping_status, struct} | _], _) when status == mapping_status do decode(env, struct) end - def resolve_mapping(env, [{:default, struct} | tail], _), do: resolve_mapping(env, tail, struct) - def resolve_mapping(env, [_ | tail], struct), do: resolve_mapping(env, tail, struct) - def resolve_mapping(env, [], nil), do: {:error, env} - def resolve_mapping(env, [], struct), do: decode(env, struct) + defp resolve_mapping(env, [{:default, struct} | tail], _), do: resolve_mapping(env, tail, struct) + + defp resolve_mapping(env, [_ | tail], struct), do: resolve_mapping(env, tail, struct) + + defp resolve_mapping(env, [], nil), do: {:error, env} + + defp resolve_mapping(env, [], struct), do: decode(env, struct) + + defp decode(%Tesla.Env{} = env, false), do: {:ok, env} + + defp decode(%Tesla.Env{body: body}, struct), do: Poison.decode(body, as: struct) end diff --git a/modules/openapi-generator/src/main/resources/elixir/runtime.exs.mustache b/modules/openapi-generator/src/main/resources/elixir/runtime.exs.mustache index e10c690c80..30d2a8f9f4 100644 --- a/modules/openapi-generator/src/main/resources/elixir/runtime.exs.mustache +++ b/modules/openapi-generator/src/main/resources/elixir/runtime.exs.mustache @@ -7,6 +7,6 @@ import Config # any compile-time configuration in here, as it won't be applied. # The block below contains prod specific runtime configuration. -if env = System.get_env("{{#env_var}}{{appName}}{{/env_var}}_BASE_URI") do - config :{{#underscored}}{{appName}}{{/underscored}}, base_url: env +if base_url = System.get_env("{{#env_var}}{{packageName}}{{/env_var}}_BASE_URI") do + config {{#atom}}{{#underscored}}{{packageName}}{{/underscored}}{{/atom}}, base_url: base_url end diff --git a/samples/client/petstore/elixir/.gitignore b/samples/client/petstore/elixir/.gitignore index b6012c77a3..5aa3f68181 100644 --- a/samples/client/petstore/elixir/.gitignore +++ b/samples/client/petstore/elixir/.gitignore @@ -18,3 +18,6 @@ erl_crash.dump # Also ignore archive artifacts (built via "mix archive.build"). *.ez + +# Ignore elixir LS +/.elixir_ls diff --git a/samples/client/petstore/elixir/README.md b/samples/client/petstore/elixir/README.md index 42caba912a..898f669267 100644 --- a/samples/client/petstore/elixir/README.md +++ b/samples/client/petstore/elixir/README.md @@ -2,33 +2,46 @@ This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ -### Building +## Building To install the required dependencies and to build the elixir project, run: -``` + +```console mix local.hex --force mix do deps.get, compile ``` ## Installation -If [available in Hex](https://hex.pm/docs/publish), the package can be installed -by adding `openapi_petstore` to your list of dependencies in `mix.exs`: +If [available in Hex][], the package can be installed by adding `openapi_petstore` to +your list of dependencies in `mix.exs`: ```elixir def deps do - [{:openapi_petstore, "~> 0.1.0"}] + [{:openapi_petstore, "~> 1.0.0"}] end ``` -Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) -and published on [HexDocs](https://hexdocs.pm). Once published, the docs can -be found at [https://hexdocs.pm/openapi_petstore](https://hexdocs.pm/openapi_petstore). - +Documentation can be generated with [ExDoc][] and published on [HexDocs][]. Once published, the docs can be found at +[https://hexdocs.pm/openapi_petstore][docs]. ## Configuration -You can override the URL of your server (e.g. if you have a separate development and production server in your configuration files. +You can override the URL of your server (e.g. if you have a separate development and production server in your +configuration files). + ```elixir -config :open_api_petstore, base_url: "http://petstore.swagger.io:80/v2" -``` \ No newline at end of file +config :openapi_petstore, base_url: "http://petstore.swagger.io:80/v2" +``` + +Multiple clients for the same API with different URLs can be created passing different `base_url`s when calling +`OpenapiPetstore.Connection.new/1`: + +```elixir +client = OpenapiPetstore.Connection.new(base_url: "http://petstore.swagger.io:80/v2") +``` + +[exdoc]: https://github.com/elixir-lang/ex_doc +[hexdocs]: https://hexdocs.pm +[available in hex]: https://hex.pm/docs/publish +[docs]: https://hexdocs.pm/openapi_petstore diff --git a/samples/client/petstore/elixir/config/config.exs b/samples/client/petstore/elixir/config/config.exs index 6056f2411d..a6e7708580 100644 --- a/samples/client/petstore/elixir/config/config.exs +++ b/samples/client/petstore/elixir/config/config.exs @@ -7,7 +7,7 @@ # General application configuration import Config -config :open_api_petstore, base_url: "http://petstore.swagger.io:80/v2" +config :openapi_petstore, base_url: "http://petstore.swagger.io:80/v2" # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. diff --git a/samples/client/petstore/elixir/config/runtime.exs b/samples/client/petstore/elixir/config/runtime.exs index a034b2dac4..9fcc3ea00a 100644 --- a/samples/client/petstore/elixir/config/runtime.exs +++ b/samples/client/petstore/elixir/config/runtime.exs @@ -7,6 +7,6 @@ import Config # any compile-time configuration in here, as it won't be applied. # The block below contains prod specific runtime configuration. -if env = System.get_env("OPEN_API_PETSTORE_BASE_URI") do - config :open_api_petstore, base_url: env +if base_url = System.get_env("OPENAPI_PETSTORE_BASE_URI") do + config :openapi_petstore, base_url: base_url end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex index 110b399f33..a6e58d1b07 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/another_fake.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.AnotherFake do @moduledoc """ @@ -10,31 +9,34 @@ defmodule OpenapiPetstore.Api.AnotherFake do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ To test special tags To test special tags and operation ID starting with number - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - client (Client): client model - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `client` (Client): client model + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.Client.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.Client.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec call_123_test_special_tags(Tesla.Env.client, OpenapiPetstore.Model.Client.t, keyword()) :: {:ok, OpenapiPetstore.Model.Client.t} | {:error, Tesla.Env.t} def call_123_test_special_tags(connection, client, _opts \\ []) do - %{} - |> method(:patch) - |> url("/another-fake/dummy") - |> add_param(:body, :body, client) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:patch) + |> url("/another-fake/dummy") + |> add_param(:body, :body, client) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.Client{}} + {200, %OpenapiPetstore.Model.Client{}} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/default.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/default.ex index 6432938ee0..2093a71f98 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/default.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/default.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.Default do @moduledoc """ @@ -10,27 +9,30 @@ defmodule OpenapiPetstore.Api.Default do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.FooGetDefaultResponse.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.FooGetDefaultResponse.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec foo_get(Tesla.Env.client, keyword()) :: {:ok, OpenapiPetstore.Model.FooGetDefaultResponse.t} | {:error, Tesla.Env.t} def foo_get(connection, _opts \\ []) do - %{} - |> method(:get) - |> url("/foo") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/foo") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { :default, %OpenapiPetstore.Model.FooGetDefaultResponse{}} + {:default, %OpenapiPetstore.Model.FooGetDefaultResponse{}} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex index 1d2b32abc9..8be82a4bde 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.Fake do @moduledoc """ @@ -10,45 +9,49 @@ defmodule OpenapiPetstore.Api.Fake do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ Health check endpoint - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.HealthCheckResult.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.HealthCheckResult.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_health_get(Tesla.Env.client, keyword()) :: {:ok, OpenapiPetstore.Model.HealthCheckResult.t} | {:error, Tesla.Env.t} def fake_health_get(connection, _opts \\ []) do - %{} - |> method(:get) - |> url("/fake/health") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/fake/health") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.HealthCheckResult{}} + {200, %OpenapiPetstore.Model.HealthCheckResult{}} ]) end @doc """ test http signature authentication - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet (Pet): Pet object that needs to be added to the store - - opts (KeywordList): [optional] Optional parameters - - :query1 (String.t): query parameter - - :header1 (String.t): header parameter - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet` (Pet): Pet object that needs to be added to the store + - `opts` (keyword): Optional parameters + - `:query1` (String.t): query parameter + - `:header1` (String.t): header parameter - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_http_signature_test(Tesla.Env.client, OpenapiPetstore.Model.Pet.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def fake_http_signature_test(connection, pet, opts \\ []) do @@ -56,240 +59,280 @@ defmodule OpenapiPetstore.Api.Fake do :query_1 => :query, :header_1 => :headers } - %{} - |> method(:get) - |> url("/fake/http-signature-test") - |> add_param(:body, :body, pet) - |> add_optional_params(optional_params, opts) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:get) + |> url("/fake/http-signature-test") + |> add_param(:body, :body, pet) + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ Test serialization of outer boolean types - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - - :body (boolean()): Input boolean as post body - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters + - `:body` (boolean()): Input boolean as post body - {:ok, boolean()} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, boolean()}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_outer_boolean_serialize(Tesla.Env.client, keyword()) :: {:ok, Boolean.t} | {:error, Tesla.Env.t} def fake_outer_boolean_serialize(connection, opts \\ []) do optional_params = %{ :body => :body } - %{} - |> method(:post) - |> url("/fake/outer/boolean") - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/fake/outer/boolean") + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ Test serialization of object with outer number type - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - - :body (OuterComposite): Input composite as post body - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters + - `:body` (OuterComposite): Input composite as post body - {:ok, OpenapiPetstore.Model.OuterComposite.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.OuterComposite.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_outer_composite_serialize(Tesla.Env.client, keyword()) :: {:ok, OpenapiPetstore.Model.OuterComposite.t} | {:error, Tesla.Env.t} def fake_outer_composite_serialize(connection, opts \\ []) do optional_params = %{ :body => :body } - %{} - |> method(:post) - |> url("/fake/outer/composite") - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/fake/outer/composite") + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.OuterComposite{}} + {200, %OpenapiPetstore.Model.OuterComposite{}} ]) end @doc """ Test serialization of outer number types - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - - :body (float()): Input number as post body - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters + - `:body` (float()): Input number as post body - {:ok, float()} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, float()}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_outer_number_serialize(Tesla.Env.client, keyword()) :: {:ok, Float.t} | {:error, Tesla.Env.t} def fake_outer_number_serialize(connection, opts \\ []) do optional_params = %{ :body => :body } - %{} - |> method(:post) - |> url("/fake/outer/number") - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/fake/outer/number") + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ Test serialization of outer string types - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - - :body (String.t): Input string as post body - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters + - `:body` (String.t): Input string as post body - {:ok, String.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, String.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_outer_string_serialize(Tesla.Env.client, keyword()) :: {:ok, String.t} | {:error, Tesla.Env.t} def fake_outer_string_serialize(connection, opts \\ []) do optional_params = %{ :body => :body } - %{} - |> method(:post) - |> url("/fake/outer/string") - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/fake/outer/string") + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ Test serialization of enum (int) properties with examples - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - outer_object_with_enum_property (OuterObjectWithEnumProperty): Input enum (int) as post body - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `outer_object_with_enum_property` (OuterObjectWithEnumProperty): Input enum (int) as post body + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.OuterObjectWithEnumProperty.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.OuterObjectWithEnumProperty.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec fake_property_enum_integer_serialize(Tesla.Env.client, OpenapiPetstore.Model.OuterObjectWithEnumProperty.t, keyword()) :: {:ok, OpenapiPetstore.Model.OuterObjectWithEnumProperty.t} | {:error, Tesla.Env.t} def fake_property_enum_integer_serialize(connection, outer_object_with_enum_property, _opts \\ []) do - %{} - |> method(:post) - |> url("/fake/property/enum-int") - |> add_param(:body, :body, outer_object_with_enum_property) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/fake/property/enum-int") + |> add_param(:body, :body, outer_object_with_enum_property) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.OuterObjectWithEnumProperty{}} + {200, %OpenapiPetstore.Model.OuterObjectWithEnumProperty{}} ]) end @doc """ For this test, the body has to be a binary file. - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - body (String.t): image to upload - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `body` (String.t): image to upload + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_body_with_binary(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_body_with_binary(connection, body, _opts \\ []) do - %{} - |> method(:put) - |> url("/fake/body-with-binary") - |> add_param(:body, :body, body) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:put) + |> url("/fake/body-with-binary") + |> add_param(:body, :body, body) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ For this test, the body for this request must reference a schema named `File`. - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - file_schema_test_class (FileSchemaTestClass): - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `file_schema_test_class` (FileSchemaTestClass): + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_body_with_file_schema(Tesla.Env.client, OpenapiPetstore.Model.FileSchemaTestClass.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_body_with_file_schema(connection, file_schema_test_class, _opts \\ []) do - %{} - |> method(:put) - |> url("/fake/body-with-file-schema") - |> add_param(:body, :body, file_schema_test_class) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:put) + |> url("/fake/body-with-file-schema") + |> add_param(:body, :body, file_schema_test_class) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - query (String.t): - - user (User): - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `query` (String.t): + - `user` (User): + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_body_with_query_params(Tesla.Env.client, String.t, OpenapiPetstore.Model.User.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_body_with_query_params(connection, query, user, _opts \\ []) do - %{} - |> method(:put) - |> url("/fake/body-with-query-params") - |> add_param(:query, :query, query) - |> add_param(:body, :body, user) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:put) + |> url("/fake/body-with-query-params") + |> add_param(:query, :query, query) + |> add_param(:body, :body, user) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @@ -297,26 +340,30 @@ defmodule OpenapiPetstore.Api.Fake do To test \"client\" model To test \"client\" model - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - client (Client): client model - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `client` (Client): client model + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.Client.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.Client.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_client_model(Tesla.Env.client, OpenapiPetstore.Model.Client.t, keyword()) :: {:ok, OpenapiPetstore.Model.Client.t} | {:error, Tesla.Env.t} def test_client_model(connection, client, _opts \\ []) do - %{} - |> method(:patch) - |> url("/fake") - |> add_param(:body, :body, client) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:patch) + |> url("/fake") + |> add_param(:body, :body, client) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.Client{}} + {200, %OpenapiPetstore.Model.Client{}} ]) end @@ -324,28 +371,29 @@ defmodule OpenapiPetstore.Api.Fake do Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - number (float()): None - - double (float()): None - - pattern_without_delimiter (String.t): None - - byte (binary()): None - - opts (KeywordList): [optional] Optional parameters - - :integer (integer()): None - - :int32 (integer()): None - - :int64 (integer()): None - - :float (float()): None - - :string (String.t): None - - :binary (String.t): None - - :date (Date.t): None - - :date_time (DateTime.t): None - - :password (String.t): None - - :callback (String.t): None - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `number` (float()): None + - `double` (float()): None + - `pattern_without_delimiter` (String.t): None + - `byte` (binary()): None + - `opts` (keyword): Optional parameters + - `:integer` (integer()): None + - `:int32` (integer()): None + - `:int64` (integer()): None + - `:float` (float()): None + - `:string` (String.t): None + - `:binary` (String.t): None + - `:date` (Date.t): None + - `:date_time` (DateTime.t): None + - `:password` (String.t): None + - `:callback` (String.t): None - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_endpoint_parameters(Tesla.Env.client, float(), float(), String.t, binary(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_endpoint_parameters(connection, number, double, pattern_without_delimiter, byte, opts \\ []) do @@ -361,19 +409,23 @@ defmodule OpenapiPetstore.Api.Fake do :password => :form, :callback => :form } - %{} - |> method(:post) - |> url("/fake") - |> add_param(:form, :number, number) - |> add_param(:form, :double, double) - |> add_param(:form, :pattern_without_delimiter, pattern_without_delimiter) - |> add_param(:form, :byte, byte) - |> add_optional_params(optional_params, opts) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/fake") + |> add_param(:form, :number, number) + |> add_param(:form, :double, double) + |> add_param(:form, :pattern_without_delimiter, pattern_without_delimiter) + |> add_param(:form, :byte, byte) + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 400, false}, - { 404, false} + {400, false}, + {404, false} ]) end @@ -381,23 +433,24 @@ defmodule OpenapiPetstore.Api.Fake do To test enum parameters To test enum parameters - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - - :enum_header_string_array ([String.t]): Header parameter enum test (string array) - - :enum_header_string (String.t): Header parameter enum test (string) - - :enum_query_string_array ([String.t]): Query parameter enum test (string array) - - :enum_query_string (String.t): Query parameter enum test (string) - - :enum_query_integer (integer()): Query parameter enum test (double) - - :enum_query_double (float()): Query parameter enum test (double) - - :enum_query_model_array ([OpenapiPetstore.Model.EnumClass.t]): - - :enum_form_string_array ([String.t]): Form parameter enum test (string array) - - :enum_form_string (String.t): Form parameter enum test (string) - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters + - `:enum_header_string_array` ([String.t]): Header parameter enum test (string array) + - `:enum_header_string` (String.t): Header parameter enum test (string) + - `:enum_query_string_array` ([String.t]): Query parameter enum test (string array) + - `:enum_query_string` (String.t): Query parameter enum test (string) + - `:enum_query_integer` (integer()): Query parameter enum test (double) + - `:enum_query_double` (float()): Query parameter enum test (double) + - `:enum_query_model_array` ([OpenapiPetstore.Model.EnumClass.t]): + - `:enum_form_string_array` ([String.t]): Form parameter enum test (string array) + - `:enum_form_string` (String.t): Form parameter enum test (string) - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_enum_parameters(Tesla.Env.client, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_enum_parameters(connection, opts \\ []) do @@ -412,15 +465,19 @@ defmodule OpenapiPetstore.Api.Fake do :enum_form_string_array => :form, :enum_form_string => :form } - %{} - |> method(:get) - |> url("/fake") - |> add_optional_params(optional_params, opts) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:get) + |> url("/fake") + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 400, false}, - { 404, false} + {400, false}, + {404, false} ]) end @@ -428,20 +485,21 @@ defmodule OpenapiPetstore.Api.Fake do Fake endpoint to test group parameters (optional) Fake endpoint to test group parameters (optional) - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - required_string_group (integer()): Required String in group parameters - - required_boolean_group (boolean()): Required Boolean in group parameters - - required_int64_group (integer()): Required Integer in group parameters - - opts (KeywordList): [optional] Optional parameters - - :string_group (integer()): String in group parameters - - :boolean_group (boolean()): Boolean in group parameters - - :int64_group (integer()): Integer in group parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `required_string_group` (integer()): Required String in group parameters + - `required_boolean_group` (boolean()): Required Boolean in group parameters + - `required_int64_group` (integer()): Required Integer in group parameters + - `opts` (keyword): Optional parameters + - `:string_group` (integer()): String in group parameters + - `:boolean_group` (boolean()): Boolean in group parameters + - `:int64_group` (integer()): Integer in group parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_group_parameters(Tesla.Env.client, integer(), boolean(), integer(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_group_parameters(connection, required_string_group, required_boolean_group, required_int64_group, opts \\ []) do @@ -450,17 +508,21 @@ defmodule OpenapiPetstore.Api.Fake do :boolean_group => :headers, :int64_group => :query } - %{} - |> method(:delete) - |> url("/fake") - |> add_param(:query, :required_string_group, required_string_group) - |> add_param(:headers, :required_boolean_group, required_boolean_group) - |> add_param(:query, :required_int64_group, required_int64_group) - |> add_optional_params(optional_params, opts) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:delete) + |> url("/fake") + |> add_param(:query, :required_string_group, required_string_group) + |> add_param(:headers, :required_boolean_group, required_boolean_group) + |> add_param(:query, :required_int64_group, required_int64_group) + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 400, false} + {400, false} ]) end @@ -468,26 +530,30 @@ defmodule OpenapiPetstore.Api.Fake do test inline additionalProperties - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - request_body (%{optional(String.t) => String.t}): request body - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `request_body` (%{optional(String.t) => String.t}): request body + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_inline_additional_properties(Tesla.Env.client, %{optional(String.t) => String.t}, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_inline_additional_properties(connection, request_body, _opts \\ []) do - %{} - |> method(:post) - |> url("/fake/inline-additionalProperties") - |> add_param(:body, :body, request_body) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/fake/inline-additionalProperties") + |> add_param(:body, :body, request_body) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @@ -495,70 +561,79 @@ defmodule OpenapiPetstore.Api.Fake do test json serialization of form data - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - param (String.t): field1 - - param2 (String.t): field2 - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `param` (String.t): field1 + - `param2` (String.t): field2 + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_json_form_data(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_json_form_data(connection, param, param2, _opts \\ []) do - %{} - |> method(:get) - |> url("/fake/jsonFormData") - |> add_param(:form, :param, param) - |> add_param(:form, :param2, param2) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/fake/jsonFormData") + |> add_param(:form, :param, param) + |> add_param(:form, :param2, param2) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end @doc """ To test the collection format in query parameters - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pipe ([String.t]): - - ioutil ([String.t]): - - http ([String.t]): - - url ([String.t]): - - context ([String.t]): - - allow_empty (String.t): - - opts (KeywordList): [optional] Optional parameters - - :language (%{optional(String.t) => String.t}): - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pipe` ([String.t]): + - `ioutil` ([String.t]): + - `http` ([String.t]): + - `url` ([String.t]): + - `context` ([String.t]): + - `allow_empty` (String.t): + - `opts` (keyword): Optional parameters + - `:language` (%{optional(String.t) => String.t}): - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_query_parameter_collection_format(Tesla.Env.client, list(String.t), list(String.t), list(String.t), list(String.t), list(String.t), String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_query_parameter_collection_format(connection, pipe, ioutil, http, url, context, allow_empty, opts \\ []) do optional_params = %{ :language => :query } - %{} - |> method(:put) - |> url("/fake/test-query-parameters") - |> add_param(:query, :pipe, pipe) - |> add_param(:query, :ioutil, ioutil) - |> add_param(:query, :http, http) - |> add_param(:query, :url, url) - |> add_param(:query, :context, context) - |> add_param(:query, :allowEmpty, allow_empty) - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:put) + |> url("/fake/test-query-parameters") + |> add_param(:query, :pipe, pipe) + |> add_param(:query, :ioutil, ioutil) + |> add_param(:query, :http, http) + |> add_param(:query, :url, url) + |> add_param(:query, :context, context) + |> add_param(:query, :allowEmpty, allow_empty) + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false} + {200, false} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake_classname_tags123.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake_classname_tags123.ex index fd202abac6..941b1ab0b1 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/fake_classname_tags123.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/fake_classname_tags123.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.FakeClassnameTags123 do @moduledoc """ @@ -10,31 +9,34 @@ defmodule OpenapiPetstore.Api.FakeClassnameTags123 do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ To test class name in snake case To test class name in snake case - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - client (Client): client model - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `client` (Client): client model + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.Client.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.Client.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec test_classname(Tesla.Env.client, OpenapiPetstore.Model.Client.t, keyword()) :: {:ok, OpenapiPetstore.Model.Client.t} | {:error, Tesla.Env.t} def test_classname(connection, client, _opts \\ []) do - %{} - |> method(:patch) - |> url("/fake_classname_test") - |> add_param(:body, :body, client) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:patch) + |> url("/fake_classname_test") + |> add_param(:body, :body, client) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.Client{}} + {200, %OpenapiPetstore.Model.Client{}} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex index acc415d75a..700c6253c0 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/pet.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.Pet do @moduledoc """ @@ -10,32 +9,35 @@ defmodule OpenapiPetstore.Api.Pet do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ Add a new pet to the store - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet (Pet): Pet object that needs to be added to the store - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet` (Pet): Pet object that needs to be added to the store + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec add_pet(Tesla.Env.client, OpenapiPetstore.Model.Pet.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def add_pet(connection, pet, _opts \\ []) do - %{} - |> method(:post) - |> url("/pet") - |> add_param(:body, :body, pet) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/pet") + |> add_param(:body, :body, pet) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false}, - { 405, false} + {200, false}, + {405, false} ]) end @@ -43,31 +45,36 @@ defmodule OpenapiPetstore.Api.Pet do Deletes a pet - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet_id (integer()): Pet id to delete - - opts (KeywordList): [optional] Optional parameters - - :api_key (String.t): - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet_id` (integer()): Pet id to delete + - `opts` (keyword): Optional parameters + - `:api_key` (String.t): - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec delete_pet(Tesla.Env.client, integer(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def delete_pet(connection, pet_id, opts \\ []) do optional_params = %{ :api_key => :headers } - %{} - |> method(:delete) - |> url("/pet/#{pet_id}") - |> add_optional_params(optional_params, opts) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:delete) + |> url("/pet/#{pet_id}") + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false}, - { 400, false} + {200, false}, + {400, false} ]) end @@ -75,27 +82,31 @@ defmodule OpenapiPetstore.Api.Pet do Finds Pets by status Multiple status values can be provided with comma separated strings - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - status ([String.t]): Status values that need to be considered for filter - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `status` ([String.t]): Status values that need to be considered for filter + - `opts` (keyword): Optional parameters - {:ok, [%Pet{}, ...]} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, [%Pet{}, ...]}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec find_pets_by_status(Tesla.Env.client, list(String.t), keyword()) :: {:ok, nil} | {:ok, list(OpenapiPetstore.Model.Pet.t)} | {:error, Tesla.Env.t} def find_pets_by_status(connection, status, _opts \\ []) do - %{} - |> method(:get) - |> url("/pet/findByStatus") - |> add_param(:query, :status, status) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/pet/findByStatus") + |> add_param(:query, :status, status) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, [%OpenapiPetstore.Model.Pet{}]}, - { 400, false} + {200, [%OpenapiPetstore.Model.Pet{}]}, + {400, false} ]) end @@ -103,27 +114,31 @@ defmodule OpenapiPetstore.Api.Pet do Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - tags ([String.t]): Tags to filter by - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `tags` ([String.t]): Tags to filter by + - `opts` (keyword): Optional parameters - {:ok, [%Pet{}, ...]} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, [%Pet{}, ...]}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec find_pets_by_tags(Tesla.Env.client, list(String.t), keyword()) :: {:ok, nil} | {:ok, list(OpenapiPetstore.Model.Pet.t)} | {:error, Tesla.Env.t} def find_pets_by_tags(connection, tags, _opts \\ []) do - %{} - |> method(:get) - |> url("/pet/findByTags") - |> add_param(:query, :tags, tags) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/pet/findByTags") + |> add_param(:query, :tags, tags) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, [%OpenapiPetstore.Model.Pet{}]}, - { 400, false} + {200, [%OpenapiPetstore.Model.Pet{}]}, + {400, false} ]) end @@ -131,27 +146,31 @@ defmodule OpenapiPetstore.Api.Pet do Find pet by ID Returns a single pet - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet to return - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet_id` (integer()): ID of pet to return + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.Pet.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.Pet.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec get_pet_by_id(Tesla.Env.client, integer(), keyword()) :: {:ok, nil} | {:ok, OpenapiPetstore.Model.Pet.t} | {:error, Tesla.Env.t} def get_pet_by_id(connection, pet_id, _opts \\ []) do - %{} - |> method(:get) - |> url("/pet/#{pet_id}") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/pet/#{pet_id}") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.Pet{}}, - { 400, false}, - { 404, false} + {200, %OpenapiPetstore.Model.Pet{}}, + {400, false}, + {404, false} ]) end @@ -159,29 +178,33 @@ defmodule OpenapiPetstore.Api.Pet do Update an existing pet - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet (Pet): Pet object that needs to be added to the store - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet` (Pet): Pet object that needs to be added to the store + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec update_pet(Tesla.Env.client, OpenapiPetstore.Model.Pet.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def update_pet(connection, pet, _opts \\ []) do - %{} - |> method(:put) - |> url("/pet") - |> add_param(:body, :body, pet) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:put) + |> url("/pet") + |> add_param(:body, :body, pet) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false}, - { 400, false}, - { 404, false}, - { 405, false} + {200, false}, + {400, false}, + {404, false}, + {405, false} ]) end @@ -189,17 +212,18 @@ defmodule OpenapiPetstore.Api.Pet do Updates a pet in the store with form data - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet that needs to be updated - - opts (KeywordList): [optional] Optional parameters - - :name (String.t): Updated name of the pet - - :status (String.t): Updated status of the pet - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet_id` (integer()): ID of pet that needs to be updated + - `opts` (keyword): Optional parameters + - `:name` (String.t): Updated name of the pet + - `:status` (String.t): Updated status of the pet - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec update_pet_with_form(Tesla.Env.client, integer(), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def update_pet_with_form(connection, pet_id, opts \\ []) do @@ -207,16 +231,20 @@ defmodule OpenapiPetstore.Api.Pet do :name => :form, :status => :form } - %{} - |> method(:post) - |> url("/pet/#{pet_id}") - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/pet/#{pet_id}") + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false}, - { 405, false} + {200, false}, + {405, false} ]) end @@ -224,17 +252,18 @@ defmodule OpenapiPetstore.Api.Pet do uploads an image - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet to update - - opts (KeywordList): [optional] Optional parameters - - :additional_metadata (String.t): Additional data to pass to server - - :file (String.t): file to upload - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet_id` (integer()): ID of pet to update + - `opts` (keyword): Optional parameters + - `:additional_metadata` (String.t): Additional data to pass to server + - `:file` (String.t): file to upload - {:ok, OpenapiPetstore.Model.ApiResponse.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.ApiResponse.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec upload_file(Tesla.Env.client, integer(), keyword()) :: {:ok, OpenapiPetstore.Model.ApiResponse.t} | {:error, Tesla.Env.t} def upload_file(connection, pet_id, opts \\ []) do @@ -242,15 +271,19 @@ defmodule OpenapiPetstore.Api.Pet do :additionalMetadata => :form, :file => :form } - %{} - |> method(:post) - |> url("/pet/#{pet_id}/uploadImage") - |> add_optional_params(optional_params, opts) - |> ensure_body() - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/pet/#{pet_id}/uploadImage") + |> add_optional_params(optional_params, opts) + |> ensure_body() + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.ApiResponse{}} + {200, %OpenapiPetstore.Model.ApiResponse{}} ]) end @@ -258,32 +291,37 @@ defmodule OpenapiPetstore.Api.Pet do uploads an image (required) - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet to update - - required_file (String.t): file to upload - - opts (KeywordList): [optional] Optional parameters - - :additional_metadata (String.t): Additional data to pass to server - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `pet_id` (integer()): ID of pet to update + - `required_file` (String.t): file to upload + - `opts` (keyword): Optional parameters + - `:additional_metadata` (String.t): Additional data to pass to server - {:ok, OpenapiPetstore.Model.ApiResponse.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.ApiResponse.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec upload_file_with_required_file(Tesla.Env.client, integer(), String.t, keyword()) :: {:ok, OpenapiPetstore.Model.ApiResponse.t} | {:error, Tesla.Env.t} def upload_file_with_required_file(connection, pet_id, required_file, opts \\ []) do optional_params = %{ :additionalMetadata => :form } - %{} - |> method(:post) - |> url("/fake/#{pet_id}/uploadImageWithRequiredFile") - |> add_param(:file, :requiredFile, required_file) - |> add_optional_params(optional_params, opts) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + + request = + %{} + |> method(:post) + |> url("/fake/#{pet_id}/uploadImageWithRequiredFile") + |> add_param(:file, :requiredFile, required_file) + |> add_optional_params(optional_params, opts) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.ApiResponse{}} + {200, %OpenapiPetstore.Model.ApiResponse{}} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/store.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/store.ex index 8487ba44ca..5acf6cfa89 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/store.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/store.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.Store do @moduledoc """ @@ -10,31 +9,34 @@ defmodule OpenapiPetstore.Api.Store do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - order_id (String.t): ID of the order that needs to be deleted - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `order_id` (String.t): ID of the order that needs to be deleted + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec delete_order(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def delete_order(connection, order_id, _opts \\ []) do - %{} - |> method(:delete) - |> url("/store/order/#{order_id}") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:delete) + |> url("/store/order/#{order_id}") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 400, false}, - { 404, false} + {400, false}, + {404, false} ]) end @@ -42,24 +44,28 @@ defmodule OpenapiPetstore.Api.Store do Returns pet inventories by status Returns a map of status codes to quantities - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters - {:ok, %{}} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, %{}}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec get_inventory(Tesla.Env.client, keyword()) :: {:ok, map()} | {:error, Tesla.Env.t} def get_inventory(connection, _opts \\ []) do - %{} - |> method(:get) - |> url("/store/inventory") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/store/inventory") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %{}} + {200, %{}} ]) end @@ -67,27 +73,31 @@ defmodule OpenapiPetstore.Api.Store do Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - order_id (integer()): ID of pet that needs to be fetched - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `order_id` (integer()): ID of pet that needs to be fetched + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.Order.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.Order.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec get_order_by_id(Tesla.Env.client, integer(), keyword()) :: {:ok, nil} | {:ok, OpenapiPetstore.Model.Order.t} | {:error, Tesla.Env.t} def get_order_by_id(connection, order_id, _opts \\ []) do - %{} - |> method(:get) - |> url("/store/order/#{order_id}") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/store/order/#{order_id}") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.Order{}}, - { 400, false}, - { 404, false} + {200, %OpenapiPetstore.Model.Order{}}, + {400, false}, + {404, false} ]) end @@ -95,27 +105,31 @@ defmodule OpenapiPetstore.Api.Store do Place an order for a pet - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - order (Order): order placed for purchasing the pet - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `order` (Order): order placed for purchasing the pet + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.Order.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.Order.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec place_order(Tesla.Env.client, OpenapiPetstore.Model.Order.t, keyword()) :: {:ok, nil} | {:ok, OpenapiPetstore.Model.Order.t} | {:error, Tesla.Env.t} def place_order(connection, order, _opts \\ []) do - %{} - |> method(:post) - |> url("/store/order") - |> add_param(:body, :body, order) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/store/order") + |> add_param(:body, :body, order) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.Order{}}, - { 400, false} + {200, %OpenapiPetstore.Model.Order{}}, + {400, false} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/api/user.ex b/samples/client/petstore/elixir/lib/openapi_petstore/api/user.ex index ea436c9e40..8a73fe2350 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/api/user.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/api/user.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Api.User do @moduledoc """ @@ -10,31 +9,34 @@ defmodule OpenapiPetstore.Api.User do alias OpenapiPetstore.Connection import OpenapiPetstore.RequestBuilder - @doc """ Create user This can only be done by the logged in user. - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - user (User): Created user object - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `user` (User): Created user object + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec create_user(Tesla.Env.client, OpenapiPetstore.Model.User.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def create_user(connection, user, _opts \\ []) do - %{} - |> method(:post) - |> url("/user") - |> add_param(:body, :body, user) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/user") + |> add_param(:body, :body, user) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { :default, false} + {:default, false} ]) end @@ -42,26 +44,30 @@ defmodule OpenapiPetstore.Api.User do Creates list of users with given input array - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - user ([OpenapiPetstore.Model.User.t]): List of user object - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `user` ([OpenapiPetstore.Model.User.t]): List of user object + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec create_users_with_array_input(Tesla.Env.client, list(OpenapiPetstore.Model.User.t), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def create_users_with_array_input(connection, user, _opts \\ []) do - %{} - |> method(:post) - |> url("/user/createWithArray") - |> add_param(:body, :body, user) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/user/createWithArray") + |> add_param(:body, :body, user) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { :default, false} + {:default, false} ]) end @@ -69,26 +75,30 @@ defmodule OpenapiPetstore.Api.User do Creates list of users with given input array - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - user ([OpenapiPetstore.Model.User.t]): List of user object - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `user` ([OpenapiPetstore.Model.User.t]): List of user object + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec create_users_with_list_input(Tesla.Env.client, list(OpenapiPetstore.Model.User.t), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def create_users_with_list_input(connection, user, _opts \\ []) do - %{} - |> method(:post) - |> url("/user/createWithList") - |> add_param(:body, :body, user) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:post) + |> url("/user/createWithList") + |> add_param(:body, :body, user) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { :default, false} + {:default, false} ]) end @@ -96,26 +106,30 @@ defmodule OpenapiPetstore.Api.User do Delete user This can only be done by the logged in user. - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - username (String.t): The name that needs to be deleted - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `username` (String.t): The name that needs to be deleted + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec delete_user(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def delete_user(connection, username, _opts \\ []) do - %{} - |> method(:delete) - |> url("/user/#{username}") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:delete) + |> url("/user/#{username}") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 400, false}, - { 404, false} + {400, false}, + {404, false} ]) end @@ -123,27 +137,31 @@ defmodule OpenapiPetstore.Api.User do Get user by user name - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - username (String.t): The name that needs to be fetched. Use user1 for testing. - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `username` (String.t): The name that needs to be fetched. Use user1 for testing. + - `opts` (keyword): Optional parameters - {:ok, OpenapiPetstore.Model.User.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, OpenapiPetstore.Model.User.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec get_user_by_name(Tesla.Env.client, String.t, keyword()) :: {:ok, nil} | {:ok, OpenapiPetstore.Model.User.t} | {:error, Tesla.Env.t} def get_user_by_name(connection, username, _opts \\ []) do - %{} - |> method(:get) - |> url("/user/#{username}") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/user/#{username}") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, %OpenapiPetstore.Model.User{}}, - { 400, false}, - { 404, false} + {200, %OpenapiPetstore.Model.User{}}, + {400, false}, + {404, false} ]) end @@ -151,29 +169,33 @@ defmodule OpenapiPetstore.Api.User do Logs user into the system - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - username (String.t): The user name for login - - password (String.t): The password for login in clear text - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `username` (String.t): The user name for login + - `password` (String.t): The password for login in clear text + - `opts` (keyword): Optional parameters - {:ok, String.t} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, String.t}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec login_user(Tesla.Env.client, String.t, String.t, keyword()) :: {:ok, nil} | {:ok, String.t} | {:error, Tesla.Env.t} def login_user(connection, username, password, _opts \\ []) do - %{} - |> method(:get) - |> url("/user/login") - |> add_param(:query, :username, username) - |> add_param(:query, :password, password) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/user/login") + |> add_param(:query, :username, username) + |> add_param(:query, :password, password) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 200, false}, - { 400, false} + {200, false}, + {400, false} ]) end @@ -181,24 +203,28 @@ defmodule OpenapiPetstore.Api.User do Logs out current logged in user session - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec logout_user(Tesla.Env.client, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def logout_user(connection, _opts \\ []) do - %{} - |> method(:get) - |> url("/user/logout") - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:get) + |> url("/user/logout") + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { :default, false} + {:default, false} ]) end @@ -206,28 +232,32 @@ defmodule OpenapiPetstore.Api.User do Updated user This can only be done by the logged in user. - ## Parameters + ### Parameters - - connection (OpenapiPetstore.Connection): Connection to server - - username (String.t): name that need to be deleted - - user (User): Updated user object - - opts (KeywordList): [optional] Optional parameters - ## Returns + - `connection` (OpenapiPetstore.Connection): Connection to server + - `username` (String.t): name that need to be deleted + - `user` (User): Updated user object + - `opts` (keyword): Optional parameters - {:ok, nil} on success - {:error, Tesla.Env.t} on failure + ### Returns + + - `{:ok, nil}` on success + - `{:error, Tesla.Env.t}` on failure """ @spec update_user(Tesla.Env.client, String.t, OpenapiPetstore.Model.User.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def update_user(connection, username, user, _opts \\ []) do - %{} - |> method(:put) - |> url("/user/#{username}") - |> add_param(:body, :body, user) - |> Enum.into([]) - |> (&Connection.request(connection, &1)).() + request = + %{} + |> method(:put) + |> url("/user/#{username}") + |> add_param(:body, :body, user) + |> Enum.into([]) + + connection + |> Connection.request(request) |> evaluate_response([ - { 400, false}, - { 404, false} + {400, false}, + {404, false} ]) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex index 926fcb5053..b5ed1a8bac 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/connection.ex @@ -1,122 +1,238 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Connection do @moduledoc """ Handle Tesla connections for OpenapiPetstore. + + Additional middleware can be set in the compile-time or runtime configuration: + + config :tesla, OpenapiPetstore.Connection, + base_url: "http://petstore.swagger.io:80/v2", + adapter: Tesla.Adapter.Hackney + + The default base URL can also be set as: + + config :openapi_petstore, + :base_url, "http://petstore.swagger.io:80/v2" """ - use Tesla + @default_base_url Application.compile_env( + :openapi_petstore, + :base_url, + "http://petstore.swagger.io:80/v2" + ) - # Add any middleware here (authentication) - plug Tesla.Middleware.BaseUrl, Application.get_env(:open_api_petstore, :base_url, "http://petstore.swagger.io:80/v2") - plug Tesla.Middleware.Headers, [{"user-agent", "Elixir"}] - plug Tesla.Middleware.EncodeJson, engine: Poison - - @doc """ - Configure a client connection using Basic authentication. - - ## Parameters - - - username (String): Username used for authentication - - password (String): Password used for authentication - - # Returns - - Tesla.Env.client - """ - @spec new(String.t, String.t) :: Tesla.Env.client - def new(username, password) do - Tesla.client([ - {Tesla.Middleware.BasicAuth, %{username: username, password: password}} - ]) - end - @doc """ - Configure a client connection using Basic authentication. - - ## Parameters - - - username (String): Username used for authentication - - password (String): Password used for authentication - - # Returns - - Tesla.Env.client - """ - @spec new(String.t, String.t) :: Tesla.Env.client - def new(username, password) do - Tesla.client([ - {Tesla.Middleware.BasicAuth, %{username: username, password: password}} - ]) - end - @doc """ - Configure a client connection using Basic authentication. - - ## Parameters - - - username (String): Username used for authentication - - password (String): Password used for authentication - - # Returns - - Tesla.Env.client - """ - @spec new(String.t, String.t) :: Tesla.Env.client - def new(username, password) do - Tesla.client([ - {Tesla.Middleware.BasicAuth, %{username: username, password: password}} - ]) - end - @scopes [ - "write:pets", # modify pets in your account - "read:pets" # read your pets + @default_scopes [ + # modify pets in your account + "write:pets", + # read your pets + "read:pets" ] + @typedoc """ + An arity-1 function or module/function tuple specification which, given + a list of scopes, obtains an OAuth2 token. + """ + @type token_fetcher :: (scopes :: list(String.t()) -> String.t()) | {module(), atom()} + + @typedoc """ + The list of options that can be passed to new/1. + + - `base_url`: Overrides the base URL on a per-client basis. + - `user_agent`: Overrides the User-Agent header. + - `token`: An OAuth2 token or a token fetcher function. + - `token_scopes`: A list of OAuth2 scope strings for use with a token + fetcher function. + - `username`: A username for basic authentication. + - `password`: A password for basic authentication. + """ + @type options :: [ + {:base_url, String.t()}, + {:user_agent, String.t()}, + {:token, String.t() | token_fetcher}, + {:token_scopes, list(String.t())}, + {:username, String.t() | nil}, + {:password, String.t() | nil}, + ] + + @doc "Forward requests to Tesla." + @spec request(Tesla.Client.t(), [Tesla.option()]) :: Tesla.Env.result() + defdelegate request(client, options), to: Tesla + @doc """ - Configure a client connection using a provided OAuth2 token as a Bearer token + Configure a client with no authentication. - ## Parameters - - - token (String): Bearer token - - ## Returns + ### Returns Tesla.Env.client """ - @spec new(String.t) :: Tesla.Env.client - def new(token) when is_binary(token) do - Tesla.client([ - {Tesla.Middleware.Headers, [{"authorization", "Bearer #{token}"}]} - ]) - end - - @doc """ - Configure a client connection using a function which yields a Bearer token. - - ## Parameters - - - token_fetcher (function arity of 1): Callback which provides an OAuth2 token - given a list of scopes - - ## Returns - - Tesla.Env.client - """ - @spec new(((list(String.t)) -> String.t)) :: Tesla.Env.client - def new(token_fetcher) when is_function(token_fetcher) do - token_fetcher.(@scopes) - |> new - end - @doc """ - Configure an authless client connection - - # Returns - - Tesla.Env.client - """ - @spec new() :: Tesla.Env.client + @spec new() :: Tesla.Env.client() def new do - Tesla.client([]) + Tesla.client(middleware(), adapter()) + end + + @doc """ + Configure a client that may have authentication. + + ### Parameters + + The first parameter *may* be a `token` (a string, a token fetcher class, + or a module/function tuple) or a keyword list of `options`. They are + documented separately, but only *one* of them will be passed. + + - `token`: a String or a function of arity one. This value, or the result + of the function call, will be set as a bearer token in the + `authorization` header. + - `options`: a keyword list of OpenAPIPetstore.Connection.options. + + ### Returns + + Tesla.Env.client + """ + @spec new(String.t() | token_fetcher | options) :: Tesla.Env.client() + def new(token) when is_binary(token) or is_function(token, 1) or is_tuple(token) do + new(token: token) + end + + def new(options) when is_list(options) do + options + |> middleware() + |> Tesla.client(adapter()) + end + + @doc """ + Configure a client using bearer authentication with scopes, or with + username and password for basic authentication. + + ### Parameters + + - `token_or_username`: a String representing a bearer token or a username, + depending on the type of the next parameter, or a function arity one + that returns a bearer token. + - `scopes_or_password`: a list of Strings represenging OAuth2 scopes, or + a single string that is the password for the username provided. + - `options`: a keyword list of OpenAPIPetstore.Connection.options. + + ### Returns + + Tesla.Env.client + """ + @spec new( + token_or_username :: String.t() | token_fetcher, + scopes_or_password :: list(String.t()) | String.t(), + options + ) :: Tesla.Env.client() + + def new(token_or_username, scopes_or_password, options \\ []) + + def new(token, scopes, options) + when (is_binary(token) or is_function(token, 1) or is_tuple(token)) and is_list(scopes) do + options + |> Keyword.merge(token: token, token_scopes: scopes) + |> new() + end + + def new(username, password, options) when is_binary(username) and is_binary(password) do + options + |> Keyword.merge(username: username, password: password) + |> new() + end + + @doc """ + Returns fully configured middleware for passing to Tesla.client/2. + """ + @spec middleware(options) :: [Tesla.Client.middleware()] + def middleware(options \\ []) do + base_url = + Keyword.get( + options, + :base_url, + Application.get_env(:openapi_petstore, :base_url, @default_base_url) + ) + + tesla_options = Application.get_env(:tesla, __MODULE__, []) + middleware = Keyword.get(tesla_options, :middleware, []) + json_engine = Keyword.get(tesla_options, :json, Poison) + + user_agent = + Keyword.get( + options, + :user_agent, + Keyword.get( + tesla_options, + :user_agent, + "openapi-generator - OpenapiPetstore 1.0.0 - elixir" + ) + ) + + username = Keyword.get(options, :username) + password = Keyword.get(options, :password) + middleware = + if username || password do + [{Tesla.Middleware.BasicAuth, %{username: username, password: password}} | middleware] + else + middleware + end + + middleware = + if token = Keyword.get(options, :token) do + scopes = Keyword.get(options, :token_scopes, @default_scopes) + [authorization(token, scopes) | middleware] + else + middleware + end + + [ + {Tesla.Middleware.BaseUrl, base_url}, + {Tesla.Middleware.Headers, [{"user-agent", user_agent}]}, + {Tesla.Middleware.EncodeJson, engine: json_engine} + | middleware + ] + end + + @doc """ + Returns an authentication middleware tuple for a Tesla client that sets + the `authorization` header to the value of the provided bearer token. If + the token is provided as a function of arity one, it will be called with + a list of requested scopes that will obtain an OAuth2 token. + + ### Parameters + + - `token`: a String or a function of arity one. This value, or the result + of the function call, will be set as a bearer token in the + `authorization` header. + + - `scopes`: an optional list of scopes for use with the token fetcher + function. Ignored when `token` is provided as a String. Defaults to + `#{inspect(@default_scopes)}`. + + ### Returns + + `{Tesla.Middleware.Headers, [{"authorization", TOKEN}]}` + """ + @spec authorization(String.t() | token_fetcher, list(String.t())) :: + Tesla.Client.middleware() + def authorization(token, scopes \\ @default_scopes) + + def authorization(token, _scopes) when is_binary(token) do + {Tesla.Middlware.Headers, ["authorization", token]} + end + + def authorization({module, function}, scopes) when is_atom(module) and is_atom(function) do + apply(module, function, [scopes]) + end + + def authorization(token_fetcher, scopes) when is_function(token_fetcher, 1) do + authorization(token_fetcher.(scopes)) + end + + @doc """ + Returns the default adapter for this API. + """ + def adapter do + :tesla + |> Application.get_env(__MODULE__, []) + |> Keyword.get(:adapter, nil) end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex b/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex index e5e927f1fa..5f936c0b87 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/deserializer.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Deserializer do @moduledoc """ @@ -15,24 +14,33 @@ defmodule OpenapiPetstore.Deserializer do model |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: [struct(mod)]])))) end + def deserialize(model, field, :struct, mod, options) do model |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: struct(mod)])))) end + def deserialize(model, field, :map, mod, options) do model - |> Map.update!(field, &(Map.new(&1, fn {key, val} -> {key, Poison.Decode.decode(val, Keyword.merge(options, [as: struct(mod)]))} end))) + |> Map.update!( + field, + &Map.new(&1, fn {key, val} -> + {key, Poison.Decode.decode(val, Keyword.merge(options, [as: struct(mod)]))} + end) + ) end + def deserialize(model, field, :date, _, _options) do value = Map.get(model, field) case is_binary(value) do - true -> case DateTime.from_iso8601(value) do - {:ok, datetime, _offset} -> - Map.put(model, field, datetime) - _ -> - model - end - false -> model + true -> + case DateTime.from_iso8601(value) do + {:ok, datetime, _offset} -> Map.put(model, field, datetime) + _ -> model + end + + false -> + model end end end diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex index c48a99b52e..f186cbe2a7 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/_foo_get_default_response.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.FooGetDefaultResponse do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex index 429129b42a..9b93c10b78 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/_special_model_name_.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.SpecialModelName do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex index 722af9396b..22fee7ce15 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/additional_properties_class.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.AdditionalPropertiesClass do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex index eaef9cbfcf..ba71da5d83 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/all_of_with_single_ref.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.AllOfWithSingleRef do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex index 2457f9dca1..1791a9282b 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/animal.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Animal do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex index 5df3e445eb..8148918b99 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/api_response.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ApiResponse do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex index d0312d28ca..6d0d358646 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_array_of_number_only.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ArrayOfArrayOfNumberOnly do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex index 770c78e85a..c00729e351 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_of_number_only.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ArrayOfNumberOnly do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex index 0314a88325..d78d568bef 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/array_test.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ArrayTest do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex index 23e25dfa36..b80cca4553 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/capitalization.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Capitalization do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex index d3281a7ac1..5ad36e3d53 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/cat.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Cat do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/cat_all_of.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/cat_all_of.ex index 6935c289a0..f7074447b7 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/cat_all_of.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/cat_all_of.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.CatAllOf do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex index 678b66a070..c73610ee8d 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/category.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Category do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex index ba41186048..9e081c31c0 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/class_model.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ClassModel do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex index 6ef6dddec0..1969a60266 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/client.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Client do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_object.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_object.ex index 0fd11a2a22..e214eed74e 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_object.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/deprecated_object.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.DeprecatedObject do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex index 567f056d8e..4306585c8c 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/dog.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Dog do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/dog_all_of.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/dog_all_of.ex index 5898abad3d..f459cac8cb 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/dog_all_of.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/dog_all_of.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.DogAllOf do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex index 28f27eb79d..2cc1054eb2 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_arrays.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.EnumArrays do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex index 784588422e..c979757a00 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_class.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.EnumClass do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex index 1af76bedb3..bb3126dc99 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/enum_test.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.EnumTest do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex index 659a4b26ec..cbd8b13aa5 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/file.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.File do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex index 9edcf4f8a0..dec0f5786b 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/file_schema_test_class.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.FileSchemaTestClass do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex index b25263be9a..2e53dc8336 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/foo.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Foo do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex index 6dafb14d70..f87e35c3d4 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/format_test.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.FormatTest do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex index c8bf68f5b2..def6458b25 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/has_only_read_only.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.HasOnlyReadOnly do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex index 339a5fe876..82f2db2fa2 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/health_check_result.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.HealthCheckResult do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex index b37fab3f46..7ea571733b 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/list.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.List do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex index 6d94cf83c1..b0503ebc25 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/map_test.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.MapTest do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex index a8e4981cd3..9527792cfc 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/mixed_properties_and_additional_properties_class.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex index 3fbd1067f7..e68e7729ac 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/model_200_response.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Model200Response do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex index 42d93796dd..bdf258674f 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/name.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Name do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex index 45174fd475..a4dfb5182e 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/nullable_class.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.NullableClass do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex index 5658d13314..d1a50d43eb 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/number_only.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.NumberOnly do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex index a3f5cc4a53..70b97c24e6 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/object_with_deprecated_fields.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ObjectWithDeprecatedFields do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex index 0b430ca41c..7e3b45a2b8 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/order.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Order do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex index abacaa6d85..f1032a3566 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_composite.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.OuterComposite do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex index 5e9ce9d276..f8fe24d03c 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.OuterEnum do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex index 8c890fef50..3a63d0de01 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_default_value.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.OuterEnumDefaultValue do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex index 5130ca77d2..f7c6139452 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.OuterEnumInteger do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex index 33160c1679..40da8a07a0 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_enum_integer_default_value.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.OuterEnumIntegerDefaultValue do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex index 23502200bf..885ce63df9 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/outer_object_with_enum_property.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.OuterObjectWithEnumProperty do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex index 046e5bee22..a97c69d0f5 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/pet.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Pet do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex index 6f36aba467..05a59cb92e 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/read_only_first.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.ReadOnlyFirst do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex index 54b3cbf391..44f2ddd6be 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/return.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Return do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex index d2a17aa740..f69d46d4c5 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/single_ref_type.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.SingleRefType do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex index f64ba461a3..b2209758f3 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/tag.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.Tag do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex b/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex index 368e3f52a3..eea7eb439f 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/model/user.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.Model.User do @moduledoc """ diff --git a/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex b/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex index 2488ab80c7..18b2673740 100644 --- a/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex +++ b/samples/client/petstore/elixir/lib/openapi_petstore/request_builder.ex @@ -1,6 +1,5 @@ -# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). -# https://openapi-generator.tech -# Do not edit the class manually. +# NOTE: This file is auto generated by OpenAPI Generator 6.1.0-SNAPSHOT (https://openapi-generator.tech). +# Do not edit this file manually. defmodule OpenapiPetstore.RequestBuilder do @moduledoc """ @@ -8,113 +7,130 @@ defmodule OpenapiPetstore.RequestBuilder do """ @doc """ - Specify the request method when building a request + Specify the request `method` when building a request. - ## Parameters + Does not override the `method` if one has already been specified. - - request (Map) - Collected request options - - m (atom) - Request method + ### Parameters - ## Returns + - `request` (Map) - Collected request options + - `method` (atom) - Request method + + ### Returns Map """ - @spec method(map(), atom) :: map() - def method(request, m) do - Map.put_new(request, :method, m) + @spec method(map(), atom()) :: map() + def method(request, method) do + Map.put_new(request, :method, method) end @doc """ - Specify the request method when building a request + Specify the request URL when building a request. - ## Parameters + Does not override the `url` if one has already been specified. - - request (Map) - Collected request options - - u (String) - Request URL + ### Parameters - ## Returns + - `request` (Map) - Collected request options + - `url` (String) - Request URL + + ### Returns Map """ - @spec url(map(), String.t) :: map() - def url(request, u) do - Map.put_new(request, :url, u) + @spec url(map(), String.t()) :: map() + def url(request, url) do + Map.put_new(request, :url, url) end @doc """ - Add optional parameters to the request + Add optional parameters to the request. - ## Parameters + ### Parameters - - request (Map) - Collected request options - - definitions (Map) - Map of parameter name to parameter location. - - options (KeywordList) - The provided optional parameters + - `request` (Map) - Collected request options + - `definitions` (Map) - Map of parameter name to parameter location. + - `options` (KeywordList) - The provided optional parameters - ## Returns + ### Returns Map """ - @spec add_optional_params(map(), %{optional(atom) => atom}, keyword()) :: map() + @spec add_optional_params(map(), %{optional(atom) => atom()}, keyword()) :: map() def add_optional_params(request, _, []), do: request + def add_optional_params(request, definitions, [{key, value} | tail]) do case definitions do %{^key => location} -> request |> add_param(location, key, value) |> add_optional_params(definitions, tail) + _ -> add_optional_params(request, definitions, tail) end end @doc """ - Add optional parameters to the request + Add non-optional parameters to the request. - ## Parameters + ### Parameters - - request (Map) - Collected request options - - location (atom) - Where to put the parameter - - key (atom) - The name of the parameter - - value (any) - The value of the parameter + - `request` (Map) - Collected request options + - `location` (atom) - Where to put the parameter + - `key` (atom) - The name of the parameter + - `value` (any) - The value of the parameter - ## Returns + ### Returns Map """ - @spec add_param(map(), atom, atom, any()) :: map() + @spec add_param(map(), atom(), atom(), any()) :: map() def add_param(request, :body, :body, value), do: Map.put(request, :body, value) + def add_param(request, :body, key, value) do request |> Map.put_new_lazy(:body, &Tesla.Multipart.new/0) - |> Map.update!(:body, &(Tesla.Multipart.add_field(&1, key, Poison.encode!(value), headers: [{:"Content-Type", "application/json"}]))) + |> Map.update!(:body, fn multipart -> + Tesla.Multipart.add_field( + multipart, + key, + Poison.encode!(value), + headers: [{:"Content-Type", "application/json"}] + ) + end) end + def add_param(request, :headers, key, value) do - request - |> Tesla.put_header(key, value) + Tesla.put_header(request, key, value) end + def add_param(request, :file, name, path) do request |> Map.put_new_lazy(:body, &Tesla.Multipart.new/0) |> Map.update!(:body, &(Tesla.Multipart.add_file(&1, path, name: name))) end + def add_param(request, :form, name, value) do - request - |> Map.update(:body, %{name => value}, &(Map.put(&1, name, value))) + Map.update(request, :body, %{name => value}, &(Map.put(&1, name, value))) end + def add_param(request, location, key, value) do Map.update(request, location, [{key, value}], &(&1 ++ [{key, value}])) end @doc """ - Due to a bug in httpc, POST, PATCH and PUT requests will fail, if the body is empty + This function ensures that the `body` parameter is always set. - This function will ensure, that the body param is always set + When using Tesla with the `httpc` adapter (the default adapter), there is a + bug where POST, PATCH and PUT requests will fail if the body is empty. - ## Parameters + ### Parameters - - request (Map) - Collected request options + - `request` (Map) - Collected request options - ## Returns + ### Returns Map """ @@ -127,39 +143,44 @@ defmodule OpenapiPetstore.RequestBuilder do Map.put_new(request, :body, "") end + @type status_code :: 100..599 + @type response_mapping :: [{status_code, struct() | false}] + @doc """ - Handle the response for a Tesla request + Evaluate the response from a Tesla request. + Decode the response for a Tesla request. - ## Parameters + ### Parameters - - arg1 (Tesla.Env.t | term) - The response object - - arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into + - `result` (Tesla.Env.result()): The response from Tesla.request/2. + - `mapping` ([{http_status, struct}]): The mapping for status to struct for decoding. - ## Returns + ### Returns - {:ok, struct} on success - {:error, term} on failure + - `{:ok, struct}` or `{:ok, Tesla.Env.t()}` on success + - `{:error, term}` on failure """ - @spec decode(Tesla.Env.t() | term(), false | struct() | [struct()]) :: - {:ok, struct()} | {:ok, Tesla.Env.t()} | {:error, any} - def decode(%Tesla.Env{} = env, false), do: {:ok, env} - def decode(%Tesla.Env{body: body}, struct), do: Poison.decode(body, as: struct) - + @spec evaluate_response(Tesla.Env.result(), response_mapping) :: {:ok, struct()} | Tesla.Env.result() def evaluate_response({:ok, %Tesla.Env{} = env}, mapping) do - resolve_mapping(env, mapping) + resolve_mapping(env, mapping, nil) end def evaluate_response({:error, _} = error, _), do: error - def resolve_mapping(env, mapping, default \\ nil) - - def resolve_mapping(%Tesla.Env{status: status} = env, [{mapping_status, struct} | _], _) + defp resolve_mapping(%Tesla.Env{status: status} = env, [{mapping_status, struct} | _], _) when status == mapping_status do decode(env, struct) end - def resolve_mapping(env, [{:default, struct} | tail], _), do: resolve_mapping(env, tail, struct) - def resolve_mapping(env, [_ | tail], struct), do: resolve_mapping(env, tail, struct) - def resolve_mapping(env, [], nil), do: {:error, env} - def resolve_mapping(env, [], struct), do: decode(env, struct) + defp resolve_mapping(env, [{:default, struct} | tail], _), do: resolve_mapping(env, tail, struct) + + defp resolve_mapping(env, [_ | tail], struct), do: resolve_mapping(env, tail, struct) + + defp resolve_mapping(env, [], nil), do: {:error, env} + + defp resolve_mapping(env, [], struct), do: decode(env, struct) + + defp decode(%Tesla.Env{} = env, false), do: {:ok, env} + + defp decode(%Tesla.Env{body: body}, struct), do: Poison.decode(body, as: struct) end diff --git a/samples/client/petstore/elixir/mix.exs b/samples/client/petstore/elixir/mix.exs index c03b200a50..d7f7fae688 100644 --- a/samples/client/petstore/elixir/mix.exs +++ b/samples/client/petstore/elixir/mix.exs @@ -2,14 +2,16 @@ defmodule OpenapiPetstore.Mixfile do use Mix.Project def project do - [app: :openapi_petstore, - version: "1.0.0", - elixir: "~> 1.10", - build_embedded: Mix.env == :prod, - start_permanent: Mix.env == :prod, - package: package(), - description: "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\", - deps: deps()] + [ + app: :openapi_petstore, + version: "1.0.0", + elixir: "~> 1.10", + build_embedded: Mix.env() == :prod, + start_permanent: Mix.env() == :prod, + package: package(), + description: "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\", + deps: deps() + ] end # Configuration for the OTP application @@ -37,11 +39,10 @@ defmodule OpenapiPetstore.Mixfile do ] end - defp package() do - [ - name: "openapi_petstore", - files: ~w(.formatter.exs config lib mix.exs README* LICENSE*), - licenses: [""] - ] + defp package do + [ + name: "openapi_petstore", + files: ~w(.formatter.exs config lib mix.exs README* LICENSE*), + ] end end