mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-12 12:40:53 +00:00
Update Elixir Petstore with OAS2 (#316)
* restore elixir petstore original from codegen2x * update elixir generator to work with oas2 * minor fix to elixir generato * minor enhancement to templates * update elixir petstore with oas2
This commit is contained in:
parent
08e0393def
commit
8edf6e52ad
@ -32,6 +32,6 @@ rm -Rf "samples/client/petstore/elixir/lib/swagger_petstore/lib/"
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
args="$@ generate -t modules/openapi-generator/src/main/resources/elixir -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l elixir -o samples/client/petstore/elixir"
|
||||
args="generate -t modules/openapi-generator/src/main/resources/elixir -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l elixir -o samples/client/petstore/elixir/ $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $args
|
||||
|
@ -28,6 +28,8 @@ import io.swagger.v3.oas.models.media.*;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.jws.WebParam;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.*;
|
||||
@ -347,7 +349,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
for (String word : moduleName.split("\\.")) {
|
||||
underscoredWords.add(underscore(word));
|
||||
}
|
||||
return "lib/" + join("/", underscoredWords);
|
||||
return ("lib/" + join("/", underscoredWords)).replace('/', File.separatorChar);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -355,7 +357,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
* instantiated
|
||||
*/
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder() + "/" + "model";
|
||||
return outputFolder + File.separator + sourceFolder() + File.separator + "model";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,7 +366,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
*/
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder() + "/" + "api";
|
||||
return outputFolder + File.separator + sourceFolder() + File.separator + "api";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -456,14 +458,14 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
} else if (ModelUtils.isDateTimeSchema(p)) {
|
||||
return "DateTime.t";
|
||||
} else if (ModelUtils.isObjectSchema(p)) {
|
||||
// How to map it?
|
||||
// TODO How to map it?
|
||||
return super.getTypeDeclaration(p);
|
||||
} else if (ModelUtils.isIntegerSchema(p)) {
|
||||
return "integer()";
|
||||
} else if (ModelUtils.isNumberSchema(p)) {
|
||||
return "float()";
|
||||
} else if (ModelUtils.isBinarySchema(p)) {
|
||||
return "binary()";
|
||||
} else if (ModelUtils.isBinarySchema(p) || ModelUtils.isFileSchema(p)) {
|
||||
return "String.t";
|
||||
} else if (ModelUtils.isBooleanSchema(p)) {
|
||||
return "boolean()";
|
||||
} else if (!StringUtils.isEmpty(p.get$ref())) { // model
|
||||
@ -546,6 +548,8 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
this.queryParams = o.queryParams;
|
||||
this.headerParams = o.headerParams;
|
||||
this.formParams = o.formParams;
|
||||
this.requiredParams = o.requiredParams;
|
||||
this.optionalParams = o.optionalParams;
|
||||
this.authMethods = o.authMethods;
|
||||
this.tags = o.tags;
|
||||
this.responses = o.responses;
|
||||
@ -622,11 +626,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
} else if (param.isListContainer) {
|
||||
// list(<subtype>)
|
||||
sb.append("list(");
|
||||
if (param.isBodyParam) {
|
||||
buildTypespec(param.items.items, sb);
|
||||
} else {
|
||||
buildTypespec(param.items, sb);
|
||||
}
|
||||
buildTypespec(param.items, sb);
|
||||
sb.append(")");
|
||||
} else if (param.isMapContainer) {
|
||||
// %{optional(String.t) => <subtype>}
|
||||
@ -636,7 +636,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
} else if (param.isPrimitiveType) {
|
||||
// like `integer()`, `String.t`
|
||||
sb.append(param.dataType);
|
||||
} else if (param.isFile) {
|
||||
} else if (param.isFile || param.isBinary) {
|
||||
sb.append("String.t");
|
||||
} else {
|
||||
// <module>.Model.<type>.t
|
||||
@ -649,7 +649,7 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
private void buildTypespec(CodegenProperty property, StringBuilder sb) {
|
||||
if (property == null) {
|
||||
LOGGER.warn("CodegenProperty cannot be null");
|
||||
LOGGER.error("CodegenProperty cannot be null. Please report the issue to https://github.com/openapitools/openapi-generator with the spec");
|
||||
} else if (property.isListContainer) {
|
||||
sb.append("list(");
|
||||
buildTypespec(property.items, sb);
|
||||
|
@ -21,35 +21,42 @@ defmodule {{moduleName}}.Api.{{classname}} do
|
||||
## Parameters
|
||||
|
||||
- connection ({{moduleName}}.Connection): Connection to server
|
||||
{{#allParams}}{{#required}} - {{#underscored}}{{paramName}}{{/underscored}} ({{dataType}}): {{description}}
|
||||
{{/required}}{{/allParams}} - opts (KeywordList): [optional] Optional parameters
|
||||
{{#allParams}}{{^required}} - {{#underscored}}:{{paramName}}{{/underscored}} ({{dataType}}): {{description}}
|
||||
{{/required}}{{/allParams}}
|
||||
{{#requiredParams}}
|
||||
- {{#underscored}}{{paramName}}{{/underscored}} ({{dataType}}): {{description}}
|
||||
{{/requiredParams}}
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
{{#optionalParams}}
|
||||
- {{#underscored}}:{{paramName}}{{/underscored}} ({{dataType}}): {{description}}
|
||||
{{/optionalParams}}
|
||||
## Returns
|
||||
|
||||
{:ok, {{#isListContainer}}[%{{returnBaseType}}{}, ...]{{/isListContainer}}{{#isMapContainer}}%{}{{/isMapContainer}}{{^returnType}}%{}{{/returnType}}{{#returnSimpleType}}%{{#returnType}}{{#isMapContainer}}{{/isMapContainer}}{{moduleName}}.Model.{{{returnType}}}{{/returnType}}{}{{/returnSimpleType}}} on success
|
||||
{:ok, {{#isListContainer}}[%{{returnBaseType}}{}, ...]{{/isListContainer}}{{#isMapContainer}}%{}{{/isMapContainer}}{{^returnType}}%{}{{/returnType}}{{#returnSimpleType}}%{{#returnType}}{{#isMapContainer}}{{/isMapContainer}}{{{moduleName}}}.Model.{{{returnType}}}{{/returnType}}{}{{/returnSimpleType}}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
{{typespec}}
|
||||
def {{#underscored}}{{operationId}}{{/underscored}}(connection, {{#allParams}}{{#required}}{{#underscored}}{{paramName}}{{/underscored}}, {{/required}}{{/allParams}}{{^hasOptionalParams}}_{{/hasOptionalParams}}opts \\ []) do
|
||||
{{#hasOptionalParams}}
|
||||
{{{typespec}}}
|
||||
def {{#underscored}}{{{operationId}}}{{/underscored}}(connection, {{#requiredParams}}{{#underscored}}{{{paramName}}}{{/underscored}}, {{/requiredParams}}{{^hasOptionalParams}}_{{/hasOptionalParams}}opts \\ []) do
|
||||
{{#optionalParams}}
|
||||
{{#-first}}
|
||||
optional_params = %{
|
||||
{{#allParams}}{{^required}}{{^isPathParam}}:"{{baseName}}" => {{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}:form{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}{{/isPathParam}}{{#hasMore}},
|
||||
{{/hasMore}}{{/required}}{{/allParams}}
|
||||
{{/-first}}
|
||||
:"{{baseName}}" => {{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}:form{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}{{#hasMore}},{{/hasMore}}
|
||||
{{#-last}}
|
||||
}
|
||||
{{/hasOptionalParams}}
|
||||
{{/-last}}
|
||||
{{/optionalParams}}
|
||||
%{}
|
||||
|> method(:{{#underscored}}{{httpMethod}}{{/underscored}})
|
||||
|> url("{{replacedPathName}}")
|
||||
{{#allParams}}
|
||||
{{#required}}
|
||||
{{^isPathParam}} |> add_param({{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}{{#isMultipart}}{{#isFile}}:file{{/isFile}}{{^isFile}}:form{{/isFile}}{{/isMultipart}}{{^isMultipart}}:form{{/isMultipart}}{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}, :"{{baseName}}", {{#underscored}}{{paramName}}{{/underscored}})
|
||||
{{#requiredParams}}
|
||||
{{^isPathParam}}
|
||||
|> add_param({{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}{{#isMultipart}}{{#isFile}}:file{{/isFile}}{{^isFile}}:form{{/isFile}}{{/isMultipart}}{{^isMultipart}}:form{{/isMultipart}}{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}, :"{{baseName}}", {{#underscored}}{{paramName}}{{/underscored}})
|
||||
{{/isPathParam}}
|
||||
{{/required}}
|
||||
{{/allParams}}
|
||||
{{#hasOptionalParams}}
|
||||
{{/requiredParams}}
|
||||
{{#optionalParams}}
|
||||
{{#-first}}
|
||||
|> add_optional_params(optional_params, opts)
|
||||
{{/hasOptionalParams}}
|
||||
{{/-first}}
|
||||
{{/optionalParams}}
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode({{decodedStruct}})
|
||||
|
@ -1 +1 @@
|
||||
2.3.0-SNAPSHOT
|
||||
3.0.0-SNAPSHOT
|
@ -18,20 +18,19 @@ defmodule SwaggerPetstore.Api.AnotherFake do
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (Client): client model
|
||||
- client (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.Client{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec test_special_tags(Tesla.Env.client, SwaggerPetstore.Model.Client.t, keyword()) :: {:ok, SwaggerPetstore.Model.Client.t} | {:error, Tesla.Env.t}
|
||||
def test_special_tags(connection, body, _opts \\ []) do
|
||||
def test_special_tags(connection, client, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:patch)
|
||||
|> url("/another-fake/dummy")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"Client", client)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.Client{})
|
||||
|
@ -18,14 +18,13 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (OuterBoolean): Input boolean as post body
|
||||
|
||||
- :body (boolean()): Input boolean as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.OuterBoolean{}} on success
|
||||
{:ok, %SwaggerPetstore.Model.Boolean{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec fake_outer_boolean_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterBoolean.t} | {:error, Tesla.Env.t}
|
||||
@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
|
||||
@ -36,7 +35,7 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.OuterBoolean{})
|
||||
|> decode(false)
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -46,8 +45,7 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (OuterComposite): Input composite as post body
|
||||
|
||||
- :outer_composite (OuterComposite): Input composite as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.OuterComposite{}} on success
|
||||
@ -56,7 +54,7 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
@spec fake_outer_composite_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterComposite.t} | {:error, Tesla.Env.t}
|
||||
def fake_outer_composite_serialize(connection, opts \\ []) do
|
||||
optional_params = %{
|
||||
:"body" => :body
|
||||
:"OuterComposite" => :body
|
||||
}
|
||||
%{}
|
||||
|> method(:post)
|
||||
@ -74,14 +72,13 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (OuterNumber): Input number as post body
|
||||
|
||||
- :body (float()): Input number as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.OuterNumber{}} on success
|
||||
{:ok, %SwaggerPetstore.Model.Float{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec fake_outer_number_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterNumber.t} | {:error, Tesla.Env.t}
|
||||
@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
|
||||
@ -92,7 +89,7 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.OuterNumber{})
|
||||
|> decode(false)
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -102,14 +99,13 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :body (OuterString): Input string as post body
|
||||
|
||||
- :body (String.t): Input string as post body
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.OuterString{}} on success
|
||||
{:ok, %SwaggerPetstore.Model.String{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec fake_outer_string_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterString.t} | {:error, Tesla.Env.t}
|
||||
@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
|
||||
@ -120,7 +116,32 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|> add_optional_params(optional_params, opts)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.OuterString{})
|
||||
|> decode(false)
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.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, SwaggerPetstore.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, :"User", user)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
end
|
||||
|
||||
@doc """
|
||||
@ -130,20 +151,19 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (Client): client model
|
||||
- client (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.Client{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec test_client_model(Tesla.Env.client, SwaggerPetstore.Model.Client.t, keyword()) :: {:ok, SwaggerPetstore.Model.Client.t} | {:error, Tesla.Env.t}
|
||||
def test_client_model(connection, body, _opts \\ []) do
|
||||
def test_client_model(connection, client, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:patch)
|
||||
|> url("/fake")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"Client", client)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.Client{})
|
||||
@ -166,12 +186,11 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
- :int64 (integer()): None
|
||||
- :float (float()): None
|
||||
- :string (String.t): None
|
||||
- :binary (binary()): 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
|
||||
@ -212,15 +231,14 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :enum_form_string_array ([String.t]): Form parameter enum test (string array)
|
||||
- :enum_form_string (String.t): Form parameter enum test (string)
|
||||
- :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
|
||||
@ -229,14 +247,14 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
@spec test_enum_parameters(Tesla.Env.client, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def test_enum_parameters(connection, opts \\ []) do
|
||||
optional_params = %{
|
||||
:"enum_form_string_array" => :form,
|
||||
:"enum_form_string" => :form,
|
||||
:"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" => :form
|
||||
:"enum_query_double" => :query,
|
||||
:"enum_form_string_array" => :form,
|
||||
:"enum_form_string" => :form
|
||||
}
|
||||
%{}
|
||||
|> method(:get)
|
||||
@ -249,25 +267,23 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
@doc """
|
||||
test inline additionalProperties
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- param (Object): request body
|
||||
- request_body (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, SwaggerPetstore.Model.Object.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def test_inline_additional_properties(connection, param, _opts \\ []) do
|
||||
@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, :"param", param)
|
||||
|> add_param(:body, :"request_body", request_body)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
@ -275,7 +291,6 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
|
||||
@doc """
|
||||
test json serialization of form data
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -283,7 +298,6 @@ defmodule SwaggerPetstore.Api.Fake do
|
||||
- param (String.t): field1
|
||||
- param2 (String.t): field2
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
|
@ -13,24 +13,24 @@ defmodule SwaggerPetstore.Api.FakeClassnameTags123 do
|
||||
|
||||
@doc """
|
||||
To test class name in snake case
|
||||
To test class name in snake case
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (Client): client model
|
||||
- client (Client): client model
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.Client{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec test_classname(Tesla.Env.client, SwaggerPetstore.Model.Client.t, keyword()) :: {:ok, SwaggerPetstore.Model.Client.t} | {:error, Tesla.Env.t}
|
||||
def test_classname(connection, body, _opts \\ []) do
|
||||
def test_classname(connection, client, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:patch)
|
||||
|> url("/fake_classname_test")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"Client", client)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.Client{})
|
||||
|
@ -13,25 +13,23 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
|
||||
@doc """
|
||||
Add a new pet to the store
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (Pet): Pet object that needs to be added to the store
|
||||
- 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, SwaggerPetstore.Model.Pet.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def add_pet(connection, body, _opts \\ []) do
|
||||
def add_pet(connection, pet, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/pet")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"Pet", pet)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
@ -39,7 +37,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
|
||||
@doc """
|
||||
Deletes a pet
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -47,7 +44,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
- pet_id (integer()): Pet id to delete
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :api_key (String.t):
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
@ -76,7 +72,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
- connection (SwaggerPetstore.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
|
||||
@ -102,7 +97,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- tags ([String.t]): Tags to filter by
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, [%Pet{}, ...]} on success
|
||||
@ -128,7 +122,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- pet_id (integer()): ID of pet to return
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.Pet{}} on success
|
||||
@ -146,25 +139,23 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
|
||||
@doc """
|
||||
Update an existing pet
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (Pet): Pet object that needs to be added to the store
|
||||
- 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, SwaggerPetstore.Model.Pet.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def update_pet(connection, body, _opts \\ []) do
|
||||
def update_pet(connection, pet, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:put)
|
||||
|> url("/pet")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"Pet", pet)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
@ -172,7 +163,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
|
||||
@doc """
|
||||
Updates a pet in the store with form data
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -181,7 +171,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
- 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
|
||||
@ -204,7 +193,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
|
||||
@doc """
|
||||
uploads an image
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -213,7 +201,6 @@ defmodule SwaggerPetstore.Api.Pet do
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
- :additional_metadata (String.t): Additional data to pass to server
|
||||
- :file (String.t): file to upload
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.ApiResponse{}} on success
|
||||
|
@ -20,7 +20,6 @@ defmodule SwaggerPetstore.Api.Store do
|
||||
- connection (SwaggerPetstore.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
|
||||
@ -44,7 +43,6 @@ defmodule SwaggerPetstore.Api.Store do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
@ -69,7 +67,6 @@ defmodule SwaggerPetstore.Api.Store do
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- order_id (integer()): ID of pet that needs to be fetched
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.Order{}} on success
|
||||
@ -87,25 +84,23 @@ defmodule SwaggerPetstore.Api.Store do
|
||||
|
||||
@doc """
|
||||
Place an order for a pet
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (Order): order placed for purchasing the pet
|
||||
- order (Order): order placed for purchasing the pet
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.Order{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec place_order(Tesla.Env.client, SwaggerPetstore.Model.Order.t, keyword()) :: {:ok, SwaggerPetstore.Model.Order.t} | {:error, Tesla.Env.t}
|
||||
def place_order(connection, body, _opts \\ []) do
|
||||
def place_order(connection, order, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/store/order")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"Order", order)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(%SwaggerPetstore.Model.Order{})
|
||||
|
@ -18,20 +18,19 @@ defmodule SwaggerPetstore.Api.User do
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body (User): Created user object
|
||||
- user (User): Created user object
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
{:error, info} on failure
|
||||
"""
|
||||
@spec create_user(Tesla.Env.client, SwaggerPetstore.Model.User.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def create_user(connection, body, _opts \\ []) do
|
||||
def create_user(connection, user, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/user")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"User", user)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
@ -39,25 +38,23 @@ defmodule SwaggerPetstore.Api.User do
|
||||
|
||||
@doc """
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body ([User]): List of user object
|
||||
- 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(SwaggerPetstore.Model.User.t), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def create_users_with_array_input(connection, body, _opts \\ []) do
|
||||
def create_users_with_array_input(connection, user, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/user/createWithArray")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"User", user)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
@ -65,25 +62,23 @@ defmodule SwaggerPetstore.Api.User do
|
||||
|
||||
@doc """
|
||||
Creates list of users with given input array
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- body ([User]): List of user object
|
||||
- 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(SwaggerPetstore.Model.User.t), keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def create_users_with_list_input(connection, body, _opts \\ []) do
|
||||
def create_users_with_list_input(connection, user, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:post)
|
||||
|> url("/user/createWithList")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"User", user)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
@ -98,7 +93,6 @@ defmodule SwaggerPetstore.Api.User do
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- username (String.t): The name that needs to be deleted
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
@ -116,14 +110,12 @@ defmodule SwaggerPetstore.Api.User do
|
||||
|
||||
@doc """
|
||||
Get user by user name
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- username (String.t): The name that needs to be fetched. Use user1 for testing.
|
||||
- username (String.t): The name that needs to be fetched. Use user1 for testing.
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %SwaggerPetstore.Model.User{}} on success
|
||||
@ -141,7 +133,6 @@ defmodule SwaggerPetstore.Api.User do
|
||||
|
||||
@doc """
|
||||
Logs user into the system
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
@ -149,7 +140,6 @@ defmodule SwaggerPetstore.Api.User do
|
||||
- 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, %SwaggerPetstore.Model.String.t{}} on success
|
||||
@ -169,13 +159,11 @@ defmodule SwaggerPetstore.Api.User do
|
||||
|
||||
@doc """
|
||||
Logs out current logged in user session
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- opts (KeywordList): [optional] Optional parameters
|
||||
|
||||
## Returns
|
||||
|
||||
{:ok, %{}} on success
|
||||
@ -199,20 +187,19 @@ defmodule SwaggerPetstore.Api.User do
|
||||
|
||||
- connection (SwaggerPetstore.Connection): Connection to server
|
||||
- username (String.t): name that need to be deleted
|
||||
- body (User): Updated user object
|
||||
- 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, SwaggerPetstore.Model.User.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t}
|
||||
def update_user(connection, username, body, _opts \\ []) do
|
||||
def update_user(connection, username, user, _opts \\ []) do
|
||||
%{}
|
||||
|> method(:put)
|
||||
|> url("/user/#{username}")
|
||||
|> add_param(:body, :"body", body)
|
||||
|> add_param(:body, :"User", user)
|
||||
|> Enum.into([])
|
||||
|> (&Connection.request(connection, &1)).()
|
||||
|> decode(false)
|
||||
|
@ -24,11 +24,15 @@ defmodule SwaggerPetstore.Deserializer do
|
||||
|> 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
|
||||
case DateTime.from_iso8601(Map.get(model, field)) do
|
||||
{:ok, datetime} ->
|
||||
Map.put(model, field, datetime)
|
||||
_ ->
|
||||
model
|
||||
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
|
||||
|
@ -10,6 +10,7 @@ defmodule SwaggerPetstore.Model.EnumTest do
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
:"enum_string",
|
||||
:"enum_string_required",
|
||||
:"enum_integer",
|
||||
:"enum_number",
|
||||
:"outerEnum"
|
||||
@ -17,6 +18,7 @@ defmodule SwaggerPetstore.Model.EnumTest do
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"enum_string" => String.t,
|
||||
:"enum_string_required" => String.t,
|
||||
:"enum_integer" => integer(),
|
||||
:"enum_number" => float(),
|
||||
:"outerEnum" => OuterEnum
|
||||
|
@ -33,7 +33,7 @@ defmodule SwaggerPetstore.Model.FormatTest do
|
||||
:"double" => float(),
|
||||
:"string" => String.t,
|
||||
:"byte" => binary(),
|
||||
:"binary" => binary(),
|
||||
:"binary" => String.t,
|
||||
:"date" => Date.t,
|
||||
:"dateTime" => DateTime.t,
|
||||
:"uuid" => String.t,
|
||||
|
@ -1,25 +0,0 @@
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# https://github.com/swagger-api/swagger-codegen.git
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule SwaggerPetstore.Model.OuterBoolean do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: SwaggerPetstore.Model.OuterBoolean do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -15,19 +15,15 @@ defmodule SwaggerPetstore.Model.OuterComposite do
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
:"my_number" => OuterNumber,
|
||||
:"my_string" => OuterString,
|
||||
:"my_boolean" => OuterBoolean
|
||||
:"my_number" => Float,
|
||||
:"my_string" => String,
|
||||
:"my_boolean" => Boolean
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: SwaggerPetstore.Model.OuterComposite do
|
||||
import SwaggerPetstore.Deserializer
|
||||
def decode(value, options) do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
|> deserialize(:"my_number", :struct, SwaggerPetstore.Model.OuterNumber, options)
|
||||
|> deserialize(:"my_string", :struct, SwaggerPetstore.Model.OuterString, options)
|
||||
|> deserialize(:"my_boolean", :struct, SwaggerPetstore.Model.OuterBoolean, options)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,25 +0,0 @@
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# https://github.com/swagger-api/swagger-codegen.git
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule SwaggerPetstore.Model.OuterNumber do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: SwaggerPetstore.Model.OuterNumber do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
@ -1,25 +0,0 @@
|
||||
# NOTE: This class is auto generated by the swagger code generator program.
|
||||
# https://github.com/swagger-api/swagger-codegen.git
|
||||
# Do not edit the class manually.
|
||||
|
||||
defmodule SwaggerPetstore.Model.OuterString do
|
||||
@moduledoc """
|
||||
|
||||
"""
|
||||
|
||||
@derive [Poison.Encoder]
|
||||
defstruct [
|
||||
|
||||
]
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
defimpl Poison.Decoder, for: SwaggerPetstore.Model.OuterString do
|
||||
def decode(value, _options) do
|
||||
value
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user