mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-03-10 08:31:23 +00:00
Further Elixir Client Improvements (#12775)
* Further Elixir Client Improvements Resolves #12731 and is the completion of the work that I started with #12751. The changes here are extensive and likely resolve an issue that I have seen with the Ory SDK (ory/sdk#194). I have also been unable to run the integration suite for Elixir as I am (trying) to run everything in Docker (`./run-in-docker.sh`) as I *do not* have a suitable Java development environment set up, and do not do enough Java work to really justify it. - Updated the README for Elixir projects. Aside from some improved readability of the template by use of link references instead of inline links, I have also fixed the examples: - The `deps` example should have been putting a version constraint related to `appVersion`. - The `config` example should have been using `packageName` instead of `appName`. This particular issue repeats. - In all Elixir files: - Changed the function `@docs` formatting: - changed the ehading level for `Parameters` and `Returns` to h3 (`###` instead of `##`). This will make somewhat better looking documentation that does not over-emphasize these details (which are *not* documented in a normal Elixir way, but this is somewhat to be expected with a code generator.) It may be desirable, after testing, to change this to `h4` instead of `h3`. - Put parameter names and most return types in in-line code blocks (`` `hello` ``). - Put return types, when there are multiple types, in a Markdown list. - Fixed a lot of the spacing. Most files will be *closer* to Elixir standard formatting than they were. Because of the limitations of Mustache, it is still recommended that people who generate Elixir clients run `mix format` at least once on their codebase. - `api.mustache`: - Removed an awkward function pipeline call. If we specified at least Elixir 1.12 (something that I do not recommend as we have recently jumped from requiring Elixir 1.6 to Elixir 1.10), there is a better way to specify this now with `Kernel.then/2`. In the meantime, assigning the constructed request structure to a variable and then making a separate pipeline for the request execution and handling makes for *much* easier to read generated code. - Fixed the extra space issue with `evaluate_response` call tuple values; `{{=<% %>=}}` changes the tag types, so this change is intentional. - In `config.exs.mustache`, `runtime.exs.mustache`, `mix.exs.mustache`, and `connection.ex.mustache`, use `packageName` instead of `appName` for configuration specification. If `packageName` and `appName` differed, we would end up with cases like ory/sdk#194. - `connection.ex.mustache` has been almost entirely rewritten. The changes started in order to eliminate a `@doc` compile-time warning, but shifted to remove the old way of building Tesla client structs with `use Tesla`. It works, but is no longer the recommended way of building Tesla clients. - The *recommended* way of building a Tesla Client would now be `Tesla.client(Connection.middleware(), Connection.adapter())`. - Exposed both `Connection.adapter/0` and `Connection.middleware/1` for use. `Connection.middleware/1` has special handling for the cases where OAuth2 or HTTP Basic Auth are defined in the application, but do not currently handle any other auth methods. - `deserializer.ex.mustache` has mostly been reformatted. There are things that I do not like about it (I do not like pipelines with one line), and I have expanded one function capture into an anonymous function for readability. - `request_builder.ex.mustache` has been updated with better function and parameter descriptions and names. Please note that if `request |> method(:delete) |> method(:post)` is supposed to produce a `POST` operation, we will need to change from `Map.put_new/3` to `Map.put/3`. - Reordered `evaluate_response/2` so that it is the function documented, and made `decode/2` and `response_mapping/3` private functions. As far as I can tell, I have *not* changed the functionality. * Address issues found in code review - The example dependency code in the README had dropped the opening brace for the tuple. This has been resolved. - The default formatting of the API pipelines has been adjusted to minimize possible changes from `mix format`. * Update modules/openapi-generator/src/main/resources/elixir/api.mustache Co-authored-by: Michael Ramstein <633688+mrmstn@users.noreply.github.com> * Update modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache Co-authored-by: Michael Ramstein <633688+mrmstn@users.noreply.github.com> * Update modules/openapi-generator/src/main/resources/elixir/connection.ex.mustache Co-authored-by: Michael Ramstein <633688+mrmstn@users.noreply.github.com> * Update templates based on review comments Co-authored-by: Michael Ramstein <633688+mrmstn@users.noreply.github.com>
This commit is contained in:
@@ -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}}}"
|
||||
```
|
||||
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}}
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,3 +18,6 @@ erl_crash.dump
|
||||
|
||||
# Also ignore archive artifacts (built via "mix archive.build").
|
||||
*.ez
|
||||
|
||||
# Ignore elixir LS
|
||||
/.elixir_ls
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
3
samples/client/petstore/elixir/.gitignore
vendored
3
samples/client/petstore/elixir/.gitignore
vendored
@@ -18,3 +18,6 @@ erl_crash.dump
|
||||
|
||||
# Also ignore archive artifacts (built via "mix archive.build").
|
||||
*.ez
|
||||
|
||||
# Ignore elixir LS
|
||||
/.elixir_ls
|
||||
|
||||
@@ -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"
|
||||
```
|
||||
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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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 """
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user