forked from loafle/openapi-generator-original
[Elixir] Deserialize responses based on status code (#2355)
* Update Tesla dependency and replace Poison with Jason * Use new Tesla method to set headers * Fix jason dependency definition * Use list for Headers instead of a map * Rollback to Poison because Jason does not support 'as:' option to decode to arbitrary struct * Use new return signature from Tesla 1.0 in decode function * catch error when a struct is given as second parameter to RequestBuilder.decode * Update modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache Co-Authored-By: yknx4 <yknx.4.b@gmail.com> * Update modules/openapi-generator/src/main/resources/elixir/request_builder.ex.mustache Co-Authored-By: yknx4 <yknx.4.b@gmail.com> * Evaluate response based on status code * Generate Petstore * pin poison to ~> 3.0.0 since 4.0.0 does not work atm * run ./bin/openapi3/elixir-petstore.sh
This commit is contained in:
parent
37c275b3fb
commit
49f3e9a355
@ -23,6 +23,7 @@ import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@ -53,7 +54,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
List<String> extraApplications = Arrays.asList(":logger");
|
||||
List<String> deps = Arrays.asList(
|
||||
"{:tesla, \"~> 1.0.0\"}",
|
||||
"{:poison, \">= 1.0.0\"}"
|
||||
"{:poison, \"~> 3.0.0\"}"
|
||||
);
|
||||
|
||||
public ElixirClientCodegen() {
|
||||
@ -310,6 +311,11 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return new ExtendedCodegenModel(cm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenResponse fromResponse(String responseCode, ApiResponse resp) {
|
||||
return new ExtendedCodegenResponse(super.fromResponse(responseCode, resp));
|
||||
}
|
||||
|
||||
// We should use String.join if we can use Java8
|
||||
String join(CharSequence charSequence, Iterable<String> iterable) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
@ -515,6 +521,91 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
class ExtendedCodegenResponse extends CodegenResponse {
|
||||
public boolean isDefinedDefault;
|
||||
|
||||
public ExtendedCodegenResponse(CodegenResponse o) {
|
||||
super();
|
||||
|
||||
this.headers.addAll(o.headers);
|
||||
this.code = o.code;
|
||||
this.message = o.message;
|
||||
this.hasMore = o.hasMore;
|
||||
this.examples = o.examples;
|
||||
this.dataType = o.dataType;
|
||||
this.baseType = o.baseType;
|
||||
this.containerType = o.containerType;
|
||||
this.hasHeaders = o.hasHeaders;
|
||||
this.isString = o.isString;
|
||||
this.isNumeric = o.isNumeric;
|
||||
this.isInteger = o.isInteger;
|
||||
this.isLong = o.isLong;
|
||||
this.isNumber = o.isNumber;
|
||||
this.isFloat = o.isFloat;
|
||||
this.isDouble = o.isDouble;
|
||||
this.isByteArray = o.isByteArray;
|
||||
this.isBoolean = o.isBoolean;
|
||||
this.isDate = o.isDate;
|
||||
this.isDateTime = o.isDateTime;
|
||||
this.isUuid = o.isUuid;
|
||||
this.isEmail = o.isEmail;
|
||||
this.isModel = o.isModel;
|
||||
this.isFreeFormObject = o.isFreeFormObject;
|
||||
this.isDefault = o.isDefault;
|
||||
this.simpleType = o.simpleType;
|
||||
this.primitiveType = o.primitiveType;
|
||||
this.isMapContainer = o.isMapContainer;
|
||||
this.isListContainer = o.isListContainer;
|
||||
this.isBinary = o.isBinary;
|
||||
this.isFile = o.isFile;
|
||||
this.schema = o.schema;
|
||||
this.jsonSchema = o.jsonSchema;
|
||||
this.vendorExtensions = o.vendorExtensions;
|
||||
|
||||
this.isDefinedDefault = (this.code.equals("0") || this.code.equals("default"));
|
||||
}
|
||||
|
||||
public String codeMappingKey(){
|
||||
if(this.isDefinedDefault) {
|
||||
return ":default";
|
||||
}
|
||||
|
||||
if(code.matches("^\\d{3}$")){
|
||||
return code;
|
||||
}
|
||||
|
||||
LOGGER.warn("Unknown HTTP status code: " + this.code);
|
||||
return "\"" + code + "\"";
|
||||
}
|
||||
|
||||
public String decodedStruct() {
|
||||
// Let Poison decode the entire response into a generic blob
|
||||
if (isMapContainer) {
|
||||
return "%{}";
|
||||
}
|
||||
// Primitive return type, don't even try to decode
|
||||
if (baseType == null || (simpleType && primitiveType)) {
|
||||
return "false";
|
||||
} else if (isListContainer && languageSpecificPrimitives().contains(baseType)) {
|
||||
return "[]";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (isListContainer) {
|
||||
sb.append("[");
|
||||
}
|
||||
sb.append("%");
|
||||
sb.append(moduleName);
|
||||
sb.append(".Model.");
|
||||
sb.append(baseType);
|
||||
sb.append("{}");
|
||||
if (isListContainer) {
|
||||
sb.append("]");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ExtendedCodegenOperation extends CodegenOperation {
|
||||
private List<String> pathTemplateNames = new ArrayList<String>();
|
||||
private String replacedPathName;
|
||||
@ -688,32 +779,6 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
sb.append(".t");
|
||||
}
|
||||
}
|
||||
|
||||
public String decodedStruct() {
|
||||
// Let Poison decode the entire response into a generic blob
|
||||
if (isMapContainer) {
|
||||
return "";
|
||||
}
|
||||
// Primitive return type, don't even try to decode
|
||||
if (returnBaseType == null || (returnSimpleType && returnTypeIsPrimitive)) {
|
||||
return "false";
|
||||
} else if (isListContainer && languageSpecificPrimitives().contains(returnBaseType)) {
|
||||
return "[]";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (isListContainer) {
|
||||
sb.append("[");
|
||||
}
|
||||
sb.append("%");
|
||||
sb.append(moduleName);
|
||||
sb.append(".Model.");
|
||||
sb.append(returnBaseType);
|
||||
sb.append("{}");
|
||||
if (isListContainer) {
|
||||
sb.append("]");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class ExtendedCodegenModel extends CodegenModel {
|
||||
|
@ -12,21 +12,21 @@ defmodule {{moduleName}}.Api.{{classname}} do
|
||||
|
||||
@doc """
|
||||
{{#summary}}
|
||||
{{summary}}
|
||||
{{&summary}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
{{notes}}
|
||||
{{¬es}}
|
||||
{{/notes}}
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection ({{moduleName}}.Connection): Connection to server
|
||||
{{#requiredParams}}
|
||||
- {{#underscored}}{{paramName}}{{/underscored}} ({{dataType}}): {{description}}
|
||||
- {{#underscored}}{{paramName}}{{/underscored}} ({{dataType}}): {{&description}}
|
||||
{{/requiredParams}}
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
{{#optionalParams}}
|
||||
- {{#underscored}}:{{paramName}}{{/underscored}} ({{dataType}}): {{description}}
|
||||
- {{#underscored}}:{{paramName}}{{/underscored}} ({{dataType}}): {{&description}}
|
||||
{{/optionalParams}}
|
||||
## Returns
|
||||
|
||||
@ -59,7 +59,10 @@ defmodule {{moduleName}}.Api.{{classname}} do
|
||||
{{/optionalParams}}
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode({{decodedStruct}})
|
||||
|> evaluate_response({{#responses}}{{#-first}}[
|
||||
{{/-first}}
|
||||
{ {{& codeMappingKey}}, {{decodedStruct}}}{{#hasMore}},{{/hasMore}}
|
||||
{{#-last}} ]{{/-last}}{{/responses}})
|
||||
end
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
@ -107,7 +107,7 @@ defmodule {{moduleName}}.RequestBuilder do
|
||||
|
||||
## Parameters
|
||||
|
||||
- arg1 ({:ok, Tesla.Env.t} | term) - The response object
|
||||
- arg1 (Tesla.Env.t | term) - The response object
|
||||
- arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into
|
||||
|
||||
## Returns
|
||||
@ -115,16 +115,26 @@ defmodule {{moduleName}}.RequestBuilder do
|
||||
{:ok, struct} on success
|
||||
{:error, term} on failure
|
||||
"""
|
||||
@spec decode({:ok, Tesla.Env.t} | term()) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()}
|
||||
def decode({:ok, %Tesla.Env{status: 200, body: body}}), do: Poison.decode(body)
|
||||
def decode(response), do: {:error, response}
|
||||
def decode({:error, _} = error), do: error
|
||||
def decode(response), do: {:error, response}
|
||||
@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 decode({:ok, Tesla.Env.t} | term(), :false | struct() | [struct()]) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()}
|
||||
def decode({:ok, %Tesla.Env{status: 200}} = env, false), do: {:ok, env}
|
||||
def decode({:ok, %Tesla.Env{status: 200, body: body}}, struct), do: Poison.decode(body, as: struct)
|
||||
def decode({:ok, %Tesla.Env{} = response}, _struct), do: {:error, response}
|
||||
def decode({:error, _} = error, _struct), do: error
|
||||
def decode(response, _struct), do: {:error, response}
|
||||
def evaluate_response({:ok, %Tesla.Env{} = env}, mapping) do
|
||||
resolve_mapping(env, mapping)
|
||||
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} | _], _)
|
||||
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)
|
||||
end
|
||||
|
@ -1 +1 @@
|
||||
3.3.4-SNAPSHOT
|
||||
4.0.0-SNAPSHOT
|
@ -1,18 +1,18 @@
|
||||
# OpenapiPetstore
|
||||
# OpenAPIPetstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
## 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`:
|
||||
by adding `open_api_petstore` to your list of dependencies in `mix.exs`:
|
||||
|
||||
```elixir
|
||||
def deps do
|
||||
[{:openapi_petstore, "~> 0.1.0"}]
|
||||
[{:open_api_petstore, "~> 0.1.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).
|
||||
be found at [https://hexdocs.pm/open_api_petstore](https://hexdocs.pm/open_api_petstore).
|
||||
|
@ -0,0 +1,40 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.AnotherFake do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `AnotherFake`.
|
||||
"""
|
||||
|
||||
alias OpenAPIPetstore.Connection
|
||||
import OpenAPIPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
To test special tags
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- client (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.Client{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.Client{}}
|
||||
])
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.Default do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `Default`.
|
||||
"""
|
||||
|
||||
alias OpenAPIPetstore.Connection
|
||||
import OpenAPIPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.InlineResponseDefault{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec foo_get(Tesla.Env.client, keyword()) :: {:ok, OpenAPIPetstore.Model.InlineResponseDefault.t} | {:error, Tesla.Env.t}
|
||||
def foo_get(connection, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:get)
|
||||
|> url("/foo")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ :default, %OpenAPIPetstore.Model.InlineResponseDefault{}}
|
||||
])
|
||||
end
|
||||
end
|
429
samples/client/petstore/elixir/lib/open_api_petstore/api/fake.ex
Normal file
429
samples/client/petstore/elixir/lib/open_api_petstore/api/fake.ex
Normal file
@ -0,0 +1,429 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.Fake do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `Fake`.
|
||||
"""
|
||||
|
||||
alias OpenAPIPetstore.Connection
|
||||
import OpenAPIPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
Health check endpoint
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.HealthCheckResult{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.HealthCheckResult{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Test serialization of outer boolean types
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (boolean()): Input boolean as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.boolean(){}} on success
|
||||
{:error, info} 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)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Test serialization of object with outer number type
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :outer_composite (OuterComposite): Input composite as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.OuterComposite{}} on success
|
||||
{:error, info} 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 = %{
|
||||
:"OuterComposite" => :body
|
||||
}
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/fake/outer/composite")
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.OuterComposite{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Test serialization of outer number types
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (float()): Input number as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.float(){}} on success
|
||||
{:error, info} 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)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Test serialization of outer string types
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (String.t): Input string as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.String.t{}} on success
|
||||
{:error, info} 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)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
For this test, the body for this request much reference a schema named `File`.
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- file_schema_test_class (FileSchemaTestClass):
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- query (String.t):
|
||||
- user (User):
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
To test \"client\" model
|
||||
To test \"client\" model
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- client (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.Client{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.Client{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
Fake endpoint for testing various 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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
|
||||
optional_params = %{
|
||||
:"integer" => :form,
|
||||
:"int32" => :form,
|
||||
:"int64" => :form,
|
||||
:"float" => :form,
|
||||
:"string" => :form,
|
||||
:"binary" => :form,
|
||||
:"date" => :form,
|
||||
:"dateTime" => :form,
|
||||
:"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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
To test enum parameters
|
||||
To test enum 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_form_string_array ([String.t]): Form parameter enum test (string array)
|
||||
- :enum_form_string (String.t): Form parameter enum test (string)
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec test_enum_parameters(Tesla.Env.client, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def test_enum_parameters(connection, opts \\ []) do
|
||||
optional_params = %{
|
||||
:"enum_header_string_array" => :headers,
|
||||
:"enum_header_string" => :headers,
|
||||
:"enum_query_string_array" => :query,
|
||||
:"enum_query_string" => :query,
|
||||
:"enum_query_integer" => :query,
|
||||
:"enum_query_double" => :query,
|
||||
:"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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Fake endpoint to test group parameters (optional)
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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
|
||||
optional_params = %{
|
||||
:"string_group" => :query,
|
||||
:"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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
test inline additionalProperties
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- request_body (%{optional(String.t) => String.t}): request body
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
test json serialization of form data
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- param (String.t): field1
|
||||
- param2 (String.t): field2
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
end
|
@ -0,0 +1,40 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.FakeClassnameTags123 do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `FakeClassnameTags123`.
|
||||
"""
|
||||
|
||||
alias OpenAPIPetstore.Connection
|
||||
import OpenAPIPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
To test class name in snake case
|
||||
To test class name in snake case
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- client (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.Client{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.Client{}}
|
||||
])
|
||||
end
|
||||
end
|
277
samples/client/petstore/elixir/lib/open_api_petstore/api/pet.ex
Normal file
277
samples/client/petstore/elixir/lib/open_api_petstore/api/pet.ex
Normal file
@ -0,0 +1,277 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.Pet do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `Pet`.
|
||||
"""
|
||||
|
||||
alias OpenAPIPetstore.Connection
|
||||
import OpenAPIPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
Add a new pet to the store
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 405, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deletes a pet
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- pet_id (integer()): Pet id to delete
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :api_key (String.t):
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Finds Pets by status
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, [%Pet{}, ...]} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec find_pets_by_status(Tesla.Env.client, list(String.t), keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, [%OpenAPIPetstore.Model.Pet{}]},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Finds Pets by tags
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- tags ([String.t]): Tags to filter by
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, [%Pet{}, ...]} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec find_pets_by_tags(Tesla.Env.client, list(String.t), keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, [%OpenAPIPetstore.Model.Pet{}]},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Find pet by ID
|
||||
Returns a single pet
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- pet_id (integer()): ID of pet to return
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.Pet{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec get_pet_by_id(Tesla.Env.client, integer(), keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.Pet{}},
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Update an existing pet
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false},
|
||||
{ 405, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Updates a pet in the store with form data
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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
|
||||
optional_params = %{
|
||||
:"name" => :form,
|
||||
:"status" => :form
|
||||
}
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/pet/#{pet_id}")
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 405, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
uploads an image
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.ApiResponse{}} on success
|
||||
{:error, info} 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
|
||||
optional_params = %{
|
||||
:"additionalMetadata" => :form,
|
||||
:"file" => :form
|
||||
}
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/pet/#{pet_id}/uploadImage")
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.ApiResponse{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
uploads an image (required)
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.ApiResponse{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.ApiResponse{}}
|
||||
])
|
||||
end
|
||||
end
|
@ -0,0 +1,120 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.Store do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `Store`.
|
||||
"""
|
||||
|
||||
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
|
||||
|
||||
- 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns pet inventories by status
|
||||
Returns a map of status codes to quantities
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Find purchase order by ID
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- order_id (integer()): ID of pet that needs to be fetched
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.Order{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec get_order_by_id(Tesla.Env.client, integer(), keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.Order{}},
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Place an order for a pet
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- order (Order): order placed for purchasing the pet
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.Order{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec place_order(Tesla.Env.client, OpenAPIPetstore.Model.Order.t, keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.Order{}},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
end
|
228
samples/client/petstore/elixir/lib/open_api_petstore/api/user.ex
Normal file
228
samples/client/petstore/elixir/lib/open_api_petstore/api/user.ex
Normal file
@ -0,0 +1,228 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Api.User do
|
||||
@moduledoc """
|
||||
API calls for all endpoints tagged `User`.
|
||||
"""
|
||||
|
||||
alias OpenAPIPetstore.Connection
|
||||
import OpenAPIPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
Create user
|
||||
This can only be done by the logged in user.
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- user (User): Created user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Creates list of users with given input array
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- user ([User]): List of user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Creates list of users with given input array
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- user ([User]): List of user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Delete user
|
||||
This can only be done by the logged in user.
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- username (String.t): The name that needs to be deleted
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Get user by user name
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.User{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec get_user_by_name(Tesla.Env.client, String.t, keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenAPIPetstore.Model.User{}},
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Logs user into the system
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %OpenAPIPetstore.Model.String.t{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec login_user(Tesla.Env.client, String.t, String.t, keyword()) :: {: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)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Logs out current logged in user session
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenAPIPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Updated user
|
||||
This can only be done by the logged in user.
|
||||
|
||||
## 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
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} 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)).()
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
end
|
@ -0,0 +1,104 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Connection do
|
||||
@moduledoc """
|
||||
Handle Tesla connections for OpenAPIPetstore.
|
||||
"""
|
||||
|
||||
use Tesla
|
||||
|
||||
# Add any middleware here (authentication)
|
||||
plug Tesla.Middleware.BaseUrl, "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.build_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.build_client([
|
||||
{Tesla.Middleware.BasicAuth, %{username: username, password: password}}
|
||||
])
|
||||
end
|
||||
@scopes [
|
||||
"write:pets", # modify pets in your account
|
||||
"read:pets" # read your pets
|
||||
]
|
||||
|
||||
@doc """
|
||||
Configure a client connection using a provided OAuth2 token as a Bearer token
|
||||
|
||||
## Parameters
|
||||
|
||||
- token (String): Bearer token
|
||||
|
||||
## Returns
|
||||
|
||||
Tesla.Env.client
|
||||
"""
|
||||
@spec new(String.t) :: Tesla.Env.client
|
||||
def new(token) when is_binary(token) do
|
||||
Tesla.build_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
|
||||
def new do
|
||||
Tesla.build_client([])
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Deserializer do
|
||||
@moduledoc """
|
||||
Helper functions for deserializing responses into models
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Update the provided model with a deserialization of a nested value
|
||||
"""
|
||||
@spec deserialize(struct(), :atom, :atom, struct(), keyword()) :: struct()
|
||||
def deserialize(model, field, :list, mod, options) 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)))
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.SpecialModelName do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"$special[property.name]"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"$special[property.name]" => integer() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.SpecialModelName do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.AdditionalPropertiesClass do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"map_property",
|
||||
:"map_of_map_property"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"map_property" => %{optional(String.t) => String.t} | nil,
|
||||
:"map_of_map_property" => %{optional(String.t) => %{optional(String.t) => String.t}} | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.AdditionalPropertiesClass do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Animal do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"className",
|
||||
:"color"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"className" => String.t,
|
||||
:"color" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Animal do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,29 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.ApiResponse do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"code",
|
||||
:"type",
|
||||
:"message"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"code" => integer() | nil,
|
||||
:"type" => String.t | nil,
|
||||
:"message" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.ApiResponse do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.ArrayOfArrayOfNumberOnly do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"ArrayArrayNumber"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"ArrayArrayNumber" => [[float()]] | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.ArrayOfArrayOfNumberOnly do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.ArrayOfNumberOnly do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"ArrayNumber"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"ArrayNumber" => [float()] | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.ArrayOfNumberOnly do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,29 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.ArrayTest do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"array_of_string",
|
||||
:"array_array_of_integer",
|
||||
:"array_array_of_model"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"array_of_string" => [String.t] | nil,
|
||||
:"array_array_of_integer" => [[integer()]] | nil,
|
||||
:"array_array_of_model" => [[ReadOnlyFirst]] | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.ArrayTest do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,35 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Capitalization do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"smallCamel",
|
||||
:"CapitalCamel",
|
||||
:"small_Snake",
|
||||
:"Capital_Snake",
|
||||
:"SCA_ETH_Flow_Points",
|
||||
:"ATT_NAME"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"smallCamel" => String.t | nil,
|
||||
:"CapitalCamel" => String.t | nil,
|
||||
:"small_Snake" => String.t | nil,
|
||||
:"Capital_Snake" => String.t | nil,
|
||||
:"SCA_ETH_Flow_Points" => String.t | nil,
|
||||
:"ATT_NAME" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Capitalization do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,29 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Cat do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"className",
|
||||
:"color",
|
||||
:"declawed"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"className" => String.t,
|
||||
:"color" => String.t | nil,
|
||||
:"declawed" => boolean() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Cat do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Category do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"id",
|
||||
:"name"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"id" => integer() | nil,
|
||||
:"name" => String.t
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Category do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.ClassModel do
|
||||
@moduledoc """
|
||||
Model for testing model with \"_class\" property
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"_class"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"_class" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.ClassModel do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Client do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"client"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"client" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Client do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,29 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Dog do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"className",
|
||||
:"color",
|
||||
:"breed"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"className" => String.t,
|
||||
:"color" => String.t | nil,
|
||||
:"breed" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Dog do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.EnumArrays do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"just_symbol",
|
||||
:"array_enum"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"just_symbol" => String.t | nil,
|
||||
:"array_enum" => [String.t] | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.EnumArrays do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.EnumClass do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.EnumClass do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,44 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.EnumTest do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"enum_string",
|
||||
:"enum_string_required",
|
||||
:"enum_integer",
|
||||
:"enum_number",
|
||||
:"outerEnum",
|
||||
:"outerEnumInteger",
|
||||
:"outerEnumDefaultValue",
|
||||
:"outerEnumIntegerDefaultValue"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"enum_string" => String.t | nil,
|
||||
:"enum_string_required" => String.t,
|
||||
:"enum_integer" => integer() | nil,
|
||||
:"enum_number" => float() | nil,
|
||||
:"outerEnum" => OuterEnum | nil,
|
||||
:"outerEnumInteger" => OuterEnumInteger | nil,
|
||||
:"outerEnumDefaultValue" => OuterEnumDefaultValue | nil,
|
||||
:"outerEnumIntegerDefaultValue" => OuterEnumIntegerDefaultValue | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.EnumTest do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"outerEnum", :struct, OpenAPIPetstore.Model.OuterEnum, options)
|
||||
|> deserialize(:"outerEnumInteger", :struct, OpenAPIPetstore.Model.OuterEnumInteger, options)
|
||||
|> deserialize(:"outerEnumDefaultValue", :struct, OpenAPIPetstore.Model.OuterEnumDefaultValue, options)
|
||||
|> deserialize(:"outerEnumIntegerDefaultValue", :struct, OpenAPIPetstore.Model.OuterEnumIntegerDefaultValue, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,30 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.FileSchemaTestClass do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"file",
|
||||
:"files"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"file" => File | nil,
|
||||
:"files" => [File] | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.FileSchemaTestClass do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"file", :struct, OpenAPIPetstore.Model.File, options)
|
||||
|> deserialize(:"files", :list, OpenAPIPetstore.Model.File, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Foo do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"bar"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"bar" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Foo do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,55 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.FormatTest do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"integer",
|
||||
:"int32",
|
||||
:"int64",
|
||||
:"number",
|
||||
:"float",
|
||||
:"double",
|
||||
:"string",
|
||||
:"byte",
|
||||
:"binary",
|
||||
:"date",
|
||||
:"dateTime",
|
||||
:"uuid",
|
||||
:"password",
|
||||
:"pattern_with_digits",
|
||||
:"pattern_with_digits_and_delimiter"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"integer" => integer() | nil,
|
||||
:"int32" => integer() | nil,
|
||||
:"int64" => integer() | nil,
|
||||
:"number" => float(),
|
||||
:"float" => float() | nil,
|
||||
:"double" => float() | nil,
|
||||
:"string" => String.t | nil,
|
||||
:"byte" => binary(),
|
||||
:"binary" => String.t | nil,
|
||||
:"date" => Date.t,
|
||||
:"dateTime" => DateTime.t | nil,
|
||||
:"uuid" => String.t | nil,
|
||||
:"password" => String.t,
|
||||
:"pattern_with_digits" => String.t | nil,
|
||||
:"pattern_with_digits_and_delimiter" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.FormatTest do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"date", :date, nil, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.HasOnlyReadOnly do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"bar",
|
||||
:"foo"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"bar" => String.t | nil,
|
||||
:"foo" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.HasOnlyReadOnly do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.HealthCheckResult do
|
||||
@moduledoc """
|
||||
Just a string to inform instance is up and running. Make it nullable in hope to get it as pointer in generated model.
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"NullableMessage"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"NullableMessage" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.HealthCheckResult do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineObject do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"name",
|
||||
:"status"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"name" => String.t | nil,
|
||||
:"status" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineObject do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineObject1 do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"additionalMetadata",
|
||||
:"file"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"additionalMetadata" => String.t | nil,
|
||||
:"file" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineObject1 do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineObject2 do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"enum_form_string_array",
|
||||
:"enum_form_string"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"enum_form_string_array" => [String.t] | nil,
|
||||
:"enum_form_string" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineObject2 do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,53 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineObject3 do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"integer",
|
||||
:"int32",
|
||||
:"int64",
|
||||
:"number",
|
||||
:"float",
|
||||
:"double",
|
||||
:"string",
|
||||
:"pattern_without_delimiter",
|
||||
:"byte",
|
||||
:"binary",
|
||||
:"date",
|
||||
:"dateTime",
|
||||
:"password",
|
||||
:"callback"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"integer" => integer() | nil,
|
||||
:"int32" => integer() | nil,
|
||||
:"int64" => integer() | nil,
|
||||
:"number" => float(),
|
||||
:"float" => float() | nil,
|
||||
:"double" => float(),
|
||||
:"string" => String.t | nil,
|
||||
:"pattern_without_delimiter" => String.t,
|
||||
:"byte" => binary(),
|
||||
:"binary" => String.t | nil,
|
||||
:"date" => Date.t | nil,
|
||||
:"dateTime" => DateTime.t | nil,
|
||||
:"password" => String.t | nil,
|
||||
:"callback" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineObject3 do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"date", :date, nil, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineObject4 do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"param",
|
||||
:"param2"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"param" => String.t,
|
||||
:"param2" => String.t
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineObject4 do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineObject5 do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"additionalMetadata",
|
||||
:"requiredFile"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"additionalMetadata" => String.t | nil,
|
||||
:"requiredFile" => String.t
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineObject5 do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.InlineResponseDefault do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"string"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"string" => Foo | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.InlineResponseDefault do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"string", :struct, OpenAPIPetstore.Model.Foo, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,31 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.MapTest do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"map_map_of_string",
|
||||
:"map_of_enum_string",
|
||||
:"direct_map",
|
||||
:"indirect_map"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"map_map_of_string" => %{optional(String.t) => %{optional(String.t) => String.t}} | nil,
|
||||
:"map_of_enum_string" => %{optional(String.t) => String.t} | nil,
|
||||
:"direct_map" => %{optional(String.t) => boolean()} | nil,
|
||||
:"indirect_map" => %{optional(String.t) => boolean()} | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.MapTest do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,31 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"uuid",
|
||||
:"dateTime",
|
||||
:"map"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"uuid" => String.t | nil,
|
||||
:"dateTime" => DateTime.t | nil,
|
||||
:"map" => %{optional(String.t) => Animal} | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"map", :map, OpenAPIPetstore.Model.Animal, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Model200Response do
|
||||
@moduledoc """
|
||||
Model for testing model name starting with number
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"name",
|
||||
:"class"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"name" => integer() | nil,
|
||||
:"class" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Model200Response do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,31 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Name do
|
||||
@moduledoc """
|
||||
Model for testing model name same as property name
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"name",
|
||||
:"snake_case",
|
||||
:"property",
|
||||
:"123Number"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"name" => integer(),
|
||||
:"snake_case" => integer() | nil,
|
||||
:"property" => String.t | nil,
|
||||
:"123Number" => integer() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Name do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.NumberOnly do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"JustNumber"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"JustNumber" => float() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.NumberOnly do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,35 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Order do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"id",
|
||||
:"petId",
|
||||
:"quantity",
|
||||
:"shipDate",
|
||||
:"status",
|
||||
:"complete"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"id" => integer() | nil,
|
||||
:"petId" => integer() | nil,
|
||||
:"quantity" => integer() | nil,
|
||||
:"shipDate" => DateTime.t | nil,
|
||||
:"status" => String.t | nil,
|
||||
:"complete" => boolean() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Order do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,29 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.OuterComposite do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"my_number",
|
||||
:"my_string",
|
||||
:"my_boolean"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"my_number" => float() | nil,
|
||||
:"my_string" => String.t | nil,
|
||||
:"my_boolean" => boolean() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.OuterComposite do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.OuterEnum do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.OuterEnum do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.OuterEnumDefaultValue do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.OuterEnumDefaultValue do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.OuterEnumInteger do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.OuterEnumInteger do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.OuterEnumIntegerDefaultValue do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.OuterEnumIntegerDefaultValue do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,38 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Pet do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"id",
|
||||
:"category",
|
||||
:"name",
|
||||
:"photoUrls",
|
||||
:"tags",
|
||||
:"status"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"id" => integer() | nil,
|
||||
:"category" => Category | nil,
|
||||
:"name" => String.t,
|
||||
:"photoUrls" => [String.t],
|
||||
:"tags" => [Tag] | nil,
|
||||
:"status" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Pet do
|
||||
import OpenAPIPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
value
|
||||
|> deserialize(:"category", :struct, OpenAPIPetstore.Model.Category, options)
|
||||
|> deserialize(:"tags", :list, OpenAPIPetstore.Model.Tag, options)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.ReadOnlyFirst do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"bar",
|
||||
:"baz"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"bar" => String.t | nil,
|
||||
:"baz" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.ReadOnlyFirst do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,25 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Return do
|
||||
@moduledoc """
|
||||
Model for testing reserved words
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"return"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"return" => integer() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Return do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,27 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.Tag do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"id",
|
||||
:"name"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"id" => integer() | nil,
|
||||
:"name" => String.t | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.Tag do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,39 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.Model.User do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"id",
|
||||
:"username",
|
||||
:"firstName",
|
||||
:"lastName",
|
||||
:"email",
|
||||
:"password",
|
||||
:"phone",
|
||||
:"userStatus"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"id" => integer() | nil,
|
||||
:"username" => String.t | nil,
|
||||
:"firstName" => String.t | nil,
|
||||
:"lastName" => String.t | nil,
|
||||
:"email" => String.t | nil,
|
||||
:"password" => String.t | nil,
|
||||
:"phone" => String.t | nil,
|
||||
:"userStatus" => integer() | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenAPIPetstore.Model.User do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,143 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenAPIPetstore.RequestBuilder do
|
||||
@moduledoc """
|
||||
Helper functions for building Tesla requests
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Specify the request method when building a request
|
||||
|
||||
## Parameters
|
||||
|
||||
- request (Map) - Collected request options
|
||||
- m (atom) - Request method
|
||||
|
||||
## Returns
|
||||
|
||||
Map
|
||||
"""
|
||||
@spec method(map(), atom) :: map()
|
||||
def method(request, m) do
|
||||
Map.put_new(request, :method, m)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Specify the request method when building a request
|
||||
|
||||
## Parameters
|
||||
|
||||
- request (Map) - Collected request options
|
||||
- u (String) - Request URL
|
||||
|
||||
## Returns
|
||||
|
||||
Map
|
||||
"""
|
||||
@spec url(map(), String.t) :: map()
|
||||
def url(request, u) do
|
||||
Map.put_new(request, :url, u)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Add optional parameters to the request
|
||||
|
||||
## Parameters
|
||||
|
||||
- request (Map) - Collected request options
|
||||
- definitions (Map) - Map of parameter name to parameter location.
|
||||
- options (KeywordList) - The provided optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
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
|
||||
|
||||
## 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
|
||||
|
||||
## Returns
|
||||
|
||||
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"}])))
|
||||
end
|
||||
def add_param(request, :headers, key, value) do
|
||||
request
|
||||
|> Tesla.put_header(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)))
|
||||
end
|
||||
def add_param(request, location, key, value) do
|
||||
Map.update(request, location, [{key, value}], &(&1 ++ [{key, value}]))
|
||||
end
|
||||
|
||||
@doc """
|
||||
Handle the response for a Tesla request
|
||||
|
||||
## Parameters
|
||||
|
||||
- arg1 (Tesla.Env.t | term) - The response object
|
||||
- arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, struct} 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)
|
||||
|
||||
def evaluate_response({:ok, %Tesla.Env{} = env}, mapping) do
|
||||
resolve_mapping(env, mapping)
|
||||
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} | _], _)
|
||||
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)
|
||||
end
|
@ -18,7 +18,7 @@ defmodule OpenapiPetstore.Api.AnotherFake do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- client (Client): client model
|
||||
- body (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -26,13 +26,15 @@ defmodule OpenapiPetstore.Api.AnotherFake do
|
||||
{:error, info} 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
|
||||
def call_123_test_special_tags(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:patch)
|
||||
|> url("/another-fake/dummy")
|
||||
|> add_param(:body, :body, client)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.Client{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.Client{}}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -11,6 +11,33 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
import OpenapiPetstore.RequestBuilder
|
||||
|
||||
|
||||
@doc """
|
||||
creates an XmlItem
|
||||
this route creates an XmlItem
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- xml_item (XmlItem): XmlItem Body
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec create_xml_item(Tesla.Env.client, OpenapiPetstore.Model.XmlItem.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def create_xml_item(connection, xml_item, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/fake/create_xml_item")
|
||||
|> add_param(:body, :body, xml_item)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Test serialization of outer boolean types
|
||||
|
||||
@ -35,7 +62,9 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -45,7 +74,7 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :outer_composite (OuterComposite): Input composite as post body
|
||||
- :body (OuterComposite): Input composite as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %OpenapiPetstore.Model.OuterComposite{}} on success
|
||||
@ -54,7 +83,7 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
@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 = %{
|
||||
:"OuterComposite" => :body
|
||||
:"body" => :body
|
||||
}
|
||||
%{}
|
||||
|> method(:post)
|
||||
@ -62,7 +91,9 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.OuterComposite{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.OuterComposite{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -89,7 +120,9 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -116,16 +149,18 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
For this test, the body for this request much reference a schema named `File`.
|
||||
For this test, the body for this request much reference a schema named `File`.
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- file_schema_test_class (FileSchemaTestClass):
|
||||
- body (FileSchemaTestClass):
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -133,14 +168,16 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
{:error, info} 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
|
||||
def test_body_with_file_schema(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:put)
|
||||
|> url("/fake/body-with-file-schema")
|
||||
|> add_param(:body, :body, file_schema_test_class)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -149,7 +186,7 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- query (String.t):
|
||||
- user (User):
|
||||
- body (User):
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -157,25 +194,27 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
{:error, info} 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
|
||||
def test_body_with_query_params(connection, query, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:put)
|
||||
|> url("/fake/body-with-query-params")
|
||||
|> add_param(:query, :"query", query)
|
||||
|> add_param(:body, :body, user)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
To test \"client\" model
|
||||
To test \"client\" model
|
||||
To test \"client\" model
|
||||
To test \"client\" model
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- client (Client): client model
|
||||
- body (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -183,14 +222,16 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
{:error, info} 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
|
||||
def test_client_model(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:patch)
|
||||
|> url("/fake")
|
||||
|> add_param(:body, :body, client)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.Client{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.Client{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -244,7 +285,10 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -286,7 +330,10 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -324,7 +371,9 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -333,7 +382,7 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- request_body (%{optional(String.t) => String.t}): request body
|
||||
- param (%{optional(String.t) => String.t}): request body
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -341,14 +390,16 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
{:error, info} 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
|
||||
def test_inline_additional_properties(connection, param, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/fake/inline-additionalProperties")
|
||||
|> add_param(:body, :body, request_body)
|
||||
|> add_param(:body, :body, param)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -374,6 +425,8 @@ defmodule OpenapiPetstore.Api.Fake do
|
||||
|> add_param(:form, :"param2", param2)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ defmodule OpenapiPetstore.Api.FakeClassnameTags123 do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- client (Client): client model
|
||||
- body (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -26,13 +26,15 @@ defmodule OpenapiPetstore.Api.FakeClassnameTags123 do
|
||||
{:error, info} 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
|
||||
def test_classname(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:patch)
|
||||
|> url("/fake_classname_test")
|
||||
|> add_param(:body, :body, client)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.Client{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.Client{}}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -17,7 +17,7 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- pet (Pet): Pet object that needs to be added to the store
|
||||
- body (Pet): Pet object that needs to be added to the store
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -25,14 +25,16 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
{:error, info} 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
|
||||
def add_pet(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/pet")
|
||||
|> add_param(:body, :body, pet)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 405, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -60,7 +62,9 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -85,7 +89,10 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> add_param(:query, :"status", status)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode([%OpenapiPetstore.Model.Pet{}])
|
||||
|> evaluate_response([
|
||||
{ 200, [%OpenapiPetstore.Model.Pet{}]},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -110,7 +117,10 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> add_param(:query, :"tags", tags)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode([%OpenapiPetstore.Model.Pet{}])
|
||||
|> evaluate_response([
|
||||
{ 200, [%OpenapiPetstore.Model.Pet{}]},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -134,7 +144,11 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> url("/pet/#{pet_id}")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.Pet{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.Pet{}},
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -143,7 +157,7 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- pet (Pet): Pet object that needs to be added to the store
|
||||
- body (Pet): Pet object that needs to be added to the store
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -151,14 +165,18 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
{:error, info} 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
|
||||
def update_pet(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:put)
|
||||
|> url("/pet")
|
||||
|> add_param(:body, :body, pet)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false},
|
||||
{ 405, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -188,7 +206,9 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 405, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -218,7 +238,9 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.ApiResponse{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.ApiResponse{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -248,6 +270,8 @@ defmodule OpenapiPetstore.Api.Pet do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.ApiResponse{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.ApiResponse{}}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,7 @@ defmodule OpenapiPetstore.Api.Store do
|
||||
|
||||
@doc """
|
||||
Delete purchase order by ID
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -32,7 +32,10 @@ defmodule OpenapiPetstore.Api.Store do
|
||||
|> url("/store/order/#{order_id}")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -55,12 +58,14 @@ defmodule OpenapiPetstore.Api.Store do
|
||||
|> url("/store/inventory")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode()
|
||||
|> evaluate_response([
|
||||
{ 200, %{}}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
Find purchase order by ID
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -79,7 +84,11 @@ defmodule OpenapiPetstore.Api.Store do
|
||||
|> url("/store/order/#{order_id}")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.Order{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.Order{}},
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -88,7 +97,7 @@ defmodule OpenapiPetstore.Api.Store do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- order (Order): order placed for purchasing the pet
|
||||
- body (Order): order placed for purchasing the pet
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -96,13 +105,16 @@ defmodule OpenapiPetstore.Api.Store do
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec place_order(Tesla.Env.client, OpenapiPetstore.Model.Order.t, keyword()) :: {:ok, OpenapiPetstore.Model.Order.t} | {:error, Tesla.Env.t}
|
||||
def place_order(connection, order, _opts \\ []) do
|
||||
def place_order(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/store/order")
|
||||
|> add_param(:body, :body, order)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.Order{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.Order{}},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -18,7 +18,7 @@ defmodule OpenapiPetstore.Api.User do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- user (User): Created user object
|
||||
- body (User): Created user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -26,14 +26,16 @@ defmodule OpenapiPetstore.Api.User do
|
||||
{:error, info} 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
|
||||
def create_user(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/user")
|
||||
|> add_param(:body, :body, user)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -42,7 +44,7 @@ defmodule OpenapiPetstore.Api.User do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- user ([User]): List of user object
|
||||
- body ([User]): List of user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -50,14 +52,16 @@ defmodule OpenapiPetstore.Api.User do
|
||||
{:error, info} 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
|
||||
def create_users_with_array_input(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/user/createWithArray")
|
||||
|> add_param(:body, :body, user)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -66,7 +70,7 @@ defmodule OpenapiPetstore.Api.User do
|
||||
## Parameters
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- user ([User]): List of user object
|
||||
- body ([User]): List of user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -74,14 +78,16 @@ defmodule OpenapiPetstore.Api.User do
|
||||
{:error, info} 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
|
||||
def create_users_with_list_input(connection, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/user/createWithList")
|
||||
|> add_param(:body, :body, user)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -105,7 +111,10 @@ defmodule OpenapiPetstore.Api.User do
|
||||
|> url("/user/#{username}")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -128,7 +137,11 @@ defmodule OpenapiPetstore.Api.User do
|
||||
|> url("/user/#{username}")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%OpenapiPetstore.Model.User{})
|
||||
|> evaluate_response([
|
||||
{ 200, %OpenapiPetstore.Model.User{}},
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -154,7 +167,10 @@ defmodule OpenapiPetstore.Api.User do
|
||||
|> add_param(:query, :"password", password)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 200, false},
|
||||
{ 400, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -176,7 +192,9 @@ defmodule OpenapiPetstore.Api.User do
|
||||
|> url("/user/logout")
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ :default, false}
|
||||
])
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -187,7 +205,7 @@ defmodule OpenapiPetstore.Api.User do
|
||||
|
||||
- connection (OpenapiPetstore.Connection): Connection to server
|
||||
- username (String.t): name that need to be deleted
|
||||
- user (User): Updated user object
|
||||
- body (User): Updated user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
## Returns
|
||||
|
||||
@ -195,13 +213,16 @@ defmodule OpenapiPetstore.Api.User do
|
||||
{:error, info} 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
|
||||
def update_user(connection, username, body, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:put)
|
||||
|> url("/user/#{username}")
|
||||
|> add_param(:body, :body, user)
|
||||
|> add_param(:body, :body, body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|> evaluate_response([
|
||||
{ 400, false},
|
||||
{ 404, false}
|
||||
])
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,33 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenapiPetstore.Model.TypeHolderDefault do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"string_item",
|
||||
:"number_item",
|
||||
:"integer_item",
|
||||
:"bool_item",
|
||||
:"array_item"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"string_item" => String.t,
|
||||
:"number_item" => float(),
|
||||
:"integer_item" => integer(),
|
||||
:"bool_item" => boolean(),
|
||||
:"array_item" => [integer()]
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenapiPetstore.Model.TypeHolderDefault do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,33 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenapiPetstore.Model.TypeHolderExample do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"string_item",
|
||||
:"number_item",
|
||||
:"integer_item",
|
||||
:"bool_item",
|
||||
:"array_item"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"string_item" => String.t,
|
||||
:"number_item" => float(),
|
||||
:"integer_item" => integer(),
|
||||
:"bool_item" => boolean(),
|
||||
:"array_item" => [integer()]
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenapiPetstore.Model.TypeHolderExample do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,81 @@
|
||||
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
# https://openapi-generator.tech
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule OpenapiPetstore.Model.XmlItem do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"attribute_string",
|
||||
:"attribute_number",
|
||||
:"attribute_integer",
|
||||
:"attribute_boolean",
|
||||
:"wrapped_array",
|
||||
:"name_string",
|
||||
:"name_number",
|
||||
:"name_integer",
|
||||
:"name_boolean",
|
||||
:"name_array",
|
||||
:"name_wrapped_array",
|
||||
:"prefix_string",
|
||||
:"prefix_number",
|
||||
:"prefix_integer",
|
||||
:"prefix_boolean",
|
||||
:"prefix_array",
|
||||
:"prefix_wrapped_array",
|
||||
:"namespace_string",
|
||||
:"namespace_number",
|
||||
:"namespace_integer",
|
||||
:"namespace_boolean",
|
||||
:"namespace_array",
|
||||
:"namespace_wrapped_array",
|
||||
:"prefix_ns_string",
|
||||
:"prefix_ns_number",
|
||||
:"prefix_ns_integer",
|
||||
:"prefix_ns_boolean",
|
||||
:"prefix_ns_array",
|
||||
:"prefix_ns_wrapped_array"
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"attribute_string" => String.t | nil,
|
||||
:"attribute_number" => float() | nil,
|
||||
:"attribute_integer" => integer() | nil,
|
||||
:"attribute_boolean" => boolean() | nil,
|
||||
:"wrapped_array" => [integer()] | nil,
|
||||
:"name_string" => String.t | nil,
|
||||
:"name_number" => float() | nil,
|
||||
:"name_integer" => integer() | nil,
|
||||
:"name_boolean" => boolean() | nil,
|
||||
:"name_array" => [integer()] | nil,
|
||||
:"name_wrapped_array" => [integer()] | nil,
|
||||
:"prefix_string" => String.t | nil,
|
||||
:"prefix_number" => float() | nil,
|
||||
:"prefix_integer" => integer() | nil,
|
||||
:"prefix_boolean" => boolean() | nil,
|
||||
:"prefix_array" => [integer()] | nil,
|
||||
:"prefix_wrapped_array" => [integer()] | nil,
|
||||
:"namespace_string" => String.t | nil,
|
||||
:"namespace_number" => float() | nil,
|
||||
:"namespace_integer" => integer() | nil,
|
||||
:"namespace_boolean" => boolean() | nil,
|
||||
:"namespace_array" => [integer()] | nil,
|
||||
:"namespace_wrapped_array" => [integer()] | nil,
|
||||
:"prefix_ns_string" => String.t | nil,
|
||||
:"prefix_ns_number" => float() | nil,
|
||||
:"prefix_ns_integer" => integer() | nil,
|
||||
:"prefix_ns_boolean" => boolean() | nil,
|
||||
:"prefix_ns_array" => [integer()] | nil,
|
||||
:"prefix_ns_wrapped_array" => [integer()] | nil
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: OpenapiPetstore.Model.XmlItem do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -110,7 +110,7 @@ defmodule OpenapiPetstore.RequestBuilder do
|
||||
|
||||
## Parameters
|
||||
|
||||
- arg1 ({:ok, Tesla.Env.t} | term) - The response object
|
||||
- arg1 (Tesla.Env.t | term) - The response object
|
||||
- arg2 (:false | struct | [struct]) - The shape of the struct to deserialize into
|
||||
|
||||
## Returns
|
||||
@ -118,14 +118,26 @@ defmodule OpenapiPetstore.RequestBuilder do
|
||||
{:ok, struct} on success
|
||||
{:error, term} on failure
|
||||
"""
|
||||
@spec decode({:ok, Tesla.Env.t} | term()) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()}
|
||||
def decode({:ok, %Tesla.Env{status: 200, body: body}}), do: Poison.decode(body)
|
||||
def decode(response), do: {:error, response}
|
||||
def decode({:error, _} = error), do: error
|
||||
@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 decode({:ok, Tesla.Env.t} | term(), :false | struct() | [struct()]) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()}
|
||||
def decode({:ok, %Tesla.Env{status: 200}} = env, false), do: {:ok, env}
|
||||
def decode({:ok, %Tesla.Env{status: 200, body: body}}, struct), do: Poison.decode(body, as: struct)
|
||||
def decode({:error, _} = error, _struct), do: error
|
||||
def decode(response, _struct), do: {:error, response}
|
||||
def evaluate_response({:ok, %Tesla.Env{} = env}, mapping) do
|
||||
resolve_mapping(env, mapping)
|
||||
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} | _], _)
|
||||
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)
|
||||
end
|
||||
|
@ -1,8 +1,8 @@
|
||||
defmodule OpenapiPetstore.Mixfile do
|
||||
defmodule OpenAPIPetstore.Mixfile do
|
||||
use Mix.Project
|
||||
|
||||
def project do
|
||||
[app: :openapi_petstore,
|
||||
[app: :open_api_petstore,
|
||||
version: "0.1.0",
|
||||
elixir: "~> 1.4",
|
||||
build_embedded: Mix.env == :prod,
|
||||
@ -30,7 +30,7 @@ defmodule OpenapiPetstore.Mixfile do
|
||||
defp deps do
|
||||
[
|
||||
{:tesla, "~> 1.0.0"},
|
||||
{:poison, ">= 1.0.0"}
|
||||
{:poison, "~> 3.0.0"}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user