diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index c5b87962059..9a41c86cec5 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -39,7 +39,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.3.0 + 3.6.0 process-resources diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java index 82861dbd0e5..2d7ffb6df25 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ElixirClientCodegen.java @@ -20,21 +20,23 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig protected String moduleName; protected static final String defaultModuleName = "Swagger.Client"; - // This is the name of elixir project name; - protected static final String defaultPackageName = "swagger_client"; + // This is the name of elixir project name; + protected static final String defaultPackageName = "swagger_client"; - String supportedElixirVersion = "1.4"; - List extraApplications = Arrays.asList(":logger"); - List deps = Arrays.asList( - "{:tesla, \"~> 0.8\"}", - "{:poison, \">= 1.0.0\"}" - ); + String supportedElixirVersion = "1.4"; + List extraApplications = Arrays.asList(":logger"); + List deps = + Arrays.asList( + "{:tesla, \"~> 1.12.1\"}", + "{:poison, \">= 6.0.0\"}"); - public ElixirClientCodegen() { - super(); + Pattern MODULE_PATTERN = Pattern.compile("^[A-Z][a-zA-Z0-9]*(\\.[A-Z][a-zA-Z0-9]*)*$"); - // set the output folder here - outputFolder = "generated-code/elixir"; + public ElixirClientCodegen() { + super(); + + // set the output folder here + outputFolder = "generated-code/elixir"; /* * Models. You can write model files using the modelTemplateFiles map. @@ -77,17 +79,21 @@ public ElixirClientCodegen() { "__CALLER__") ); - /** - * Additional Properties. These values can be passed to the templates and - * are available in models, apis, and supporting files - */ - additionalProperties.put("apiVersion", apiVersion); + /** + * Additional Properties. These values can be passed to the templates and + * are available in models, apis, and supporting files + */ + additionalProperties.put("apiVersion", apiVersion); - /** - * Supporting Files. You can write single files for the generator with the - * entire object tree available. If the input file has a suffix of `.mustache - * it will be processed by the template engine. Otherwise, it will be copied - */ + //required to prevent code checker barfing on '}}}' in api.moustache + additionalProperties.put("closebrace", "}"); + + + /** + * Supporting Files. You can write single files for the generator with the + * entire object tree available. If the input file has a suffix of `.mustache + * it will be processed by the template engine. Otherwise, it will be copied + */ supportingFiles.add(new SupportingFile("README.md.mustache", // the input template or file "", // the destination folder, relative `outputFolder` "README.md") // the output file @@ -144,7 +150,7 @@ public ElixirClientCodegen() { typeMapping.put("map", "Map"); typeMapping.put("array", "List"); typeMapping.put("list", "List"); - // typeMapping.put("object", "Map"); + typeMapping.put("object", "Map"); typeMapping.put("binary", "String"); typeMapping.put("ByteArray", "String"); typeMapping.put("UUID", "String"); @@ -154,9 +160,9 @@ public ElixirClientCodegen() { cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "Elixir package name (convention: lowercase).")); } - /** - * Configures the type of generator. - * + /** + * Configures the type of generator. + * * @return the CodegenType for this generator * @see io.swagger.codegen.CodegenType */ @@ -180,48 +186,58 @@ public String getName() { * * @return A string value for the help message */ - public String getHelp() { - return "Generates an elixir client library (alpha)."; - } - - @Override - public void processOpts() { - super.processOpts(); - additionalProperties.put("supportedElixirVersion", supportedElixirVersion); - additionalProperties.put("extraApplications", join(",", extraApplications)); - additionalProperties.put("deps", deps); - additionalProperties.put("underscored", new Mustache.Lambda() { - @Override + public String getHelp() { + return "Generates an elixir client library (alpha)."; + } + + @Override + public void processOpts() { + super.processOpts(); + additionalProperties.put("supportedElixirVersion", supportedElixirVersion); + additionalProperties.put("extraApplications", join(",", extraApplications)); + additionalProperties.put("deps", deps); + additionalProperties.put("underscored", new Mustache.Lambda() { + @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { - writer.write(underscored(fragment.execute())); - } - }); - additionalProperties.put("modulized", new Mustache.Lambda() { - @Override + writer.write(underscored(fragment.execute())); + } + }); + additionalProperties.put("atom", new Mustache.Lambda() { + @Override + public void execute(Template.Fragment fragment, Writer writer) + throws IOException { + writer.write(atom(fragment.execute())); + } + }); + additionalProperties.put("modulized", new Mustache.Lambda() { + @Override public void execute(Template.Fragment fragment, Writer writer) throws IOException { - writer.write(modulized(fragment.execute())); - } - }); + writer.write(modulized(fragment.execute())); + } + }); + + final Map typeMapping4lambda = this.typeMapping; + final Map props = this.additionalProperties; - if (additionalProperties.containsKey(CodegenConstants.INVOKER_PACKAGE)) { + if (additionalProperties.get(CodegenConstants.INVOKER_PACKAGE) !=null ) { setModuleName((String) additionalProperties.get(CodegenConstants.INVOKER_PACKAGE)); - } } + } + + @Override + public void preprocessSwagger(Swagger swagger) { + Info info = swagger.getInfo(); + if (moduleName == null) { + if (info.getTitle() != null) { + // default to the appName (from title field) + setModuleName(modulized(escapeText(info.getTitle()))); + } else { + setModuleName(defaultModuleName); + } + } + additionalProperties.put("moduleName", moduleName); - @Override - public void preprocessSwagger(Swagger swagger) { - Info info = swagger.getInfo(); - if (moduleName == null) { - if (info.getTitle() != null) { - // default to the appName (from title field) - setModuleName(modulized(escapeText(info.getTitle()))); - } else { - setModuleName(defaultModuleName); - } - } - additionalProperties.put("moduleName", moduleName); - - if (!additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { + if (!additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { additionalProperties.put(CodegenConstants.PACKAGE_NAME, underscored(moduleName)); } @@ -239,43 +255,49 @@ public void preprocessSwagger(Swagger swagger) { "deserializer.ex")); } - @Override - public Map postProcessOperations(Map objs) { - Map operations = (Map) super.postProcessOperations(objs).get("operations"); - List os = (List) operations.get("operation"); - List newOs = new ArrayList(); - Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}([^\\{]*)"); - for (CodegenOperation o : os) { - ArrayList pathTemplateNames = new ArrayList(); - Matcher matcher = pattern.matcher(o.path); - StringBuffer buffer = new StringBuffer(); - while (matcher.find()) { - String pathTemplateName = matcher.group(1); - matcher.appendReplacement(buffer, "#{" + underscore(pathTemplateName) + "}" + "$2"); - pathTemplateNames.add(pathTemplateName); - } - ExtendedCodegenOperation eco = new ExtendedCodegenOperation(o); - if (buffer.toString().isEmpty()) { - eco.setReplacedPathName(o.path); - } else { - eco.setReplacedPathName(buffer.toString()); - } - eco.setPathTemplateNames(pathTemplateNames); - - // detect multipart form types - if (eco.hasConsumes == Boolean.TRUE) { - Map firstType = eco.consumes.get(0); - if (firstType != null) { - if ("multipart/form-data".equals(firstType.get("mediaType"))) { - eco.isMultipart = Boolean.TRUE; - } - } - } - - newOs.add(eco); + @Override + public Map postProcessOperations(Map objs) { + Map operations = + (Map)super.postProcessOperations(objs).get( + "operations"); + List os = + (List)operations.get("operation"); + List newOs = + new ArrayList(); + Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}([^\\{]*)"); + for (CodegenOperation o : os) { + ArrayList pathTemplateNames = new ArrayList(); + Matcher matcher = pattern.matcher(o.path); + StringBuffer buffer = new StringBuffer(); + while (matcher.find()) { + String pathTemplateName = matcher.group(1); + matcher.appendReplacement(buffer, "#{" + underscore(pathTemplateName) + + "}" + + "$2"); + pathTemplateNames.add(pathTemplateName); + } + ExtendedCodegenOperation eco = new ExtendedCodegenOperation(o); + if (buffer.toString().isEmpty()) { + eco.setReplacedPathName(o.path); + } else { + eco.setReplacedPathName(buffer.toString()); + } + eco.setPathTemplateNames(pathTemplateNames); + + // detect multipart form types + if (eco.hasConsumes == Boolean.TRUE) { + Map firstType = eco.consumes.get(0); + if (firstType != null) { + if ("multipart/form-data".equals(firstType.get("mediaType"))) { + eco.isMultipart = Boolean.TRUE; + } } - operations.put("operation", newOs); - return objs; + } + + newOs.add(eco); + } + operations.put("operation", newOs); + return objs; } @Override @@ -284,32 +306,51 @@ public CodegenModel fromModel(String name, Model model, Map allDe return new ExtendedCodegenModel(cm); } - // We should use String.join if we can use Java8 - String join(CharSequence charSequence, Iterable iterable) { - StringBuilder buf = new StringBuilder(); - for (String str : iterable) { - if (0 < buf.length()) { - buf.append((charSequence)); - } - buf.append(str); - } - return buf.toString(); + // We should use String.join if we can use Java8 + String join(CharSequence charSequence, Iterable iterable) { + StringBuilder buf = new StringBuilder(); + for (String str : iterable) { + if (0 < buf.length()) { + buf.append((charSequence)); + } + buf.append(str); } + return buf.toString(); + } - String underscored(String words) { - ArrayList underscoredWords = new ArrayList(); - for (String word : words.split(" ")) { - underscoredWords.add(underscore(word)); - } - return join("_", underscoredWords); + String underscored(String words) { + ArrayList underscoredWords = new ArrayList(); + for (String word : words.split("[ ]")) { + underscoredWords.add(underscore(word)); } + String finalClean = join("_", underscoredWords); + return String.join("_", finalClean.split("[/]")); + } - String modulized(String words) { - ArrayList modulizedWords = new ArrayList(); - for (String word : words.split(" ")) { - modulizedWords.add(camelize(word)); - } - return join("", modulizedWords); + public String atom(String word) { + if (word.isEmpty()) { + return ":\"\""; // Empty atom + } + + // Pattern for valid unquoted atom (starts with lowercase letter or + // underscore, followed by letters, numbers, underscores, or @) + Pattern validUnquotedAtom = Pattern.compile("^[a-z_][a-zA-Z0-9_@]*[!?]?$"); + + if (validUnquotedAtom.matcher(word).matches()) { + return ":" + word; // Unquoted atom + } else { + // Quote the atom and escape any double quotes within + String escaped = word.replace("\"", "\\\""); + return ":\"" + escaped + "\""; // Quoted atom + } + } + + String modulized(String words) { + ArrayList modulizedWords = new ArrayList(); + for (String word : words.split(" ")) { + modulizedWords.add(camelize(word)); + } + return join("", modulizedWords); } /** @@ -324,11 +365,11 @@ public String escapeReservedWord(String name) { } private String sourceFolder() { - ArrayList underscoredWords = new ArrayList(); - for (String word : moduleName.split("\\.")) { - underscoredWords.add(underscore(word)); - } - return "lib/" + join("/", underscoredWords); + ArrayList underscoredWords = new ArrayList(); + for (String word : moduleName.split("\\.")) { + underscoredWords.add(underscore(word)); + } + return "lib/" + join("/", underscoredWords); } /** @@ -349,40 +390,40 @@ public String apiFileFolder() { } @Override - public String toApiName(String name) { - if (name.length() == 0) { - return "Default"; - } - return camelize(name); + public String toApiName(String name) { + if (name.length() == 0) { + return "Default"; } - - @Override - public String toApiFilename(String name) { - // replace - with _ e.g. created-at => created_at - name = name.replaceAll("-", "_"); - - // e.g. PetApi.go => pet_api.go - return underscore(name); + return camelize(name); + } + + @Override + public String toApiFilename(String name) { + // replace - with _ e.g. created-at => created_at + name = name.replaceAll("-", "_"); + + // e.g. PetApi.go => pet_api.go + return underscore(name); + } + + @Override + public String toModelName(String name) { + // camelize the model name + // phone_number => PhoneNumber + return camelize(toModelFilename(name)); + } + + @Override + public String toModelFilename(String name) { + if (!StringUtils.isEmpty(modelNamePrefix)) { + name = modelNamePrefix + "_" + name; } - @Override - public String toModelName(String name) { - // camelize the model name - // phone_number => PhoneNumber - return camelize(toModelFilename(name)); + if (!StringUtils.isEmpty(modelNameSuffix)) { + name = name + "_" + modelNameSuffix; } - @Override - public String toModelFilename(String name) { - if (!StringUtils.isEmpty(modelNamePrefix)) { - name = modelNamePrefix + "_" + name; - } - - if (!StringUtils.isEmpty(modelNameSuffix)) { - name = name + "_" + modelNameSuffix; - } - - name = sanitizeName(name); + name = sanitizeName(name); // model name cannot use reserved keyword, e.g. return if (isReservedWord(name)) { @@ -396,8 +437,8 @@ public String toModelFilename(String name) { name = "model_" + name; // e.g. 200Response => Model200Response (after camelize) } - return underscore(name); - } + return underscore(name); + } @Override public String toOperationId(String operationId) { @@ -406,7 +447,17 @@ public String toOperationId(String operationId) { throw new RuntimeException("Empty method name (operationId) not allowed"); } - return camelize(sanitizeName(operationId)); + return camelize(sanitizeName(operationId)); + } + + private String getModelPackageName() { + Object moduleName = this.additionalProperties.get("moduleName"); + Object invokerPackage = this.additionalProperties.get(CodegenConstants.INVOKER_PACKAGE); + if(moduleName!= null) { + return "" + moduleName + ".Model"; + }else { + return "" + invokerPackage + ".Model"; + } } /** @@ -417,79 +468,89 @@ public String toOperationId(String operationId) { */ @Override public String getTypeDeclaration(Property p) { - // SubClasses of AbstractProperty - // - // ArrayProperty - // MapProperty - // PasswordProperty - // StringProperty - // EmailProperty - // ByteArrayProperty - // DateProperty - // UUIDProperty - // DateTimeProperty - // ObjectProperty - // AbstractNumericProperty - // BaseIntegerProperty - // IntegerProperty - // LongProperty - // DecimalProperty - // DoubleProperty - // FloatProperty - // BinaryProperty - // BooleanProperty + // SubClasses of AbstractProperty + // + // ArrayProperty + // MapProperty + // PasswordProperty + // StringProperty + // EmailProperty + // ByteArrayProperty + // DateProperty + // UUIDProperty + // DateTimeProperty + // ObjectProperty + // AbstractNumericProperty + // BaseIntegerProperty + // IntegerProperty + // LongProperty + // DecimalProperty + // DoubleProperty + // FloatProperty + // BinaryProperty + // BooleanProperty // RefProperty // FileProperty if (p instanceof ArrayProperty) { ArrayProperty ap = (ArrayProperty) p; Property inner = ap.getItems(); - return "[" + getTypeDeclaration(inner) + "]"; + String innerType = getTypeDeclaration(inner); + if(MODULE_PATTERN.matcher(innerType).matches()) { + return "[" + innerType + ".t()" +"]"; + }else { + return "[" + innerType + "]"; + } } else if (p instanceof MapProperty) { MapProperty mp = (MapProperty) p; Property inner = mp.getAdditionalProperties(); - return "%{optional(String.t) => " + getTypeDeclaration(inner) + "}"; + String innerType = getTypeDeclaration(inner); + if(MODULE_PATTERN.matcher(innerType).matches()) { + return "%{optional(String.t) => " + getTypeDeclaration(inner) + ".t()" + "}"; + }else { + return "%{optional(String.t) => " + getTypeDeclaration(inner) + "}"; + } } else if (p instanceof PasswordProperty) { - return "String.t"; - } else if (p instanceof EmailProperty) { - return "String.t"; - } else if (p instanceof ByteArrayProperty) { - return "binary()"; - } else if (p instanceof StringProperty) { - return "String.t"; - } else if (p instanceof DateProperty) { - return "Date.t"; - } else if (p instanceof UUIDProperty) { - return "String.t"; - } else if (p instanceof DateTimeProperty) { - return "DateTime.t"; - } else if (p instanceof ObjectProperty) { - // How to map it? - return super.getTypeDeclaration(p); - } else if (p instanceof IntegerProperty) { - return "integer()"; - } else if (p instanceof LongProperty) { - return "integer()"; - } else if (p instanceof BaseIntegerProperty) { - return "integer()"; - } else if (p instanceof DoubleProperty) { - return "float()"; - } else if (p instanceof FloatProperty) { - return "float()"; - } else if (p instanceof DecimalProperty) { - return "float()"; - } else if (p instanceof AbstractNumericProperty) { - return "number()"; - } else if (p instanceof BinaryProperty) { - return "binary()"; - } else if (p instanceof BooleanProperty) { - return "boolean()"; - } else if (p instanceof RefProperty) { - // How to map it? - return super.getTypeDeclaration(p); - } else if (p instanceof FileProperty) { - return "String.t"; - } - return super.getTypeDeclaration(p); + return "String.t"; + } else if (p instanceof EmailProperty) { + return "String.t"; + } else if (p instanceof ByteArrayProperty) { + return "binary()"; + } else if (p instanceof StringProperty) { + return "String.t"; + } else if (p instanceof DateProperty) { + return "Date.t"; + } else if (p instanceof UUIDProperty) { + return "String.t"; + } else if (p instanceof DateTimeProperty) { + return "DateTime.t"; + } else if (p instanceof ObjectProperty) { + // How to map it? + return super.getTypeDeclaration(p); + } else if (p instanceof IntegerProperty) { + return "integer()"; + } else if (p instanceof LongProperty) { + return "integer()"; + } else if (p instanceof BaseIntegerProperty) { + return "integer()"; + } else if (p instanceof DoubleProperty) { + return "float()"; + } else if (p instanceof FloatProperty) { + return "float()"; + } else if (p instanceof DecimalProperty) { + return "float()"; + } else if (p instanceof AbstractNumericProperty) { + return "number()"; + } else if (p instanceof BinaryProperty) { + return "binary()"; + } else if (p instanceof BooleanProperty) { + return "boolean()"; + } else if (p instanceof RefProperty) { + // How to map it? + return "" + getModelPackageName() + "." + super.getTypeDeclaration(p); + } else if (p instanceof FileProperty) { + return "String.t"; + } + return super.getTypeDeclaration(p); } /** @@ -498,79 +559,79 @@ public String getTypeDeclaration(Property p) { * * @return a string value of the type or complex model for this property * @see io.swagger.models.properties.Property - */ - @Override - public String getSwaggerType(Property p) { - String swaggerType = super.getSwaggerType(p); - String type = null; - if (typeMapping.containsKey(swaggerType)) { - type = typeMapping.get(swaggerType); - if (languageSpecificPrimitives.contains(type)) - return toModelName(type); - } else - type = swaggerType; + */ + @Override + public String getSwaggerType(Property p) { + String swaggerType = super.getSwaggerType(p); + String type = null; + if (typeMapping.containsKey(swaggerType)) { + type = typeMapping.get(swaggerType); + if (languageSpecificPrimitives.contains(type)) return toModelName(type); - } - - class ExtendedCodegenOperation extends CodegenOperation { - private List pathTemplateNames = new ArrayList(); - private String replacedPathName; - - public ExtendedCodegenOperation(CodegenOperation o) { - super(); - - // Copy all fields of CodegenOperation - this.responseHeaders.addAll(o.responseHeaders); - this.hasAuthMethods = o.hasAuthMethods; - this.hasConsumes = o.hasConsumes; - this.hasProduces = o.hasProduces; - this.hasParams = o.hasParams; - this.hasOptionalParams = o.hasOptionalParams; - this.returnTypeIsPrimitive = o.returnTypeIsPrimitive; - this.returnSimpleType = o.returnSimpleType; - this.subresourceOperation = o.subresourceOperation; - this.isMapContainer = o.isMapContainer; - this.isListContainer = o.isListContainer; - this.isMultipart = o.isMultipart; - this.hasMore = o.hasMore; - this.isResponseBinary = o.isResponseBinary; - this.hasReference = o.hasReference; - this.isRestfulIndex = o.isRestfulIndex; - this.isRestfulShow = o.isRestfulShow; - this.isRestfulCreate = o.isRestfulCreate; - this.isRestfulUpdate = o.isRestfulUpdate; - this.isRestfulDestroy = o.isRestfulDestroy; - this.isRestful = o.isRestful; - this.path = o.path; - this.operationId = o.operationId; - this.returnType = o.returnType; - this.httpMethod = o.httpMethod; - this.returnBaseType = o.returnBaseType; - this.returnContainer = o.returnContainer; - this.summary = o.summary; - this.unescapedNotes = o.unescapedNotes; - this.notes = o.notes; - this.baseName = o.baseName; - this.defaultResponse = o.defaultResponse; - this.discriminator = o.discriminator; - this.consumes = o.consumes; - this.produces = o.produces; - this.bodyParam = o.bodyParam; - this.allParams = o.allParams; - this.bodyParams = o.bodyParams; - this.pathParams = o.pathParams; - this.queryParams = o.queryParams; - this.headerParams = o.headerParams; - this.formParams = o.formParams; - this.authMethods = o.authMethods; - this.tags = o.tags; - this.responses = o.responses; - this.imports = o.imports; - this.examples = o.examples; - this.externalDocs = o.externalDocs; - this.vendorExtensions = o.vendorExtensions; - this.nickname = o.nickname; - this.operationIdLowerCase = o.operationIdLowerCase; + } else + type = swaggerType; + return toModelName(type); + } + + class ExtendedCodegenOperation extends CodegenOperation { + private List pathTemplateNames = new ArrayList(); + private String replacedPathName; + + public ExtendedCodegenOperation(CodegenOperation o) { + super(); + + // Copy all fields of CodegenOperation + this.responseHeaders.addAll(o.responseHeaders); + this.hasAuthMethods = o.hasAuthMethods; + this.hasConsumes = o.hasConsumes; + this.hasProduces = o.hasProduces; + this.hasParams = o.hasParams; + this.hasOptionalParams = o.hasOptionalParams; + this.returnTypeIsPrimitive = o.returnTypeIsPrimitive; + this.returnSimpleType = o.returnSimpleType; + this.subresourceOperation = o.subresourceOperation; + this.isMapContainer = o.isMapContainer; + this.isListContainer = o.isListContainer; + this.isMultipart = o.isMultipart; + this.hasMore = o.hasMore; + this.isResponseBinary = o.isResponseBinary; + this.hasReference = o.hasReference; + this.isRestfulIndex = o.isRestfulIndex; + this.isRestfulShow = o.isRestfulShow; + this.isRestfulCreate = o.isRestfulCreate; + this.isRestfulUpdate = o.isRestfulUpdate; + this.isRestfulDestroy = o.isRestfulDestroy; + this.isRestful = o.isRestful; + this.path = o.path; + this.operationId = o.operationId; + this.returnType = o.returnType; + this.httpMethod = o.httpMethod; + this.returnBaseType = o.returnBaseType; + this.returnContainer = o.returnContainer; + this.summary = o.summary; + this.unescapedNotes = o.unescapedNotes; + this.notes = o.notes; + this.baseName = o.baseName; + this.defaultResponse = o.defaultResponse; + this.discriminator = o.discriminator; + this.consumes = o.consumes; + this.produces = o.produces; + this.bodyParam = o.bodyParam; + this.allParams = o.allParams; + this.bodyParams = o.bodyParams; + this.pathParams = o.pathParams; + this.queryParams = o.queryParams; + this.headerParams = o.headerParams; + this.formParams = o.formParams; + this.authMethods = o.authMethods; + this.tags = o.tags; + this.responses = o.responses; + this.imports = o.imports; + this.examples = o.examples; + this.externalDocs = o.externalDocs; + this.vendorExtensions = o.vendorExtensions; + this.nickname = o.nickname; + this.operationIdLowerCase = o.operationIdLowerCase; this.operationIdCamelCase = o.operationIdCamelCase; } @@ -588,103 +649,107 @@ public String getReplacedPathName() { public void setReplacedPathName(String replacedPathName) { this.replacedPathName = replacedPathName; - } - - public String typespec() { - StringBuilder sb = new StringBuilder("@spec "); - sb.append(underscore(operationId)); - sb.append("(Tesla.Env.client, "); + } - for (CodegenParameter param : allParams) { - if (param.required) { - buildTypespec(param, sb); - sb.append(", "); - } - } + public String typespec() { + StringBuilder sb = new StringBuilder("@spec "); + sb.append(underscore(operationId)); + sb.append("(Tesla.Env.client, "); - sb.append("keyword()) :: {:ok, "); - if (returnBaseType == null) { - sb.append("nil"); - } else if (returnSimpleType) { - if (!returnTypeIsPrimitive) { - sb.append(moduleName); - sb.append(".Model."); - } - sb.append(returnBaseType); - sb.append(".t"); - } else if (returnContainer == null) { - sb.append(returnBaseType); - sb.append(".t"); - } else { - if (returnContainer.equals("array")) { - sb.append("list("); - if (!returnTypeIsPrimitive) { - sb.append(moduleName); - sb.append(".Model."); - } - sb.append(returnBaseType); - sb.append(".t)"); - } else if (returnContainer.equals("map")) { - sb.append("map()"); - } - } - sb.append("} | {:error, Tesla.Env.t}"); - return sb.toString(); + for (CodegenParameter param : allParams) { + if (param.required) { + buildTypespec(param, sb); + sb.append(", "); } - - private void buildTypespec(CodegenParameter param, StringBuilder sb) { - if (param.dataType == null) { - sb.append("nil"); - } else if (param.isListContainer) { - // list() - sb.append("list("); - if (param.isBodyParam) { - buildTypespec(param.items.items, sb); - } else { - buildTypespec(param.items, sb); - } - sb.append(")"); - } else if (param.isMapContainer) { - // %{optional(String.t) => } - sb.append("%{optional(String.t) => "); - buildTypespec(param.items, sb); - sb.append("}"); - } else if (param.isPrimitiveType) { - // like `integer()`, `String.t` - sb.append(param.dataType); - } else if (param.isFile) { - sb.append("String.t"); - } else { - // .Model..t - sb.append(moduleName); - sb.append(".Model."); - sb.append(param.dataType); - sb.append(".t"); - } + } + + sb.append("keyword()) :: {:ok, "); + if (returnBaseType == null) { + sb.append("nil"); + } else if (returnSimpleType) { + if (!returnTypeIsPrimitive) { + sb.append(moduleName); + sb.append(".Model."); } - private void buildTypespec(CodegenProperty property, StringBuilder sb) { - if (property.isListContainer) { - sb.append("list("); - buildTypespec(property.items, sb); - sb.append(")"); - } else if (property.isMapContainer) { - sb.append("%{optional(String.t) => "); - buildTypespec(property.items, sb); - sb.append("}"); - } else if (property.isPrimitiveType) { - sb.append(property.baseType); - sb.append(".t"); - } else { - sb.append(moduleName); - sb.append(".Model."); - sb.append(property.baseType); - sb.append(".t"); - } + if(returnBaseType.equals("Map")) { + sb.append("%{}"); + }else { + sb.append(returnBaseType); + sb.append(".t"); + } + } else if (returnContainer == null) { + sb.append(returnBaseType); + sb.append(".t"); + } else { + if (returnContainer.equals("array")) { + sb.append("list("); + if (!returnTypeIsPrimitive) { + sb.append(moduleName); + sb.append(".Model."); + } + sb.append(returnBaseType); + sb.append(".t)"); + } else if (returnContainer.equals("map")) { + sb.append("map()"); } + } + sb.append("} | {:error, Tesla.Env.t}"); + return sb.toString(); + } - public String decodedStruct() { - // Let Poison decode the entire response into a generic blob - if (isMapContainer) { + private void buildTypespec(CodegenParameter param, StringBuilder sb) { + if (param.dataType == null) { + sb.append("nil"); + } else if (param.isListContainer) { + // list() + sb.append("list("); + if (param.isBodyParam) { + buildTypespec(param.items.items, sb); + } else { + buildTypespec(param.items, sb); + } + sb.append(")"); + } else if (param.isMapContainer) { + // %{optional(String.t) => } + sb.append("%{optional(String.t) => "); + buildTypespec(param.items, sb); + sb.append("}"); + } else if (param.isPrimitiveType) { + // like `integer()`, `String.t` + sb.append(param.dataType); + } else if (param.isFile) { + sb.append("String.t"); + } else { + // .Model..t + sb.append(moduleName); + sb.append(".Model."); + sb.append(param.dataType); + sb.append(".t"); + } + } + private void buildTypespec(CodegenProperty property, StringBuilder sb) { + if (property.isListContainer) { + sb.append("list("); + buildTypespec(property.items, sb); + sb.append(")"); + } else if (property.isMapContainer) { + sb.append("%{optional(String.t) => "); + buildTypespec(property.items, sb); + sb.append("}"); + } else if (property.isPrimitiveType) { + sb.append(property.baseType); + sb.append(".t"); + } else { + sb.append(moduleName); + sb.append(".Model."); + sb.append(property.baseType); + 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 @@ -692,94 +757,94 @@ public String decodedStruct() { return "false"; } 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(); - } + 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 { + public boolean hasImports; + public ExtendedCodegenModel(CodegenModel cm) { + super(); + + // Copy all fields of CodegenModel + this.parent = cm.parent; + this.parentSchema = cm.parentSchema; + this.parentModel = cm.parentModel; + this.interfaceModels = cm.interfaceModels; + this.children = cm.children; + this.name = cm.name; + this.classname = cm.classname; + this.title = cm.title; + this.description = cm.description; + this.classVarName = cm.classVarName; + this.modelJson = cm.modelJson; + this.dataType = cm.dataType; + this.xmlPrefix = cm.xmlPrefix; + this.xmlNamespace = cm.xmlNamespace; + this.xmlName = cm.xmlName; + this.classFilename = cm.classFilename; + this.unescapedDescription = cm.unescapedDescription; + this.discriminator = cm.discriminator; + this.defaultValue = cm.defaultValue; + this.arrayModelType = cm.arrayModelType; + this.isAlias = cm.isAlias; + this.vars = cm.vars; + this.requiredVars = cm.requiredVars; + this.optionalVars = cm.optionalVars; + this.readOnlyVars = cm.readOnlyVars; + this.readWriteVars = cm.readWriteVars; + this.allVars = cm.allVars; + this.parentVars = cm.parentVars; + this.allowableValues = cm.allowableValues; + this.mandatory = cm.mandatory; + this.allMandatory = cm.allMandatory; + this.imports = cm.imports; + this.hasVars = cm.hasVars; + this.emptyVars = cm.emptyVars; + this.hasMoreModels = cm.hasMoreModels; + this.hasEnums = cm.hasEnums; + this.isEnum = cm.isEnum; + this.hasRequired = cm.hasRequired; + this.hasOptional = cm.hasOptional; + this.isArrayModel = cm.isArrayModel; + this.hasChildren = cm.hasChildren; + this.hasOnlyReadOnly = cm.hasOnlyReadOnly; + this.externalDocs = cm.externalDocs; + this.vendorExtensions = cm.vendorExtensions; + this.additionalPropertiesType = cm.additionalPropertiesType; + + this.hasImports = !this.imports.isEmpty(); } - class ExtendedCodegenModel extends CodegenModel { - public boolean hasImports; - public ExtendedCodegenModel(CodegenModel cm) { - super(); - - // Copy all fields of CodegenModel - this.parent = cm.parent; - this.parentSchema = cm.parentSchema; - this.parentModel = cm.parentModel; - this.interfaceModels = cm.interfaceModels; - this.children = cm.children; - this.name = cm.name; - this.classname = cm.classname; - this.title = cm.title; - this.description = cm.description; - this.classVarName = cm.classVarName; - this.modelJson = cm.modelJson; - this.dataType = cm.dataType; - this.xmlPrefix = cm.xmlPrefix; - this.xmlNamespace = cm.xmlNamespace; - this.xmlName = cm.xmlName; - this.classFilename = cm.classFilename; - this.unescapedDescription = cm.unescapedDescription; - this.discriminator = cm.discriminator; - this.defaultValue = cm.defaultValue; - this.arrayModelType = cm.arrayModelType; - this.isAlias = cm.isAlias; - this.vars = cm.vars; - this.requiredVars = cm.requiredVars; - this.optionalVars = cm.optionalVars; - this.readOnlyVars = cm.readOnlyVars; - this.readWriteVars = cm.readWriteVars; - this.allVars = cm.allVars; - this.parentVars = cm.parentVars; - this.allowableValues = cm.allowableValues; - this.mandatory = cm.mandatory; - this.allMandatory = cm.allMandatory; - this.imports = cm.imports; - this.hasVars = cm.hasVars; - this.emptyVars = cm.emptyVars; - this.hasMoreModels = cm.hasMoreModels; - this.hasEnums = cm.hasEnums; - this.isEnum = cm.isEnum; - this.hasRequired = cm.hasRequired; - this.hasOptional = cm.hasOptional; - this.isArrayModel = cm.isArrayModel; - this.hasChildren = cm.hasChildren; - this.hasOnlyReadOnly = cm.hasOnlyReadOnly; - this.externalDocs = cm.externalDocs; - this.vendorExtensions = cm.vendorExtensions; - this.additionalPropertiesType = cm.additionalPropertiesType; - - this.hasImports = !this.imports.isEmpty(); - } - - public boolean hasComplexVars() { - for (CodegenProperty p : vars) { - if (!p.isPrimitiveType) { - return true; - } - } - return false; + public boolean hasComplexVars() { + for (CodegenProperty p : vars) { + if (!p.isPrimitiveType) { + return true; } + } + return false; } + } - @Override - public String escapeQuotationMark(String input) { - return input.replace("\"", ""); - } + @Override + public String escapeQuotationMark(String input) { + return input.replace("\"", ""); + } - @Override - public String escapeUnsafeCharacters(String input) { - // no need to escape as Elixir does not support multi-line comments + @Override + public String escapeUnsafeCharacters(String input) { + // no need to escape as Elixir does not support multi-line comments return input; } diff --git a/modules/swagger-codegen/src/main/resources/elixir/api.mustache b/modules/swagger-codegen/src/main/resources/elixir/api.mustache index ece4d62da9a..b13964c63ff 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/api.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/api.mustache @@ -20,21 +20,21 @@ 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}} + - connection (`{{moduleName}}.Connection`): Connection to server +{{#allParams}}{{#required}} - {{#underscored}}{{paramName}}{{/underscored}} (`{{dataType}}`): {{description}} +{{/required}}{{/allParams}} - opts (`KeywordList`): [optional] Optional parameters +{{#allParams}}{{^required}} - :{{paramName}} ({{dataType}}): {{description}} {{/required}}{{/allParams}} ## Returns - {:ok, {{#isListContainer}}[%{{returnBaseType}}{}, ...]{{/isListContainer}}{{#isMapContainer}}%{}{{/isMapContainer}}{{^returnType}}%{}{{/returnType}}{{#returnSimpleType}}%{{#returnType}}{{#isMapContainer}}{{/isMapContainer}}{{moduleName}}.Model.{{{returnType}}}{{/returnType}}{}{{/returnSimpleType}}} on success - {:error, info} on failure + `{:ok, {{#isListContainer}}[{{returnBaseType}}, ...]{{/isListContainer}}{{#isMapContainer}}%{}{{/isMapContainer}}{{^returnType}}%{}{{/returnType}}{{#returnSimpleType}}{{#returnType}}{{#isMapContainer}}{{/isMapContainer}}{{{returnType}}}{{/returnType}}{{/returnSimpleType}}{{{closebrace}}}` on success + `{:error, info}` on failure """ {{typespec}} def {{#underscored}}{{operationId}}{{/underscored}}(connection, {{#allParams}}{{#required}}{{#underscored}}{{paramName}}{{/underscored}}, {{/required}}{{/allParams}}{{^hasOptionalParams}}_{{/hasOptionalParams}}opts \\ []) do {{#hasOptionalParams}} optional_params = %{ - {{#allParams}}{{^required}}{{^isPathParam}}:"{{baseName}}" => {{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}:form{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}{{/isPathParam}}{{#hasMore}}, + {{#allParams}}{{^required}}{{^isPathParam}}{{#atom}}{{baseName}}{{/atom}} => {{#isBodyParam}}:body{{/isBodyParam}}{{#isFormParam}}:form{{/isFormParam}}{{#isQueryParam}}:query{{/isQueryParam}}{{#isHeaderParam}}:headers{{/isHeaderParam}}{{/isPathParam}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}} } {{/hasOptionalParams}} diff --git a/modules/swagger-codegen/src/main/resources/elixir/connection.ex.mustache b/modules/swagger-codegen/src/main/resources/elixir/connection.ex.mustache index 9e10634e285..44da2199679 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/connection.ex.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/connection.ex.mustache @@ -33,7 +33,7 @@ defmodule {{moduleName}}.Connection do """ @spec new(String.t) :: Tesla.Env.client def new(token) when is_binary(token) do - Tesla.build_client([ + Tesla.client([ {Tesla.Middleware.Headers, %{"Authorization" => "Bearer #{token}"}} ]) end @@ -71,7 +71,7 @@ defmodule {{moduleName}}.Connection do """ @spec new(String.t, String.t) :: Tesla.Env.client def new(username, password) do - Tesla.build_client([ + Tesla.client([ {Tesla.Middleware.BasicAuth, %{username: username, password: password}} ]) end @@ -87,6 +87,6 @@ defmodule {{moduleName}}.Connection do """ @spec new() :: Tesla.Env.client def new do - Tesla.build_client([]) + Tesla.client([]) end end diff --git a/modules/swagger-codegen/src/main/resources/elixir/deserializer.ex.mustache b/modules/swagger-codegen/src/main/resources/elixir/deserializer.ex.mustache index ada1cf1346d..7fc2e5d8020 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/deserializer.ex.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/deserializer.ex.mustache @@ -7,20 +7,20 @@ defmodule {{moduleName}}.Deserializer do @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 + @spec deserialize(map(), atom(), atom(), module(), map()) :: map() + def deserialize(model, field, :list, mod, %{} = options) do model - |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: [struct(mod)]])))) + |> Map.update!(field, &(Poison.Decode.transform(&1, Map.merge(options, %{as: [struct(mod)]})))) end - def deserialize(model, field, :struct, mod, options) do + def deserialize(model, field, :struct, mod,%{} = options) do model - |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: struct(mod)])))) + |> Map.update!(field, &(Poison.Decode.transform(&1, Map.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))) + model + |> Map.update!(field, &(Map.new(&1 || %{}, fn {key, val} -> {key, Poison.Decode.transform(val, Map.merge(options, %{as: struct(mod)}))} end))) end - def deserialize(model, field, :date, _, _options) do + def deserialize(model, field, :date, _, %{} = _options) do value = Map.get(model, field) case is_binary(value) do true -> case DateTime.from_iso8601(value) do diff --git a/modules/swagger-codegen/src/main/resources/elixir/model.mustache b/modules/swagger-codegen/src/main/resources/elixir/model.mustache index ea43f78e0fc..209fcfa756d 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/model.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/model.mustache @@ -6,12 +6,12 @@ @derive [Poison.Encoder] defstruct [ - {{#vars}}:"{{baseName}}"{{#hasMore}}, + {{#vars}}{{#atom}}{{baseName}}{{/atom}}{{#hasMore}}, {{/hasMore}}{{/vars}} ] @type t :: %__MODULE__{ - {{#vars}}:"{{baseName}}" => {{{datatype}}}{{#hasMore}}, + {{#vars}}{{#atom}}{{baseName}}{{/atom}} => {{{datatype}}}{{#hasMore}}, {{/hasMore}}{{/vars}} } end @@ -23,7 +23,7 @@ defimpl Poison.Decoder, for: {{moduleName}}.Model.{{classname}} do value {{#vars}} {{^isPrimitiveType}} - {{#datatype}}|> deserialize(:"{{baseName}}", {{#isListContainer}}:list, {{moduleName}}.Model.{{items.datatype}}{{/isListContainer}}{{#isMapContainer}}:map, {{moduleName}}.Model.{{items.datatype}}{{/isMapContainer}}{{#isDate}}:date, nil{{/isDate}}{{#isDateTime}}:date, nil{{/isDateTime}}{{^isDate}}{{^isDateTime}}{{^isMapContainer}}{{^isListContainer}}:struct, {{moduleName}}.Model.{{datatype}}{{/isListContainer}}{{/isMapContainer}}{{/isDateTime}}{{/isDate}}, options) + {{#datatype}}|> deserialize({{#atom}}{{baseName}}{{/atom}}, {{#isListContainer}}:list, {{items.datatype}}{{/isListContainer}}{{#isMapContainer}}:map, {{items.datatype}}{{/isMapContainer}}{{#isDate}}:date, nil{{/isDate}}{{#isDateTime}}:date, nil{{/isDateTime}}{{^isDate}}{{^isDateTime}}{{^isMapContainer}}{{^isListContainer}}:struct, {{datatype}}{{/isListContainer}}{{/isMapContainer}}{{/isDateTime}}{{/isDate}}, options) {{/datatype}} {{/isPrimitiveType}} {{/vars}} diff --git a/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache b/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache index 191832e9bdb..fa2ae0c354c 100644 --- a/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache +++ b/modules/swagger-codegen/src/main/resources/elixir/request_builder.ex.mustache @@ -111,12 +111,12 @@ defmodule {{moduleName}}.RequestBuilder do {:ok, struct} on success {:error, term} on failure """ - @spec decode(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(%Tesla.Env{status: 200, body: body}), do: Poison.decode(body) def decode(response), do: {:error, response} - @spec decode(Tesla.Env.t | term(), :false | struct() | [struct()]) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()} def decode(%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(%Tesla.Env{status: 200, body: body}, struct), do: Poison.decode(body, as: struct) def decode(response, _struct), do: {:error, response} end diff --git a/samples/client/petstore/elixir/.swagger-codegen/VERSION b/samples/client/petstore/elixir/.swagger-codegen/VERSION index 017674fb59d..717311e32e3 100644 --- a/samples/client/petstore/elixir/.swagger-codegen/VERSION +++ b/samples/client/petstore/elixir/.swagger-codegen/VERSION @@ -1 +1 @@ -2.4.3-SNAPSHOT \ No newline at end of file +unset \ No newline at end of file diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/another_fake.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/another_fake.ex index 43d707f09ee..909030f582c 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/another_fake.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/another_fake.ex @@ -17,14 +17,14 @@ defmodule SwaggerPetstore.Api.AnotherFake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (Client): client model - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`Client`): client model + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %SwaggerPetstore.Model.Client{}} on success - {:error, info} on failure + `{: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 diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex index 397cd63e604..1b90811bd32 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake.ex @@ -16,19 +16,19 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - opts (`KeywordList`): [optional] Optional parameters - :body (OuterBoolean): Input boolean as post body ## Returns - {:ok, %SwaggerPetstore.Model.OuterBoolean{}} on success - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.OuterBoolean}` on success + `{:error, info}` on failure """ @spec fake_outer_boolean_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterBoolean.t} | {:error, Tesla.Env.t} def fake_outer_boolean_serialize(connection, opts \\ []) do optional_params = %{ - :"body" => :body + :body => :body } %{} |> method(:post) @@ -44,19 +44,19 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - opts (`KeywordList`): [optional] Optional parameters - :body (OuterComposite): Input composite as post body ## Returns - {:ok, %SwaggerPetstore.Model.OuterComposite{}} on success - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.OuterComposite}` on success + `{:error, info}` on failure """ @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 + :body => :body } %{} |> method(:post) @@ -72,19 +72,19 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - opts (`KeywordList`): [optional] Optional parameters - :body (OuterNumber): Input number as post body ## Returns - {:ok, %SwaggerPetstore.Model.OuterNumber{}} on success - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.OuterNumber}` on success + `{:error, info}` on failure """ @spec fake_outer_number_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterNumber.t} | {:error, Tesla.Env.t} def fake_outer_number_serialize(connection, opts \\ []) do optional_params = %{ - :"body" => :body + :body => :body } %{} |> method(:post) @@ -100,19 +100,19 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - opts (`KeywordList`): [optional] Optional parameters - :body (OuterString): Input string as post body ## Returns - {:ok, %SwaggerPetstore.Model.OuterString{}} on success - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.OuterString}` on success + `{:error, info}` on failure """ @spec fake_outer_string_serialize(Tesla.Env.client, keyword()) :: {:ok, SwaggerPetstore.Model.OuterString.t} | {:error, Tesla.Env.t} def fake_outer_string_serialize(connection, opts \\ []) do optional_params = %{ - :"body" => :body + :body => :body } %{} |> method(:post) @@ -127,15 +127,15 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (User): - - query (String.t): - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`User`): + - query (`String.t`): + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{:ok, %{}}` on success + `{:error, info}` on failure """ @spec test_body_with_query_params(Tesla.Env.client, SwaggerPetstore.Model.User.t, String.t, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_body_with_query_params(connection, body, query, _opts \\ []) do @@ -155,14 +155,14 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (Client): client model - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`Client`): client model + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %SwaggerPetstore.Model.Client{}} on success - {:error, info} on failure + `{: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 @@ -181,12 +181,12 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - number (float()): None - - double (float()): None - - pattern_without_delimiter (String.t): None - - byte (binary()): None - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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 @@ -200,22 +200,22 @@ defmodule SwaggerPetstore.Api.Fake do ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 + :integer => :form, + :int32 => :form, + :int64 => :form, + :float => :form, + :string => :form, + :binary => :form, + :date => :form, + :dateTime => :form, + :password => :form, + :callback => :form } %{} |> method(:post) @@ -236,8 +236,8 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - 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) @@ -249,20 +249,20 @@ defmodule SwaggerPetstore.Api.Fake do ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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_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_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 } %{} |> method(:get) @@ -279,16 +279,16 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - param (Object): request body - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - param (`Map`): request body + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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} + @spec test_inline_additional_properties(Tesla.Env.client, Map, keyword()) :: {:ok, nil} | {:error, Tesla.Env.t} def test_inline_additional_properties(connection, param, _opts \\ []) do %{} |> method(:post) @@ -305,15 +305,15 @@ defmodule SwaggerPetstore.Api.Fake do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - param (String.t): field1 - - param2 (String.t): field2 - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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 + `{: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 diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake_classname_tags123.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake_classname_tags123.ex index fccadef7628..e892da5032f 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/fake_classname_tags123.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/fake_classname_tags123.ex @@ -17,14 +17,14 @@ defmodule SwaggerPetstore.Api.FakeClassnameTags123 do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (Client): client model - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`Client`): client model + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %SwaggerPetstore.Model.Client{}} on success - {:error, info} on failure + `{: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 diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex index 035ad7c8cb1..c2897840814 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/pet.ex @@ -17,14 +17,14 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (Pet): Pet object that needs to be added to the store - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`Pet`): Pet object that needs to be added to the store + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -43,20 +43,20 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - pet_id (integer()): Pet id to delete - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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 + `{: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 + :api_key => :headers } %{} |> method(:delete) @@ -73,14 +73,14 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - status ([String.t]): Status values that need to be considered for filter - - opts (KeywordList): [optional] Optional parameters + - 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 - {:error, info} on failure + `{:ok, [Pet, ...]}` on success + `{:error, info}` on failure """ @spec find_pets_by_status(Tesla.Env.client, list(String.t), keyword()) :: {:ok, list(SwaggerPetstore.Model.Pet.t)} | {:error, Tesla.Env.t} def find_pets_by_status(connection, status, _opts \\ []) do @@ -99,14 +99,14 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - tags ([String.t]): Tags to filter by - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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 + `{:ok, [Pet, ...]}` on success + `{:error, info}` on failure """ @spec find_pets_by_tags(Tesla.Env.client, list(String.t), keyword()) :: {:ok, list(SwaggerPetstore.Model.Pet.t)} | {:error, Tesla.Env.t} def find_pets_by_tags(connection, tags, _opts \\ []) do @@ -125,14 +125,14 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet to return - - opts (KeywordList): [optional] Optional parameters + - 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 - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.Pet}` on success + `{:error, info}` on failure """ @spec get_pet_by_id(Tesla.Env.client, integer(), keyword()) :: {:ok, SwaggerPetstore.Model.Pet.t} | {:error, Tesla.Env.t} def get_pet_by_id(connection, pet_id, _opts \\ []) do @@ -150,14 +150,14 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (Pet): Pet object that needs to be added to the store - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`Pet`): Pet object that needs to be added to the store + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -176,22 +176,22 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet that needs to be updated - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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 + `{: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 + :name => :form, + :status => :form } %{} |> method(:post) @@ -208,22 +208,22 @@ defmodule SwaggerPetstore.Api.Pet do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - pet_id (integer()): ID of pet to update - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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, %SwaggerPetstore.Model.ApiResponse{}} on success - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.ApiResponse}` on success + `{:error, info}` on failure """ @spec upload_file(Tesla.Env.client, integer(), keyword()) :: {:ok, SwaggerPetstore.Model.ApiResponse.t} | {:error, Tesla.Env.t} def upload_file(connection, pet_id, opts \\ []) do optional_params = %{ - :"additionalMetadata" => :form, - :"file" => :form + :additionalMetadata => :form, + :file => :form } %{} |> method(:post) diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex index f604ecd82e7..01b8f199487 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/store.ex @@ -17,14 +17,14 @@ defmodule SwaggerPetstore.Api.Store do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - order_id (String.t): ID of the order that needs to be deleted - - opts (KeywordList): [optional] Optional parameters + - 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 - {:error, info} on failure + `{: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 @@ -42,13 +42,13 @@ defmodule SwaggerPetstore.Api.Store do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -66,14 +66,14 @@ defmodule SwaggerPetstore.Api.Store do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - order_id (integer()): ID of pet that needs to be fetched - - opts (KeywordList): [optional] Optional parameters + - 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 - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.Order}` on success + `{:error, info}` on failure """ @spec get_order_by_id(Tesla.Env.client, integer(), keyword()) :: {:ok, SwaggerPetstore.Model.Order.t} | {:error, Tesla.Env.t} def get_order_by_id(connection, order_id, _opts \\ []) do @@ -91,14 +91,14 @@ defmodule SwaggerPetstore.Api.Store do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (Order): order placed for purchasing the pet - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`Order`): order placed for purchasing the pet + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %SwaggerPetstore.Model.Order{}} on success - {:error, info} on failure + `{: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 diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex b/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex index a1b9d12d596..38073657839 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/api/user.ex @@ -17,14 +17,14 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body (User): Created user object - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`User`): Created user object + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -43,14 +43,14 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body ([User]): List of user object - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`[SwaggerPetstore.Model.User.t()]`): List of user object + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -69,14 +69,14 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - body ([User]): List of user object - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - body (`[SwaggerPetstore.Model.User.t()]`): List of user object + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -95,14 +95,14 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - username (String.t): The name that needs to be deleted - - opts (KeywordList): [optional] Optional parameters + - 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 - {:error, info} on failure + `{: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 @@ -120,14 +120,14 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - username (String.t): The name that needs to be fetched. Use user1 for testing. - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.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, %SwaggerPetstore.Model.User{}} on success - {:error, info} on failure + `{:ok, SwaggerPetstore.Model.User}` on success + `{:error, info}` on failure """ @spec get_user_by_name(Tesla.Env.client, String.t, keyword()) :: {:ok, SwaggerPetstore.Model.User.t} | {:error, Tesla.Env.t} def get_user_by_name(connection, username, _opts \\ []) do @@ -145,15 +145,15 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.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 + - connection (`SwaggerPetstore.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, %SwaggerPetstore.Model.String.t{}} on success - {:error, info} on failure + `{:ok, 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 @@ -173,13 +173,13 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 @@ -197,15 +197,15 @@ defmodule SwaggerPetstore.Api.User do ## Parameters - - connection (SwaggerPetstore.Connection): Connection to server - - username (String.t): name that need to be deleted - - body (User): Updated user object - - opts (KeywordList): [optional] Optional parameters + - connection (`SwaggerPetstore.Connection`): Connection to server + - username (`String.t`): name that need to be deleted + - body (`User`): Updated user object + - opts (`KeywordList`): [optional] Optional parameters ## Returns - {:ok, %{}} on success - {:error, info} on failure + `{: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 diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/connection.ex b/samples/client/petstore/elixir/lib/swagger_petstore/connection.ex index 067e59f02f6..601d3a1b33d 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/connection.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/connection.ex @@ -28,7 +28,7 @@ defmodule SwaggerPetstore.Connection do """ @spec new(String.t, String.t) :: Tesla.Env.client def new(username, password) do - Tesla.build_client([ + Tesla.client([ {Tesla.Middleware.BasicAuth, %{username: username, password: password}} ]) end @@ -50,7 +50,7 @@ defmodule SwaggerPetstore.Connection do """ @spec new(String.t) :: Tesla.Env.client def new(token) when is_binary(token) do - Tesla.build_client([ + Tesla.client([ {Tesla.Middleware.Headers, %{"Authorization" => "Bearer #{token}"}} ]) end @@ -81,6 +81,6 @@ defmodule SwaggerPetstore.Connection do """ @spec new() :: Tesla.Env.client def new do - Tesla.build_client([]) + Tesla.client([]) end end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/deserializer.ex b/samples/client/petstore/elixir/lib/swagger_petstore/deserializer.ex index d2362fc698f..5b5a6c959d4 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/deserializer.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/deserializer.ex @@ -10,20 +10,20 @@ defmodule SwaggerPetstore.Deserializer do @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 + @spec deserialize(map(), atom(), atom(), module(), map()) :: map() + def deserialize(model, field, :list, mod, %{} = options) do model - |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: [struct(mod)]])))) + |> Map.update!(field, &(Poison.Decode.transform(&1, Map.merge(options, %{as: [struct(mod)]})))) end - def deserialize(model, field, :struct, mod, options) do + def deserialize(model, field, :struct, mod,%{} = options) do model - |> Map.update!(field, &(Poison.Decode.decode(&1, Keyword.merge(options, [as: struct(mod)])))) + |> Map.update!(field, &(Poison.Decode.transform(&1, Map.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))) + model + |> Map.update!(field, &(Map.new(&1 || %{}, fn {key, val} -> {key, Poison.Decode.transform(val, Map.merge(options, %{as: struct(mod)}))} end))) end - def deserialize(model, field, :date, _, _options) do + def deserialize(model, field, :date, _, %{} = _options) do value = Map.get(model, field) case is_binary(value) do true -> case DateTime.from_iso8601(value) do diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/additional_properties_class.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/additional_properties_class.ex index d2b5f44716b..e7fd509c02f 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/additional_properties_class.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/additional_properties_class.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.AdditionalPropertiesClass do @derive [Poison.Encoder] defstruct [ - :"map_property", - :"map_of_map_property" + :map_property, + :map_of_map_property ] @type t :: %__MODULE__{ - :"map_property" => %{optional(String.t) => String.t}, - :"map_of_map_property" => %{optional(String.t) => %{optional(String.t) => String.t}} + :map_property => %{optional(String.t) => String.t}, + :map_of_map_property => %{optional(String.t) => %{optional(String.t) => String.t}} } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/animal.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/animal.ex index 2e12d720311..1111795239e 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/animal.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/animal.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.Animal do @derive [Poison.Encoder] defstruct [ - :"className", - :"color" + :className, + :color ] @type t :: %__MODULE__{ - :"className" => String.t, - :"color" => String.t + :className => String.t, + :color => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/api_response.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/api_response.ex index 9ffda2b8c8a..c4c3ccaa7ce 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/api_response.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/api_response.ex @@ -9,15 +9,15 @@ defmodule SwaggerPetstore.Model.ApiResponse do @derive [Poison.Encoder] defstruct [ - :"code", - :"type", - :"message" + :code, + :type, + :message ] @type t :: %__MODULE__{ - :"code" => integer(), - :"type" => String.t, - :"message" => String.t + :code => integer(), + :type => String.t, + :message => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/array_test.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/array_test.ex index d466a46f41d..1b8ab96f464 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/array_test.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/array_test.ex @@ -9,15 +9,15 @@ defmodule SwaggerPetstore.Model.ArrayTest do @derive [Poison.Encoder] defstruct [ - :"array_of_string", - :"array_array_of_integer", - :"array_array_of_model" + :array_of_string, + :array_array_of_integer, + :array_array_of_model ] @type t :: %__MODULE__{ - :"array_of_string" => [String.t], - :"array_array_of_integer" => [[integer()]], - :"array_array_of_model" => [[ReadOnlyFirst]] + :array_of_string => [String.t], + :array_array_of_integer => [[integer()]], + :array_array_of_model => [[SwaggerPetstore.Model.ReadOnlyFirst.t()]] } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/boolean.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/boolean.ex new file mode 100644 index 00000000000..aba1f11c184 --- /dev/null +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/boolean.ex @@ -0,0 +1,25 @@ +# 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.Boolean do + @moduledoc """ + True or False indicator + """ + + @derive [Poison.Encoder] + defstruct [ + + ] + + @type t :: %__MODULE__{ + + } +end + +defimpl Poison.Decoder, for: SwaggerPetstore.Model.Boolean do + def decode(value, _options) do + value + end +end + diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/capitalization.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/capitalization.ex index 062ac324923..f86365c22f2 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/capitalization.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/capitalization.ex @@ -9,18 +9,18 @@ defmodule SwaggerPetstore.Model.Capitalization do @derive [Poison.Encoder] defstruct [ - :"smallCamel", + :smallCamel, :"CapitalCamel", - :"small_Snake", + :small_Snake, :"Capital_Snake", :"SCA_ETH_Flow_Points", :"ATT_NAME" ] @type t :: %__MODULE__{ - :"smallCamel" => String.t, + :smallCamel => String.t, :"CapitalCamel" => String.t, - :"small_Snake" => String.t, + :small_Snake => String.t, :"Capital_Snake" => String.t, :"SCA_ETH_Flow_Points" => String.t, :"ATT_NAME" => String.t diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/cat.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/cat.ex index 20862cc4925..49dbacaed04 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/cat.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/cat.ex @@ -9,15 +9,15 @@ defmodule SwaggerPetstore.Model.Cat do @derive [Poison.Encoder] defstruct [ - :"className", - :"color", - :"declawed" + :className, + :color, + :declawed ] @type t :: %__MODULE__{ - :"className" => String.t, - :"color" => String.t, - :"declawed" => boolean() + :className => String.t, + :color => String.t, + :declawed => boolean() } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/category.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/category.ex index bbfefb6587c..69b0c072d25 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/category.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/category.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.Category do @derive [Poison.Encoder] defstruct [ - :"id", - :"name" + :id, + :name ] @type t :: %__MODULE__{ - :"id" => integer(), - :"name" => String.t + :id => integer(), + :name => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/class_model.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/class_model.ex index 9410a44a94b..c04d4b50638 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/class_model.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/class_model.ex @@ -9,11 +9,11 @@ defmodule SwaggerPetstore.Model.ClassModel do @derive [Poison.Encoder] defstruct [ - :"_class" + :_class ] @type t :: %__MODULE__{ - :"_class" => String.t + :_class => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/client.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/client.ex index 41875206b35..af7c79a7b62 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/client.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/client.ex @@ -9,11 +9,11 @@ defmodule SwaggerPetstore.Model.Client do @derive [Poison.Encoder] defstruct [ - :"client" + :client ] @type t :: %__MODULE__{ - :"client" => String.t + :client => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/dog.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/dog.ex index 519e3a3bd4d..ffad427c9d3 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/dog.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/dog.ex @@ -9,15 +9,15 @@ defmodule SwaggerPetstore.Model.Dog do @derive [Poison.Encoder] defstruct [ - :"className", - :"color", - :"breed" + :className, + :color, + :breed ] @type t :: %__MODULE__{ - :"className" => String.t, - :"color" => String.t, - :"breed" => String.t + :className => String.t, + :color => String.t, + :breed => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_arrays.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_arrays.ex index baf424abaa1..2cc8f38b188 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_arrays.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_arrays.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.EnumArrays do @derive [Poison.Encoder] defstruct [ - :"just_symbol", - :"array_enum" + :just_symbol, + :array_enum ] @type t :: %__MODULE__{ - :"just_symbol" => String.t, - :"array_enum" => [String.t] + :just_symbol => String.t, + :array_enum => [String.t] } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_test.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_test.ex index 3ee1530c302..2bb770e4abc 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_test.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/enum_test.ex @@ -9,19 +9,19 @@ defmodule SwaggerPetstore.Model.EnumTest do @derive [Poison.Encoder] defstruct [ - :"enum_string", - :"enum_string_required", - :"enum_integer", - :"enum_number", - :"outerEnum" + :enum_string, + :enum_string_required, + :enum_integer, + :enum_number, + :outerEnum ] @type t :: %__MODULE__{ - :"enum_string" => String.t, - :"enum_string_required" => String.t, - :"enum_integer" => integer(), - :"enum_number" => float(), - :"outerEnum" => OuterEnum + :enum_string => String.t, + :enum_string_required => String.t, + :enum_integer => integer(), + :enum_number => float(), + :outerEnum => SwaggerPetstore.Model.OuterEnum } end @@ -29,7 +29,7 @@ defimpl Poison.Decoder, for: SwaggerPetstore.Model.EnumTest do import SwaggerPetstore.Deserializer def decode(value, options) do value - |> deserialize(:"outerEnum", :struct, SwaggerPetstore.Model.OuterEnum, options) + |> deserialize(:outerEnum, :struct, SwaggerPetstore.Model.OuterEnum, options) end end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/format_test.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/format_test.ex index 4d271718a14..895cddc0dda 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/format_test.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/format_test.ex @@ -9,35 +9,35 @@ defmodule SwaggerPetstore.Model.FormatTest do @derive [Poison.Encoder] defstruct [ - :"integer", - :"int32", - :"int64", - :"number", - :"float", - :"double", - :"string", - :"byte", - :"binary", - :"date", - :"dateTime", - :"uuid", - :"password" + :integer, + :int32, + :int64, + :number, + :float, + :double, + :string, + :byte, + :binary, + :date, + :dateTime, + :uuid, + :password ] @type t :: %__MODULE__{ - :"integer" => integer(), - :"int32" => integer(), - :"int64" => integer(), - :"number" => float(), - :"float" => float(), - :"double" => float(), - :"string" => String.t, - :"byte" => binary(), - :"binary" => binary(), - :"date" => Date.t, - :"dateTime" => DateTime.t, - :"uuid" => String.t, - :"password" => String.t + :integer => integer(), + :int32 => integer(), + :int64 => integer(), + :number => float(), + :float => float(), + :double => float(), + :string => String.t, + :byte => binary(), + :binary => binary(), + :date => Date.t, + :dateTime => DateTime.t, + :uuid => String.t, + :password => String.t } end @@ -45,7 +45,7 @@ defimpl Poison.Decoder, for: SwaggerPetstore.Model.FormatTest do import SwaggerPetstore.Deserializer def decode(value, options) do value - |> deserialize(:"date", :date, nil, options) + |> deserialize(:date, :date, nil, options) end end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/has_only_read_only.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/has_only_read_only.ex index 8af87de21b8..3b412c245a7 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/has_only_read_only.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/has_only_read_only.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.HasOnlyReadOnly do @derive [Poison.Encoder] defstruct [ - :"bar", - :"foo" + :bar, + :foo ] @type t :: %__MODULE__{ - :"bar" => String.t, - :"foo" => String.t + :bar => String.t, + :foo => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/ints.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/ints.ex new file mode 100644 index 00000000000..1fe495f4ae1 --- /dev/null +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/ints.ex @@ -0,0 +1,25 @@ +# 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.Ints do + @moduledoc """ + True or False indicator + """ + + @derive [Poison.Encoder] + defstruct [ + + ] + + @type t :: %__MODULE__{ + + } +end + +defimpl Poison.Decoder, for: SwaggerPetstore.Model.Ints do + def decode(value, _options) do + value + end +end + diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/map_test.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/map_test.ex index f8f1f15a159..b337e4908cd 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/map_test.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/map_test.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.MapTest do @derive [Poison.Encoder] defstruct [ - :"map_map_of_string", - :"map_of_enum_string" + :map_map_of_string, + :map_of_enum_string ] @type t :: %__MODULE__{ - :"map_map_of_string" => %{optional(String.t) => %{optional(String.t) => String.t}}, - :"map_of_enum_string" => %{optional(String.t) => String.t} + :map_map_of_string => %{optional(String.t) => %{optional(String.t) => String.t}}, + :map_of_enum_string => %{optional(String.t) => String.t} } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/mixed_properties_and_additional_properties_class.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/mixed_properties_and_additional_properties_class.ex index 247f5fb1e56..51d37963887 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/mixed_properties_and_additional_properties_class.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/mixed_properties_and_additional_properties_class.ex @@ -9,15 +9,15 @@ defmodule SwaggerPetstore.Model.MixedPropertiesAndAdditionalPropertiesClass do @derive [Poison.Encoder] defstruct [ - :"uuid", - :"dateTime", - :"map" + :uuid, + :dateTime, + :map ] @type t :: %__MODULE__{ - :"uuid" => String.t, - :"dateTime" => DateTime.t, - :"map" => %{optional(String.t) => Animal} + :uuid => String.t, + :dateTime => DateTime.t, + :map => %{optional(String.t) => SwaggerPetstore.Model.Animal.t()} } end @@ -25,7 +25,7 @@ defimpl Poison.Decoder, for: SwaggerPetstore.Model.MixedPropertiesAndAdditionalP import SwaggerPetstore.Deserializer def decode(value, options) do value - |> deserialize(:"map", :map, SwaggerPetstore.Model.Animal, options) + |> deserialize(:map, :map, SwaggerPetstore.Model.Animal, options) end end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/model_200_response.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/model_200_response.ex index 32f64cbf37f..7c937b77d15 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/model_200_response.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/model_200_response.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.Model200Response do @derive [Poison.Encoder] defstruct [ - :"name", - :"class" + :name, + :class ] @type t :: %__MODULE__{ - :"name" => integer(), - :"class" => String.t + :name => integer(), + :class => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/name.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/name.ex index 07ed6555afa..7fb2fb85053 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/name.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/name.ex @@ -9,16 +9,16 @@ defmodule SwaggerPetstore.Model.Name do @derive [Poison.Encoder] defstruct [ - :"name", - :"snake_case", - :"property", + :name, + :snake_case, + :property, :"123Number" ] @type t :: %__MODULE__{ - :"name" => integer(), - :"snake_case" => integer(), - :"property" => String.t, + :name => integer(), + :snake_case => integer(), + :property => String.t, :"123Number" => integer() } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/numbers.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/numbers.ex new file mode 100644 index 00000000000..24ac45e96cc --- /dev/null +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/numbers.ex @@ -0,0 +1,25 @@ +# 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.Numbers do + @moduledoc """ + some number + """ + + @derive [Poison.Encoder] + defstruct [ + + ] + + @type t :: %__MODULE__{ + + } +end + +defimpl Poison.Decoder, for: SwaggerPetstore.Model.Numbers do + def decode(value, _options) do + value + end +end + diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/order.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/order.ex index a91dd8dfa0d..73d81a2d100 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/order.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/order.ex @@ -9,21 +9,21 @@ defmodule SwaggerPetstore.Model.Order do @derive [Poison.Encoder] defstruct [ - :"id", - :"petId", - :"quantity", - :"shipDate", - :"status", - :"complete" + :id, + :petId, + :quantity, + :shipDate, + :status, + :complete ] @type t :: %__MODULE__{ - :"id" => integer(), - :"petId" => integer(), - :"quantity" => integer(), - :"shipDate" => DateTime.t, - :"status" => String.t, - :"complete" => boolean() + :id => integer(), + :petId => integer(), + :quantity => integer(), + :shipDate => DateTime.t, + :status => String.t, + :complete => boolean() } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/outer_composite.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/outer_composite.ex index 3771cc731dc..6306f0984bb 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/outer_composite.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/outer_composite.ex @@ -9,15 +9,15 @@ defmodule SwaggerPetstore.Model.OuterComposite do @derive [Poison.Encoder] defstruct [ - :"my_number", - :"my_string", - :"my_boolean" + :my_number, + :my_string, + :my_boolean ] @type t :: %__MODULE__{ - :"my_number" => OuterNumber, - :"my_string" => OuterString, - :"my_boolean" => OuterBoolean + :my_number => SwaggerPetstore.Model.OuterNumber, + :my_string => SwaggerPetstore.Model.OuterString, + :my_boolean => SwaggerPetstore.Model.OuterBoolean } end @@ -25,9 +25,9 @@ defimpl Poison.Decoder, for: SwaggerPetstore.Model.OuterComposite do import SwaggerPetstore.Deserializer 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) + |> 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 diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/pet.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/pet.ex index abb240c6eea..0683352268f 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/pet.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/pet.ex @@ -9,21 +9,21 @@ defmodule SwaggerPetstore.Model.Pet do @derive [Poison.Encoder] defstruct [ - :"id", - :"category", - :"name", - :"photoUrls", - :"tags", - :"status" + :id, + :category, + :name, + :photoUrls, + :tags, + :status ] @type t :: %__MODULE__{ - :"id" => integer(), - :"category" => Category, - :"name" => String.t, - :"photoUrls" => [String.t], - :"tags" => [Tag], - :"status" => String.t + :id => integer(), + :category => SwaggerPetstore.Model.Category, + :name => String.t, + :photoUrls => [String.t], + :tags => [SwaggerPetstore.Model.Tag.t()], + :status => String.t } end @@ -31,8 +31,8 @@ defimpl Poison.Decoder, for: SwaggerPetstore.Model.Pet do import SwaggerPetstore.Deserializer def decode(value, options) do value - |> deserialize(:"category", :struct, SwaggerPetstore.Model.Category, options) - |> deserialize(:"tags", :list, SwaggerPetstore.Model.Tag, options) + |> deserialize(:category, :struct, SwaggerPetstore.Model.Category, options) + |> deserialize(:tags, :list, SwaggerPetstore.Model.Tag, options) end end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/read_only_first.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/read_only_first.ex index 2e41baa2442..720db695287 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/read_only_first.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/read_only_first.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.ReadOnlyFirst do @derive [Poison.Encoder] defstruct [ - :"bar", - :"baz" + :bar, + :baz ] @type t :: %__MODULE__{ - :"bar" => String.t, - :"baz" => String.t + :bar => String.t, + :baz => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/return.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/return.ex index 338325e73ef..05df596ee15 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/return.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/return.ex @@ -9,11 +9,11 @@ defmodule SwaggerPetstore.Model.Return do @derive [Poison.Encoder] defstruct [ - :"return" + :return ] @type t :: %__MODULE__{ - :"return" => integer() + :return => integer() } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/tag.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/tag.ex index f019b2f8a9a..06b37d2b3b5 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/tag.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/tag.ex @@ -9,13 +9,13 @@ defmodule SwaggerPetstore.Model.Tag do @derive [Poison.Encoder] defstruct [ - :"id", - :"name" + :id, + :name ] @type t :: %__MODULE__{ - :"id" => integer(), - :"name" => String.t + :id => integer(), + :name => String.t } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/model/user.ex b/samples/client/petstore/elixir/lib/swagger_petstore/model/user.ex index b568be8a563..c1d9b24d1aa 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/model/user.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/model/user.ex @@ -9,25 +9,25 @@ defmodule SwaggerPetstore.Model.User do @derive [Poison.Encoder] defstruct [ - :"id", - :"username", - :"firstName", - :"lastName", - :"email", - :"password", - :"phone", - :"userStatus" + :id, + :username, + :firstName, + :lastName, + :email, + :password, + :phone, + :userStatus ] @type t :: %__MODULE__{ - :"id" => integer(), - :"username" => String.t, - :"firstName" => String.t, - :"lastName" => String.t, - :"email" => String.t, - :"password" => String.t, - :"phone" => String.t, - :"userStatus" => integer() + :id => integer(), + :username => String.t, + :firstName => String.t, + :lastName => String.t, + :email => String.t, + :password => String.t, + :phone => String.t, + :userStatus => integer() } end diff --git a/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex b/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex index a1aca31bd6c..cd7541408ac 100644 --- a/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex +++ b/samples/client/petstore/elixir/lib/swagger_petstore/request_builder.ex @@ -114,12 +114,12 @@ defmodule SwaggerPetstore.RequestBuilder do {:ok, struct} on success {:error, term} on failure """ - @spec decode(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(%Tesla.Env{status: 200, body: body}), do: Poison.decode(body) def decode(response), do: {:error, response} - @spec decode(Tesla.Env.t | term(), :false | struct() | [struct()]) :: {:ok, struct()} | {:error, Tesla.Env.t} | {:error, term()} def decode(%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(%Tesla.Env{status: 200, body: body}, struct), do: Poison.decode(body, as: struct) def decode(response, _struct), do: {:error, response} end diff --git a/samples/client/petstore/elixir/mix.exs b/samples/client/petstore/elixir/mix.exs index c19f9e5a4cb..0430d31883c 100644 --- a/samples/client/petstore/elixir/mix.exs +++ b/samples/client/petstore/elixir/mix.exs @@ -29,8 +29,8 @@ defmodule SwaggerPetstore.Mixfile do # Type "mix help deps" for more examples and options defp deps do [ - {:tesla, "~> 0.8"}, - {:poison, ">= 1.0.0"} + {:tesla, "~> 1.12.1"}, + {:poison, ">= 6.0.0"} ] end end