diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index 9bb5b89089a..84f7fc50fb8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -119,6 +119,8 @@ public interface CodegenConfig { void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations); + Map postProcessAllModels(Map objs); + Map postProcessModels(Map objs); Map postProcessOperations(Map objs); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java index f0d3591ba3f..83330477b65 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java @@ -77,6 +77,9 @@ public class CodegenConstants { public static final String MODEL_PROPERTY_NAMING = "modelPropertyNaming"; public static final String MODEL_PROPERTY_NAMING_DESC = "Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name"; + public static final String DOTNET_FRAMEWORK = "targetFramework"; + public static final String DOTNET_FRAMEWORK_DESC = "The target .NET framework version."; + public static enum MODEL_PROPERTY_NAMING_TYPE {camelCase, PascalCase, snake_case, original} } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 6cb4c93e466..07ee0279c3e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -109,12 +109,19 @@ public class DefaultCodegen { } } + // override with any special post-processing for all models + @SuppressWarnings("static-method") + public Map postProcessAllModels(Map objs) { + return objs; + } + // override with any special post-processing @SuppressWarnings("static-method") public Map postProcessModels(Map objs) { return objs; } + // override with any special post-processing @SuppressWarnings("static-method") public Map postProcessOperations(Map objs) { diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 96f0f2146b9..f817b244b3c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -183,6 +183,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { sortedModelKeys = updatedKeys; } + // store all processed models + Map allProcessedModels = new HashMap(); + + // process models only for (String name : sortedModelKeys) { try { //don't generate models that have an import mapping @@ -195,6 +199,26 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { modelMap.put(name, model); Map models = processModels(config, modelMap, definitions); models.putAll(config.additionalProperties()); + + allProcessedModels.put(name, models); + + } catch (Exception e) { + throw new RuntimeException("Could not process model '" + name + "'", e); + } + } + + // post process all processed models + allProcessedModels = config.postProcessAllModels(allProcessedModels); + + // generate files based on processed models + for (String name: allProcessedModels.keySet()) { + Map models = (Map)allProcessedModels.get(name); + + try { + //don't generate models that have an import mapping + if(config.importMapping().containsKey(name)) { + continue; + } allModels.add(((List) models.get("models")).get(0)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 0da5b72f57f..3ef8e35e93e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -1,5 +1,7 @@ package io.swagger.codegen.languages; +import com.google.common.collect.ImmutableBiMap; +import com.google.common.collect.ImmutableMap; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenType; @@ -25,6 +27,8 @@ import org.slf4j.LoggerFactory; public class CSharpClientCodegen extends AbstractCSharpCodegen { @SuppressWarnings({"unused", "hiding"}) private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class); + private static final String NET45 = "v4.5"; + private static final String NET35 = "v3.5"; protected String packageGuid = "{" + java.util.UUID.randomUUID().toString().toUpperCase() + "}"; protected String packageTitle = "Swagger Library"; @@ -34,6 +38,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { protected String packageCopyright = "No Copyright"; protected String clientPackage = "IO.Swagger.Client"; + protected String targetFramework = NET45; + protected String targetFrameworkNuget = "net45"; + protected boolean supportsAsync = Boolean.TRUE; + + + protected final Map frameworks; + public CSharpClientCodegen() { super(); modelTemplateFiles.put("model.mustache", ".cs"); @@ -64,6 +75,18 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { CodegenConstants.OPTIONAL_PROJECT_GUID_DESC, null); + CliOption framework = new CliOption( + CodegenConstants.DOTNET_FRAMEWORK, + CodegenConstants.DOTNET_FRAMEWORK_DESC + ); + frameworks = new ImmutableMap.Builder() + .put(NET35, ".NET Framework 3.5 compatible") + .put(NET45, ".NET Framework 4.5+ compatible") + .build(); + framework.defaultValue(this.targetFramework); + framework.setEnum(frameworks); + cliOptions.add(framework); + // CLI Switches addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC, @@ -111,6 +134,24 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { additionalProperties.put("packageCompany", packageCompany); additionalProperties.put("packageCopyright", packageCopyright); + if (additionalProperties.containsKey(CodegenConstants.DOTNET_FRAMEWORK)) { + setTargetFramework((String) additionalProperties.get(CodegenConstants.DOTNET_FRAMEWORK)); + } + + if (NET35.equals(this.targetFramework)) { + setTargetFrameworkNuget("net35"); + setSupportsAsync(Boolean.FALSE); + if(additionalProperties.containsKey("supportsAsync")){ + additionalProperties.remove("supportsAsync"); + } + } else { + setTargetFrameworkNuget("net45"); + setSupportsAsync(Boolean.TRUE); + additionalProperties.put("supportsAsync", this.supportsAsync); + } + + additionalProperties.put("targetFrameworkNuget", this.targetFrameworkNuget); + if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) { setOptionalProjectFileFlag(Boolean.valueOf( additionalProperties.get(CodegenConstants.OPTIONAL_PROJECT_FILE).toString())); @@ -141,7 +182,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { String binRelativePath = "..\\"; for (int i = 0; i < packageDepth; i = i + 1) binRelativePath += "..\\"; - binRelativePath += "bin\\"; + binRelativePath += "vendor\\"; additionalProperties.put("binRelativePath", binRelativePath); supportingFiles.add(new SupportingFile("Configuration.mustache", @@ -153,8 +194,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { supportingFiles.add(new SupportingFile("ApiResponse.mustache", clientPackageDir, "ApiResponse.cs")); - supportingFiles.add(new SupportingFile("Newtonsoft.Json.dll", "bin", "Newtonsoft.Json.dll")); - supportingFiles.add(new SupportingFile("RestSharp.dll", "bin", "RestSharp.dll")); supportingFiles.add(new SupportingFile("compile.mustache", "", "compile.bat")); supportingFiles.add(new SupportingFile("compile-mono.sh.mustache", "", "compile-mono.sh")); supportingFiles.add(new SupportingFile("packages.config.mustache", "vendor" + java.io.File.separator, "packages.config")); @@ -222,4 +261,20 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { this.packageGuid = packageGuid; } + public void setTargetFramework(String dotnetFramework) { + if(!frameworks.containsKey(dotnetFramework)){ + LOGGER.warn("Invalid .NET framework version, defaulting to " + this.targetFramework); + } else { + this.targetFramework = dotnetFramework; + } + LOGGER.info("Generating code for .NET Framework " + this.targetFramework); + } + + public void setTargetFrameworkNuget(String targetFrameworkNuget) { + this.targetFrameworkNuget = targetFrameworkNuget; + } + + public void setSupportsAsync(Boolean supportsAsync){ + this.supportsAsync = supportsAsync; + } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 67750ea790c..53bcab9d533 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -9,6 +9,7 @@ import io.swagger.models.Swagger; import io.swagger.models.parameters.FormParameter; import io.swagger.models.parameters.Parameter; import io.swagger.models.properties.*; +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -531,18 +532,18 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } } - if(model.isEnum == null || model.isEnum) { + if(!BooleanUtils.toBoolean(model.isEnum)) { // needed by all pojos, but not enums model.imports.add("ApiModelProperty"); model.imports.add("ApiModel"); - // comment out below as it's in the model template + // comment out below as it's in the model template //model.imports.add("Objects"); final String lib = getLibrary(); if(StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) { model.imports.add("JsonProperty"); - if(model.hasEnums != null || model.hasEnums == true) { + if(BooleanUtils.toBoolean(model.hasEnums)) { model.imports.add("JsonValue"); } } @@ -747,7 +748,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } } } - + if(removedChildEnum) { // If we removed an entry from this model's vars, we need to ensure hasMore is updated int count = 0, numVars = codegenProperties.size(); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache index ef4a001dd05..e8e74cc815a 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache @@ -47,16 +47,17 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali } if (o == null || getClass() != o.getClass()) { return false; - } - {{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}} - return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}} + }{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{/vars}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} return true;{{/hasVars}} } @Override public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}); + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); } @Override diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache index 8bbb36a8014..4ca33302ee7 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache @@ -38,17 +38,17 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali } if (o == null || getClass() != o.getClass()) { return false; - } + }{{#hasVars}} {{classname}} {{classVarName}} = ({{classname}}) o; - - return true {{#hasVars}}&& {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{/vars}}{{/hasVars}} - {{#parent}}&& super.equals(o){{/parent}}; + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{/vars}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} + return true;{{/hasVars}} } @Override public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}},{{/hasVars}} super.hashCode(){{/parent}}); + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); } @Override diff --git a/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache index c55fbfd393d..6ef0a6a9dc5 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/ApiClient.mustache @@ -208,7 +208,9 @@ // See http://visionmedia.github.io/superagent/#parsing-response-bodies var data = response.body; if (data == null) { - return null; + // Superagent does not always produce a body; use the unparsed response + // as a fallback + data = response.text; } return ApiClient.convertToType(data, returnType); }; diff --git a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache index c9a2ad4e399..a42ad349820 100644 --- a/modules/swagger-codegen/src/main/resources/Javascript/api.mustache +++ b/modules/swagger-codegen/src/main/resources/Javascript/api.mustache @@ -42,13 +42,13 @@ '': <#hasMore>, }; var queryParams = {<#queryParams> - '': <#collectionFormat>this.buildCollectionParam(, '')<^collectionFormat><#hasMore>, + '': <#collectionFormat>this.apiClient.buildCollectionParam(, '')<^collectionFormat><#hasMore>, }; var headerParams = {<#headerParams> '': <#hasMore>, }; var formParams = {<#formParams> - '': <#collectionFormat>this.buildCollectionParam(, '')<^collectionFormat><#hasMore>, + '': <#collectionFormat>this.apiClient.buildCollectionParam(, '')<^collectionFormat><#hasMore>, }; var authNames = [<#authMethods>''<#hasMore>, ]; diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index 4fabfa4667b..60b573e1a6c 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -146,7 +146,7 @@ namespace {{packageName}}.Client var response = RestClient.Execute(request); return (Object) response; } - + {{#supportsAsync}} /// /// Makes the asynchronous HTTP request. /// @@ -171,7 +171,7 @@ namespace {{packageName}}.Client pathParams, contentType); var response = await RestClient.ExecuteTaskAsync(request); return (Object)response; - } + }{{/supportsAsync}} /// /// Escape string (url-encoded). @@ -367,7 +367,7 @@ namespace {{packageName}}.Client /// Object to be casted /// Target type /// Casted object - public static dynamic ConvertType(dynamic source, Type dest) + {{#supportsAsync}}public static dynamic ConvertType(dynamic source, Type dest){{/supportsAsync}}{{^supportsAsync}}public static object ConvertType(T source, Type dest) where T : class{{/supportsAsync}} { return Convert.ChangeType(source, dest); } diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache index 09dbd0dce50..8e56fb31f43 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiException.mustache @@ -17,7 +17,7 @@ namespace {{packageName}}.Client /// Gets or sets the error content (body json object) /// /// The error content (Http response body). - public dynamic ErrorContent { get; private set; } + public {{#supportsAsync}}dynamic{{/supportsAsync}}{{^supportsAsync}}object{{/supportsAsync}} ErrorContent { get; private set; } /// /// Initializes a new instance of the class. @@ -40,7 +40,7 @@ namespace {{packageName}}.Client /// HTTP status code. /// Error message. /// Error content. - public ApiException(int errorCode, string message, dynamic errorContent = null) : base(message) + public ApiException(int errorCode, string message, {{#supportsAsync}}dynamic{{/supportsAsync}}{{^supportsAsync}}object{{/supportsAsync}} errorContent = null) : base(message) { this.ErrorCode = errorCode; this.ErrorContent = errorContent; diff --git a/modules/swagger-codegen/src/main/resources/csharp/AssemblyInfo.mustache b/modules/swagger-codegen/src/main/resources/csharp/AssemblyInfo.mustache index 8a19fd01393..bf80d7d4568 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/AssemblyInfo.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/AssemblyInfo.mustache @@ -1,6 +1,5 @@ using System.Reflection; using System.Runtime.InteropServices; -using System.Windows; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information diff --git a/modules/swagger-codegen/src/main/resources/csharp/Newtonsoft.Json.dll b/modules/swagger-codegen/src/main/resources/csharp/Newtonsoft.Json.dll deleted file mode 100644 index ae725c4b598..00000000000 Binary files a/modules/swagger-codegen/src/main/resources/csharp/Newtonsoft.Json.dll and /dev/null differ diff --git a/modules/swagger-codegen/src/main/resources/csharp/Project.mustache b/modules/swagger-codegen/src/main/resources/csharp/Project.mustache index 333cb5088ff..d418dc74f8b 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Project.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Project.mustache @@ -8,7 +8,7 @@ Properties {{packageTitle}} {{packageTitle}} - v4.5 + {{targetFramework}} 512 @@ -41,10 +41,10 @@ False - {{binRelativePath}}Newtonsoft.Json.dll + {{binRelativePath}}/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll - {{binRelativePath}}RestSharp.dll + {{binRelativePath}}/RestSharp.105.2.3/lib/{{targetFrameworkNuget}}/RestSharp.dll diff --git a/modules/swagger-codegen/src/main/resources/csharp/README.md b/modules/swagger-codegen/src/main/resources/csharp/README.md index 3ce83da957b..794a7c49b1b 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/README.md +++ b/modules/swagger-codegen/src/main/resources/csharp/README.md @@ -6,12 +6,14 @@ - [RestSharp] (https://www.nuget.org/packages/RestSharp) - 105.1.0 or later - [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later -NOTE: The DLLs included in the package may not be the latest version. We recommned using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: +The DLLs included in the package may not be the latest version. We recommned using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: ``` Install-Package RestSharp Install-Package Newtonsoft.Json ``` +NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See [RestSharp#742](https://github.com/restsharp/RestSharp/issues/742) + ## Installation Run the following command to generate the DLL - [Mac/Linux] compile-mono.sh diff --git a/modules/swagger-codegen/src/main/resources/csharp/RestSharp.dll b/modules/swagger-codegen/src/main/resources/csharp/RestSharp.dll deleted file mode 100644 index a7331ed6e23..00000000000 Binary files a/modules/swagger-codegen/src/main/resources/csharp/RestSharp.dll and /dev/null differ diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index b1a6a321c56..47139b52865 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -16,6 +16,7 @@ namespace {{packageName}}.Api /// public interface I{{classname}} { + #region Synchronous Operations {{#operation}} /// /// {{summary}} @@ -36,7 +37,11 @@ namespace {{packageName}}.Api {{#allParams}}/// {{description}} {{/allParams}}/// ApiResponse of {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object(void){{/returnType}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> {{operationId}}WithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); - + {{/operation}} + #endregion Synchronous Operations + {{#supportsAsync}} + #region Asynchronous Operations + {{#operation}} /// /// {{summary}} /// @@ -57,6 +62,8 @@ namespace {{packageName}}.Api {{/allParams}}/// Task of ApiResponse{{#returnType}} ({{returnType}}){{/returnType}} System.Threading.Tasks.Task> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); {{/operation}} + #endregion Asynchronous Operations + {{/supportsAsync}} } /// @@ -245,7 +252,8 @@ namespace {{packageName}}.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null);{{/returnType}} } - + + {{#supportsAsync}} /// /// {{summary}} {{notes}} /// @@ -349,7 +357,7 @@ namespace {{packageName}}.Api {{^returnType}}return new ApiResponse(statusCode, response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null);{{/returnType}} - } + }{{/supportsAsync}} {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache index b84363cae39..b1b0c4f0c73 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile-mono.sh.mustache @@ -1,10 +1,17 @@ #!/usr/bin/env bash +frameworkVersion={{targetFrameworkNuget}} +netfx=${frameworkVersion#net} + wget -nc https://nuget.org/nuget.exe; mozroots --import --sync mono nuget.exe install vendor/packages.config -o vendor; mkdir -p bin; -mcs -sdk:45 -r:vendor/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll,\ -vendor/RestSharp.105.2.3/lib/net45/RestSharp.dll,\ + +cp vendor/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; +cp vendor/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll bin/RestSharp.dll; + +mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\ +bin/RestSharp.dll,\ System.Runtime.Serialization.dll \ -target:library \ -out:bin/{{packageName}}.dll \ diff --git a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache index e35879e0efa..6014320b2f7 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/compile.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/compile.mustache @@ -1,3 +1,12 @@ -SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 -%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/{{packageName}}.dll /recurse:src\*.cs /doc:bin/{{packageName}}.xml +@echo off +{{#supportsAsync}}SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319{{/supportsAsync}} +{{^supportsAsync}}SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v3.5{{/supportsAsync}} + +if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')" +.\nuget.exe install vendor/packages.config -o vendor + +cp vendor/Newtonsoft.Json.8.0.2/lib/{{targetFrameworkNuget}}/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll +cp vendor/RestSharp.105.1.0/lib/{{targetFrameworkNuget}}/RestSharp.dll bin/RestSharp.dll + +%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/{{packageName}}.dll /recurse:src\*.cs /doc:bin/{{packageName}}.xml diff --git a/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache b/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache index c87bbb79fa6..bd4428e687e 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/packages.config.mustache @@ -1,5 +1,5 @@ - - + + diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java index f7abe83f8f4..ce810faea8b 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java @@ -31,6 +31,7 @@ public class CSharpClientOptionsProvider implements OptionsProvider { .put(CodegenConstants.RETURN_ICOLLECTION, "false") .put(CodegenConstants.OPTIONAL_PROJECT_FILE, "true") .put(CodegenConstants.OPTIONAL_PROJECT_GUID, PACKAGE_GUID_VALUE) + .put(CodegenConstants.DOTNET_FRAMEWORK, "4.x") .build(); } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore new file mode 100644 index 00000000000..08d9d469ba8 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/.gitignore @@ -0,0 +1,2 @@ +vendor/Newtonsoft.Json.8.0.2/ +vendor/RestSharp.105.2.3/ \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll index ae725c4b598..4d42dd9c5fe 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll and b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/Newtonsoft.Json.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll index a7331ed6e23..59d82f94198 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll and b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/bin/RestSharp.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh index 67bc67e57a8..d768c892f31 100755 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile-mono.sh @@ -1,10 +1,17 @@ #!/usr/bin/env bash +frameworkVersion=net45 +netfx=${frameworkVersion#net} + wget -nc https://nuget.org/nuget.exe; mozroots --import --sync mono nuget.exe install vendor/packages.config -o vendor; mkdir -p bin; -mcs -sdk:45 -r:vendor/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll,\ -vendor/RestSharp.105.2.3/lib/net45/RestSharp.dll,\ + +cp vendor/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll; +cp vendor/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll; + +mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\ +bin/RestSharp.dll,\ System.Runtime.Serialization.dll \ -target:library \ -out:bin/IO.Swagger.dll \ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat index 90963356690..27681fc968d 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/compile.bat @@ -1,3 +1,12 @@ -SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 -%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/IO.Swagger.dll /recurse:src\*.cs /doc:bin/IO.Swagger.xml +@echo off +SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319 + + +if not exist ".\nuget.exe" powershell -Command "(new-object System.Net.WebClient).DownloadFile('https://nuget.org/nuget.exe', '.\nuget.exe')" +.\nuget.exe install vendor/packages.config -o vendor + +cp vendor/Newtonsoft.Json.8.0.2/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.Json.dll +cp vendor/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll + +%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/IO.Swagger.dll /recurse:src\*.cs /doc:bin/IO.Swagger.xml diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index 96f6b3a4d0f..27c73638479 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -15,6 +15,7 @@ namespace IO.Swagger.Api /// public interface IPetApi { + #region Synchronous Operations /// /// Update an existing pet @@ -35,7 +36,201 @@ namespace IO.Swagger.Api /// Pet object that needs to be added to the store /// ApiResponse of Object(void) ApiResponse UpdatePetWithHttpInfo (Pet body = null); - + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// + void AddPet (Pet body = null); + + /// + /// Add a new pet to the store + /// + /// + /// + /// + /// Pet object that needs to be added to the store + /// ApiResponse of Object(void) + ApiResponse AddPetWithHttpInfo (Pet body = null); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// List<Pet> + List FindPetsByStatus (List status = null); + + /// + /// Finds Pets by status + /// + /// + /// Multiple status values can be provided with comma seperated strings + /// + /// Status values that need to be considered for filter + /// ApiResponse of List<Pet> + ApiResponse> FindPetsByStatusWithHttpInfo (List status = null); + + /// + /// Finds Pets by tags + /// + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// List<Pet> + List FindPetsByTags (List tags = null); + + /// + /// Finds Pets by tags + /// + /// + /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + /// + /// Tags to filter by + /// ApiResponse of List<Pet> + ApiResponse> FindPetsByTagsWithHttpInfo (List tags = null); + + /// + /// Find pet by ID + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// Pet + Pet GetPetById (long? petId); + + /// + /// Find pet by ID + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of Pet + ApiResponse GetPetByIdWithHttpInfo (long? petId); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// + void UpdatePetWithForm (string petId, string name = null, string status = null); + + /// + /// Updates a pet in the store with form data + /// + /// + /// + /// + /// ID of pet that needs to be updated + /// Updated name of the pet + /// Updated status of the pet + /// ApiResponse of Object(void) + ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string name = null, string status = null); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// + /// + void DeletePet (long? petId, string apiKey = null); + + /// + /// Deletes a pet + /// + /// + /// + /// + /// Pet id to delete + /// + /// ApiResponse of Object(void) + ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = null); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// + void UploadFile (long? petId, string additionalMetadata = null, Stream file = null); + + /// + /// uploads an image + /// + /// + /// + /// + /// ID of pet to update + /// Additional data to pass to server + /// file to upload + /// ApiResponse of Object(void) + ApiResponse UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// byte[] + byte[] GetPetByIdWithByteArray (long? petId); + + /// + /// Fake endpoint to test byte array return by 'Find pet by ID' + /// + /// + /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of byte[] + ApiResponse GetPetByIdWithByteArrayWithHttpInfo (long? petId); + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// + /// + /// Pet object in the form of byte array + /// + void AddPetUsingByteArray (byte[] body = null); + + /// + /// Fake endpoint to test byte array in body parameter for adding a new pet to the store + /// + /// + /// + /// + /// Pet object in the form of byte array + /// ApiResponse of Object(void) + ApiResponse AddPetUsingByteArrayWithHttpInfo (byte[] body = null); + + #endregion Synchronous Operations + + #region Asynchronous Operations + /// /// Update an existing pet /// @@ -56,26 +251,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> UpdatePetAsyncWithHttpInfo (Pet body = null); - /// - /// Add a new pet to the store - /// - /// - /// - /// - /// Pet object that needs to be added to the store - /// - void AddPet (Pet body = null); - - /// - /// Add a new pet to the store - /// - /// - /// - /// - /// Pet object that needs to be added to the store - /// ApiResponse of Object(void) - ApiResponse AddPetWithHttpInfo (Pet body = null); - /// /// Add a new pet to the store /// @@ -96,26 +271,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> AddPetAsyncWithHttpInfo (Pet body = null); - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// Status values that need to be considered for filter - /// List<Pet> - List FindPetsByStatus (List status = null); - - /// - /// Finds Pets by status - /// - /// - /// Multiple status values can be provided with comma seperated strings - /// - /// Status values that need to be considered for filter - /// ApiResponse of List<Pet> - ApiResponse> FindPetsByStatusWithHttpInfo (List status = null); - /// /// Finds Pets by status /// @@ -136,26 +291,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (List<Pet>) System.Threading.Tasks.Task>> FindPetsByStatusAsyncWithHttpInfo (List status = null); - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - /// - /// Tags to filter by - /// List<Pet> - List FindPetsByTags (List tags = null); - - /// - /// Finds Pets by tags - /// - /// - /// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - /// - /// Tags to filter by - /// ApiResponse of List<Pet> - ApiResponse> FindPetsByTagsWithHttpInfo (List tags = null); - /// /// Finds Pets by tags /// @@ -176,26 +311,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (List<Pet>) System.Threading.Tasks.Task>> FindPetsByTagsAsyncWithHttpInfo (List tags = null); - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - /// - /// ID of pet that needs to be fetched - /// Pet - Pet GetPetById (long? petId); - - /// - /// Find pet by ID - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - /// - /// ID of pet that needs to be fetched - /// ApiResponse of Pet - ApiResponse GetPetByIdWithHttpInfo (long? petId); - /// /// Find pet by ID /// @@ -216,30 +331,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (Pet) System.Threading.Tasks.Task> GetPetByIdAsyncWithHttpInfo (long? petId); - /// - /// Updates a pet in the store with form data - /// - /// - /// - /// - /// ID of pet that needs to be updated - /// Updated name of the pet - /// Updated status of the pet - /// - void UpdatePetWithForm (string petId, string name = null, string status = null); - - /// - /// Updates a pet in the store with form data - /// - /// - /// - /// - /// ID of pet that needs to be updated - /// Updated name of the pet - /// Updated status of the pet - /// ApiResponse of Object(void) - ApiResponse UpdatePetWithFormWithHttpInfo (string petId, string name = null, string status = null); - /// /// Updates a pet in the store with form data /// @@ -264,28 +355,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> UpdatePetWithFormAsyncWithHttpInfo (string petId, string name = null, string status = null); - /// - /// Deletes a pet - /// - /// - /// - /// - /// Pet id to delete - /// - /// - void DeletePet (long? petId, string apiKey = null); - - /// - /// Deletes a pet - /// - /// - /// - /// - /// Pet id to delete - /// - /// ApiResponse of Object(void) - ApiResponse DeletePetWithHttpInfo (long? petId, string apiKey = null); - /// /// Deletes a pet /// @@ -308,30 +377,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null); - /// - /// uploads an image - /// - /// - /// - /// - /// ID of pet to update - /// Additional data to pass to server - /// file to upload - /// - void UploadFile (long? petId, string additionalMetadata = null, Stream file = null); - - /// - /// uploads an image - /// - /// - /// - /// - /// ID of pet to update - /// Additional data to pass to server - /// file to upload - /// ApiResponse of Object(void) - ApiResponse UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); - /// /// uploads an image /// @@ -356,26 +401,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null); - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - /// - /// ID of pet that needs to be fetched - /// byte[] - byte[] GetPetByIdWithByteArray (long? petId); - - /// - /// Fake endpoint to test byte array return by 'Find pet by ID' - /// - /// - /// Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - /// - /// ID of pet that needs to be fetched - /// ApiResponse of byte[] - ApiResponse GetPetByIdWithByteArrayWithHttpInfo (long? petId); - /// /// Fake endpoint to test byte array return by 'Find pet by ID' /// @@ -396,26 +421,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (byte[]) System.Threading.Tasks.Task> GetPetByIdWithByteArrayAsyncWithHttpInfo (long? petId); - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to the store - /// - /// - /// - /// - /// Pet object in the form of byte array - /// - void AddPetUsingByteArray (byte[] body = null); - - /// - /// Fake endpoint to test byte array in body parameter for adding a new pet to the store - /// - /// - /// - /// - /// Pet object in the form of byte array - /// ApiResponse of Object(void) - ApiResponse AddPetUsingByteArrayWithHttpInfo (byte[] body = null); - /// /// Fake endpoint to test byte array in body parameter for adding a new pet to the store /// @@ -436,6 +441,8 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> AddPetUsingByteArrayAsyncWithHttpInfo (byte[] body = null); + #endregion Asynchronous Operations + } /// @@ -598,7 +605,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Update an existing pet /// @@ -764,7 +772,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Add a new pet to the store /// @@ -925,7 +934,8 @@ namespace IO.Swagger.Api (List) Configuration.ApiClient.Deserialize(response, typeof(List))); } - + + /// /// Finds Pets by status Multiple status values can be provided with comma seperated strings /// @@ -1087,7 +1097,8 @@ namespace IO.Swagger.Api (List) Configuration.ApiClient.Deserialize(response, typeof(List))); } - + + /// /// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. /// @@ -1253,7 +1264,8 @@ namespace IO.Swagger.Api (Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet))); } - + + /// /// Find pet by ID Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// @@ -1426,7 +1438,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Updates a pet in the store with form data /// @@ -1601,7 +1614,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Deletes a pet /// @@ -1776,7 +1790,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// uploads an image /// @@ -1949,7 +1964,8 @@ namespace IO.Swagger.Api (byte[]) Configuration.ApiClient.Deserialize(response, typeof(byte[]))); } - + + /// /// Fake endpoint to test byte array return by 'Find pet by ID' Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions /// @@ -2118,7 +2134,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Fake endpoint to test byte array in body parameter for adding a new pet to the store /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index ca876a043db..2646ef0619a 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -15,6 +15,7 @@ namespace IO.Swagger.Api /// public interface IStoreApi { + #region Synchronous Operations /// /// Returns pet inventories by status @@ -33,24 +34,6 @@ namespace IO.Swagger.Api /// /// ApiResponse of Dictionary<string, int?> ApiResponse> GetInventoryWithHttpInfo (); - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// Task of Dictionary<string, int?> - System.Threading.Tasks.Task> GetInventoryAsync (); - - /// - /// Returns pet inventories by status - /// - /// - /// Returns a map of status codes to quantities - /// - /// Task of ApiResponse (Dictionary<string, int?>) - System.Threading.Tasks.Task>> GetInventoryAsyncWithHttpInfo (); /// /// Place an order for a pet @@ -71,7 +54,69 @@ namespace IO.Swagger.Api /// order placed for purchasing the pet /// ApiResponse of Order ApiResponse PlaceOrderWithHttpInfo (Order body = null); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// Order + Order GetOrderById (string orderId); + + /// + /// Find purchase order by ID + /// + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + /// + /// ID of pet that needs to be fetched + /// ApiResponse of Order + ApiResponse GetOrderByIdWithHttpInfo (string orderId); + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// + void DeleteOrder (string orderId); + + /// + /// Delete purchase order by ID + /// + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + /// + /// ID of the order that needs to be deleted + /// ApiResponse of Object(void) + ApiResponse DeleteOrderWithHttpInfo (string orderId); + + #endregion Synchronous Operations + + #region Asynchronous Operations + + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Task of Dictionary<string, int?> + System.Threading.Tasks.Task> GetInventoryAsync (); + /// + /// Returns pet inventories by status + /// + /// + /// Returns a map of status codes to quantities + /// + /// Task of ApiResponse (Dictionary<string, int?>) + System.Threading.Tasks.Task>> GetInventoryAsyncWithHttpInfo (); + /// /// Place an order for a pet /// @@ -92,26 +137,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (Order) System.Threading.Tasks.Task> PlaceOrderAsyncWithHttpInfo (Order body = null); - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// - /// ID of pet that needs to be fetched - /// Order - Order GetOrderById (string orderId); - - /// - /// Find purchase order by ID - /// - /// - /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - /// - /// ID of pet that needs to be fetched - /// ApiResponse of Order - ApiResponse GetOrderByIdWithHttpInfo (string orderId); - /// /// Find purchase order by ID /// @@ -132,26 +157,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (Order) System.Threading.Tasks.Task> GetOrderByIdAsyncWithHttpInfo (string orderId); - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// ID of the order that needs to be deleted - /// - void DeleteOrder (string orderId); - - /// - /// Delete purchase order by ID - /// - /// - /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - /// - /// ID of the order that needs to be deleted - /// ApiResponse of Object(void) - ApiResponse DeleteOrderWithHttpInfo (string orderId); - /// /// Delete purchase order by ID /// @@ -172,6 +177,8 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> DeleteOrderAsyncWithHttpInfo (string orderId); + #endregion Asynchronous Operations + } /// @@ -326,7 +333,8 @@ namespace IO.Swagger.Api (Dictionary) Configuration.ApiClient.Deserialize(response, typeof(Dictionary))); } - + + /// /// Returns pet inventories by status Returns a map of status codes to quantities /// @@ -484,7 +492,8 @@ namespace IO.Swagger.Api (Order) Configuration.ApiClient.Deserialize(response, typeof(Order))); } - + + /// /// Place an order for a pet /// @@ -635,7 +644,8 @@ namespace IO.Swagger.Api (Order) Configuration.ApiClient.Deserialize(response, typeof(Order))); } - + + /// /// Find purchase order by ID For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions /// @@ -787,7 +797,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs index 168ce373ef9..b97bb313873 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs @@ -15,6 +15,7 @@ namespace IO.Swagger.Api /// public interface IUserApi { + #region Synchronous Operations /// /// Create user @@ -35,7 +36,153 @@ namespace IO.Swagger.Api /// Created user object /// ApiResponse of Object(void) ApiResponse CreateUserWithHttpInfo (User body = null); - + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// + void CreateUsersWithArrayInput (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// ApiResponse of Object(void) + ApiResponse CreateUsersWithArrayInputWithHttpInfo (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// + void CreateUsersWithListInput (List body = null); + + /// + /// Creates list of users with given input array + /// + /// + /// + /// + /// List of user object + /// ApiResponse of Object(void) + ApiResponse CreateUsersWithListInputWithHttpInfo (List body = null); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// string + string LoginUser (string username = null, string password = null); + + /// + /// Logs user into the system + /// + /// + /// + /// + /// The user name for login + /// The password for login in clear text + /// ApiResponse of string + ApiResponse LoginUserWithHttpInfo (string username = null, string password = null); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// + void LogoutUser (); + + /// + /// Logs out current logged in user session + /// + /// + /// + /// + /// ApiResponse of Object(void) + ApiResponse LogoutUserWithHttpInfo (); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// User + User GetUserByName (string username); + + /// + /// Get user by user name + /// + /// + /// + /// + /// The name that needs to be fetched. Use user1 for testing. + /// ApiResponse of User + ApiResponse GetUserByNameWithHttpInfo (string username); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// + void UpdateUser (string username, User body = null); + + /// + /// Updated user + /// + /// + /// This can only be done by the logged in user. + /// + /// name that need to be deleted + /// Updated user object + /// ApiResponse of Object(void) + ApiResponse UpdateUserWithHttpInfo (string username, User body = null); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// + void DeleteUser (string username); + + /// + /// Delete user + /// + /// + /// This can only be done by the logged in user. + /// + /// The name that needs to be deleted + /// ApiResponse of Object(void) + ApiResponse DeleteUserWithHttpInfo (string username); + + #endregion Synchronous Operations + + #region Asynchronous Operations + /// /// Create user /// @@ -56,26 +203,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> CreateUserAsyncWithHttpInfo (User body = null); - /// - /// Creates list of users with given input array - /// - /// - /// - /// - /// List of user object - /// - void CreateUsersWithArrayInput (List body = null); - - /// - /// Creates list of users with given input array - /// - /// - /// - /// - /// List of user object - /// ApiResponse of Object(void) - ApiResponse CreateUsersWithArrayInputWithHttpInfo (List body = null); - /// /// Creates list of users with given input array /// @@ -96,26 +223,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> CreateUsersWithArrayInputAsyncWithHttpInfo (List body = null); - /// - /// Creates list of users with given input array - /// - /// - /// - /// - /// List of user object - /// - void CreateUsersWithListInput (List body = null); - - /// - /// Creates list of users with given input array - /// - /// - /// - /// - /// List of user object - /// ApiResponse of Object(void) - ApiResponse CreateUsersWithListInputWithHttpInfo (List body = null); - /// /// Creates list of users with given input array /// @@ -136,28 +243,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> CreateUsersWithListInputAsyncWithHttpInfo (List body = null); - /// - /// Logs user into the system - /// - /// - /// - /// - /// The user name for login - /// The password for login in clear text - /// string - string LoginUser (string username = null, string password = null); - - /// - /// Logs user into the system - /// - /// - /// - /// - /// The user name for login - /// The password for login in clear text - /// ApiResponse of string - ApiResponse LoginUserWithHttpInfo (string username = null, string password = null); - /// /// Logs user into the system /// @@ -180,24 +265,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (string) System.Threading.Tasks.Task> LoginUserAsyncWithHttpInfo (string username = null, string password = null); - /// - /// Logs out current logged in user session - /// - /// - /// - /// - /// - void LogoutUser (); - - /// - /// Logs out current logged in user session - /// - /// - /// - /// - /// ApiResponse of Object(void) - ApiResponse LogoutUserWithHttpInfo (); - /// /// Logs out current logged in user session /// @@ -216,26 +283,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> LogoutUserAsyncWithHttpInfo (); - /// - /// Get user by user name - /// - /// - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// User - User GetUserByName (string username); - - /// - /// Get user by user name - /// - /// - /// - /// - /// The name that needs to be fetched. Use user1 for testing. - /// ApiResponse of User - ApiResponse GetUserByNameWithHttpInfo (string username); - /// /// Get user by user name /// @@ -256,28 +303,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse (User) System.Threading.Tasks.Task> GetUserByNameAsyncWithHttpInfo (string username); - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// name that need to be deleted - /// Updated user object - /// - void UpdateUser (string username, User body = null); - - /// - /// Updated user - /// - /// - /// This can only be done by the logged in user. - /// - /// name that need to be deleted - /// Updated user object - /// ApiResponse of Object(void) - ApiResponse UpdateUserWithHttpInfo (string username, User body = null); - /// /// Updated user /// @@ -300,26 +325,6 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> UpdateUserAsyncWithHttpInfo (string username, User body = null); - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// The name that needs to be deleted - /// - void DeleteUser (string username); - - /// - /// Delete user - /// - /// - /// This can only be done by the logged in user. - /// - /// The name that needs to be deleted - /// ApiResponse of Object(void) - ApiResponse DeleteUserWithHttpInfo (string username); - /// /// Delete user /// @@ -340,6 +345,8 @@ namespace IO.Swagger.Api /// Task of ApiResponse System.Threading.Tasks.Task> DeleteUserAsyncWithHttpInfo (string username); + #endregion Asynchronous Operations + } /// @@ -495,7 +502,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Create user This can only be done by the logged in user. /// @@ -646,7 +654,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Creates list of users with given input array /// @@ -797,7 +806,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Creates list of users with given input array /// @@ -946,7 +956,8 @@ namespace IO.Swagger.Api (string) Configuration.ApiClient.Deserialize(response, typeof(string))); } - + + /// /// Logs user into the system /// @@ -1092,7 +1103,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Logs out current logged in user session /// @@ -1239,7 +1251,8 @@ namespace IO.Swagger.Api (User) Configuration.ApiClient.Deserialize(response, typeof(User))); } - + + /// /// Get user by user name /// @@ -1400,7 +1413,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Updated user This can only be done by the logged in user. /// @@ -1554,7 +1568,8 @@ namespace IO.Swagger.Api response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), null); } - + + /// /// Delete user This can only be done by the logged in user. /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs index 9ff8b481e14..104911520a6 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs @@ -146,7 +146,7 @@ namespace IO.Swagger.Client var response = RestClient.Execute(request); return (Object) response; } - + /// /// Makes the asynchronous HTTP request. /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Properties/AssemblyInfo.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Properties/AssemblyInfo.cs index 1de9edb2a81..f3b9f7d1d14 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Properties/AssemblyInfo.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Properties/AssemblyInfo.cs @@ -1,6 +1,5 @@ using System.Reflection; using System.Runtime.InteropServices; -using System.Windows; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/packages.config b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/packages.config index c87bbb79fa6..91f17cd0819 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/packages.config +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/packages.config @@ -1,5 +1,5 @@ - + diff --git a/samples/client/petstore/java/default/README.md b/samples/client/petstore/java/default/README.md index 8afc37518fc..cc9672eab41 100644 --- a/samples/client/petstore/java/default/README.md +++ b/samples/client/petstore/java/default/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/default/build.gradle b/samples/client/petstore/java/default/build.gradle index b7ccd1df774..7bebf9164bb 100644 --- a/samples/client/petstore/java/default/build.gradle +++ b/samples/client/petstore/java/default/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + group = 'io.swagger' version = '1.0.0' diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java index 7a4ed1a63b0..d0ff5f3c583 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java @@ -41,7 +41,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class ApiClient { private Map defaultHeaderMap = new HashMap(); private String basePath = "http://petstore.swagger.io/v2"; @@ -83,8 +83,12 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index bc73e268ef2..06920b07e60 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -12,7 +12,7 @@ import java.io.File; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class PetApi { private ApiClient apiClient; @@ -238,7 +238,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; @@ -438,7 +438,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 6b727652f73..352f0069c85 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -12,7 +12,7 @@ import io.swagger.client.model.Order; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class StoreApi { private ApiClient apiClient; @@ -106,7 +106,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_client_id", "test_api_client_secret" }; GenericType returnType = new GenericType() {}; @@ -153,7 +153,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_key_query", "test_api_key_header" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java index afe72de51ae..fd2d25a1bb5 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Category { private Long id = null; @@ -63,10 +62,8 @@ public class Category { return false; } Category category = (Category) o; - - return true && Objects.equals(id, category.id) && - Objects.equals(name, category.name) - ; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 4b8126387e6..959b5c03711 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Order { private Long id = null; @@ -161,14 +161,12 @@ public class Order { return false; } Order order = (Order) o; - - return true && Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete) - ; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index c04f35adfad..42da6710435 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -13,7 +13,7 @@ import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Pet { private Long id = null; @@ -163,14 +163,12 @@ public class Pet { return false; } Pet pet = (Pet) o; - - return true && Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status) - ; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java index da7f31937c5..47560e0133b 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Tag { private Long id = null; @@ -63,10 +62,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - - return true && Objects.equals(id, tag.id) && - Objects.equals(name, tag.name) - ; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java index edb5b50931f..0af0d48a56d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class User { private Long id = null; @@ -178,16 +177,14 @@ public class User { return false; } User user = (User) o; - - return true && Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus) - ; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java index 29eae3d017e..9fa51a06baa 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java @@ -131,7 +131,13 @@ public class ApiClientTest { @Test public void testSetApiKeyAndPrefix() { - ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + ApiKeyAuth auth = null; + for (Authentication _auth : apiClient.getAuthentications().values()) { + if (_auth instanceof ApiKeyAuth) { + auth = (ApiKeyAuth) _auth; + break; + } + } auth.setApiKey(null); auth.setApiKeyPrefix(null); diff --git a/samples/client/petstore/java/feign/build.gradle b/samples/client/petstore/java/feign/build.gradle index 0bfcfbec71f..ee920fbc7ca 100644 --- a/samples/client/petstore/java/feign/build.gradle +++ b/samples/client/petstore/java/feign/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + group = 'io.swagger' version = '1.0.0' diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java index 2e032a9d1d1..303927d064e 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java @@ -18,7 +18,7 @@ import feign.slf4j.Slf4jLogger; import io.swagger.client.auth.*; import io.swagger.client.auth.OAuth.AccessTokenListener; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class ApiClient { public interface Api {} @@ -42,8 +42,16 @@ public class ApiClient { RequestInterceptor auth; if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); + } else if (authName == "test_api_client_id") { + auth = new ApiKeyAuth("header", "x-test_api_client_id"); + } else if (authName == "test_api_client_secret") { + auth = new ApiKeyAuth("header", "x-test_api_client_secret"); } else if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "test_api_key_query") { + auth = new ApiKeyAuth("query", "test_api_key_query"); + } else if (authName == "test_api_key_header") { + auth = new ApiKeyAuth("header", "test_api_key_header"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index 02a44b271f0..d2755e6ac41 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import java.io.File; import java.util.*; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public interface PetApi extends ApiClient.Api { @@ -122,4 +122,30 @@ public interface PetApi extends ApiClient.Api { }) void uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return byte[] + */ + @RequestLine("GET /pet/{petId}?testing_byte_array=true") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + byte[] getPetByIdWithByteArray(@Param("petId") Long petId); + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array + * @return void + */ + @RequestLine("POST /pet?testing_byte_array=true") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + void addPetUsingByteArray(byte[] body); + } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index 92e69c4d407..2060d4f6624 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Category { private Long id = null; @@ -19,8 +18,13 @@ public class Category { /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -45,7 +54,7 @@ public class Category { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -53,10 +62,8 @@ public class Category { return false; } Category category = (Category) o; - - return true && Objects.equals(id, category.id) && - Objects.equals(name, category.name) - ; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override @@ -79,7 +86,7 @@ public class Category { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index 3dc9168d926..0086f0c61a7 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Order { private Long id = null; @@ -44,8 +44,13 @@ public class Order { /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -57,8 +62,13 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("petId") public Long getPetId() { return petId; @@ -70,8 +80,13 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("quantity") public Integer getQuantity() { return quantity; @@ -83,8 +98,13 @@ public class Order { /** **/ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("shipDate") public Date getShipDate() { return shipDate; @@ -97,8 +117,13 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "Order Status") + @ApiModelProperty(example = "null", value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -110,8 +135,13 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("complete") public Boolean getComplete() { return complete; @@ -123,7 +153,7 @@ public class Order { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -131,14 +161,12 @@ public class Order { return false; } Order order = (Order) o; - - return true && Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete) - ; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override @@ -165,7 +193,7 @@ public class Order { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index 908d654679a..c90aec64ea8 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -13,7 +13,7 @@ import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Pet { private Long id = null; @@ -46,8 +46,13 @@ public class Pet { /** **/ + public Pet id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -59,8 +64,13 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("category") public Category getCategory() { return category; @@ -72,8 +82,13 @@ public class Pet { /** **/ + public Pet name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -85,8 +100,13 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { return photoUrls; @@ -98,8 +118,13 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("tags") public List getTags() { return tags; @@ -112,8 +137,13 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "pet status in the store") + @ApiModelProperty(example = "null", value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -125,7 +155,7 @@ public class Pet { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -133,14 +163,12 @@ public class Pet { return false; } Pet pet = (Pet) o; - - return true && Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status) - ; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override @@ -167,7 +195,7 @@ public class Pet { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index 337c84211a4..2a3678bc883 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Tag { private Long id = null; @@ -19,8 +18,13 @@ public class Tag { /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -45,7 +54,7 @@ public class Tag { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -53,10 +62,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - - return true && Objects.equals(id, tag.id) && - Objects.equals(name, tag.name) - ; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override @@ -79,7 +86,7 @@ public class Tag { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index b05d8a58a81..1f8cf539938 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class User { private Long id = null; @@ -25,8 +24,13 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -38,8 +42,13 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("username") public String getUsername() { return username; @@ -51,8 +60,13 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("firstName") public String getFirstName() { return firstName; @@ -64,8 +78,13 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("lastName") public String getLastName() { return lastName; @@ -77,8 +96,13 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("email") public String getEmail() { return email; @@ -90,8 +114,13 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("password") public String getPassword() { return password; @@ -103,8 +132,13 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("phone") public String getPhone() { return phone; @@ -117,8 +151,13 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + - @ApiModelProperty(value = "User Status") + @ApiModelProperty(example = "null", value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { return userStatus; @@ -130,7 +169,7 @@ public class User { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -138,16 +177,14 @@ public class User { return false; } User user = (User) o; - - return true && Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus) - ; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override @@ -176,7 +213,7 @@ public class User { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle index 85ad4f048b9..c3a9375c9e0 100644 --- a/samples/client/petstore/java/jersey2/build.gradle +++ b/samples/client/petstore/java/jersey2/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + group = 'io.swagger' version = '1.0.0' diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java index 89fe7f60680..77bcbef413c 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java @@ -48,7 +48,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class ApiClient { private Map defaultHeaderMap = new HashMap(); private String basePath = "http://petstore.swagger.io/v2"; @@ -85,7 +85,11 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index a4402076fa7..4c9690ac4c1 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -12,7 +12,7 @@ import java.io.File; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class PetApi { private ApiClient apiClient; @@ -238,7 +238,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; @@ -438,7 +438,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index f20b99b2ae7..d5bbd658dbb 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -12,7 +12,7 @@ import io.swagger.client.model.Order; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class StoreApi { private ApiClient apiClient; @@ -106,7 +106,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_client_id", "test_api_client_secret" }; GenericType returnType = new GenericType() {}; @@ -153,7 +153,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_key_query", "test_api_key_header" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index 8c409d96e1c..fb8f0542c8d 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Category { private Long id = null; @@ -19,8 +18,13 @@ public class Category { /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -53,10 +62,8 @@ public class Category { return false; } Category category = (Category) o; - - return true && Objects.equals(id, category.id) && - Objects.equals(name, category.name) - ; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 40d3765f1da..478483ef7af 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Order { private Long id = null; @@ -44,8 +44,13 @@ public class Order { /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -57,8 +62,13 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("petId") public Long getPetId() { return petId; @@ -70,8 +80,13 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("quantity") public Integer getQuantity() { return quantity; @@ -83,8 +98,13 @@ public class Order { /** **/ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("shipDate") public Date getShipDate() { return shipDate; @@ -97,8 +117,13 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "Order Status") + @ApiModelProperty(example = "null", value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -110,8 +135,13 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("complete") public Boolean getComplete() { return complete; @@ -131,14 +161,12 @@ public class Order { return false; } Order order = (Order) o; - - return true && Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete) - ; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 68a0dd6e67b..f23c7a720b6 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -13,7 +13,7 @@ import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Pet { private Long id = null; @@ -46,8 +46,13 @@ public class Pet { /** **/ + public Pet id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -59,8 +64,13 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("category") public Category getCategory() { return category; @@ -72,8 +82,13 @@ public class Pet { /** **/ + public Pet name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -85,8 +100,13 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { return photoUrls; @@ -98,8 +118,13 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("tags") public List getTags() { return tags; @@ -112,8 +137,13 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "pet status in the store") + @ApiModelProperty(example = "null", value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -133,14 +163,12 @@ public class Pet { return false; } Pet pet = (Pet) o; - - return true && Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status) - ; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 769e5829b45..62dc4226d30 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Tag { private Long id = null; @@ -19,8 +18,13 @@ public class Tag { /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -53,10 +62,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - - return true && Objects.equals(id, tag.id) && - Objects.equals(name, tag.name) - ; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 73de26c5e7a..ba036559069 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class User { private Long id = null; @@ -25,8 +24,13 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -38,8 +42,13 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("username") public String getUsername() { return username; @@ -51,8 +60,13 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("firstName") public String getFirstName() { return firstName; @@ -64,8 +78,13 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("lastName") public String getLastName() { return lastName; @@ -77,8 +96,13 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("email") public String getEmail() { return email; @@ -90,8 +114,13 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("password") public String getPassword() { return password; @@ -103,8 +132,13 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("phone") public String getPhone() { return phone; @@ -117,8 +151,13 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + - @ApiModelProperty(value = "User Status") + @ApiModelProperty(example = "null", value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { return userStatus; @@ -138,16 +177,14 @@ public class User { return false; } User user = (User) o; - - return true && Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus) - ; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java index 29eae3d017e..9fa51a06baa 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java @@ -131,7 +131,13 @@ public class ApiClientTest { @Test public void testSetApiKeyAndPrefix() { - ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + ApiKeyAuth auth = null; + for (Authentication _auth : apiClient.getAuthentications().values()) { + if (_auth instanceof ApiKeyAuth) { + auth = (ApiKeyAuth) _auth; + break; + } + } auth.setApiKey(null); auth.setApiKeyPrefix(null); diff --git a/samples/client/petstore/java/okhttp-gson/README.md b/samples/client/petstore/java/okhttp-gson/README.md index be7ff686b7a..fd85a16cd07 100644 --- a/samples/client/petstore/java/okhttp-gson/README.md +++ b/samples/client/petstore/java/okhttp-gson/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 73a9187e75f..0f853388744 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -145,8 +145,12 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index 497e3ade6a8..a29ace374f8 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -491,7 +491,7 @@ public class PetApi { }); } - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } @@ -936,7 +936,7 @@ public class PetApi { }); } - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 5e6c7c48c6b..11d1eded300 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -180,7 +180,7 @@ public class StoreApi { }); } - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_client_id", "test_api_client_secret" }; return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } @@ -288,7 +288,7 @@ public class StoreApi { }); } - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_key_query", "test_api_key_header" }; return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java index d0908afd9e1..e7052e47170 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java @@ -52,8 +52,8 @@ public class Category { return false; } Category category = (Category) o; - return Objects.equals(id, category.id) && - Objects.equals(name, category.name); + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java index 59c5238b626..5b96b2a32b2 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java @@ -133,12 +133,12 @@ public enum StatusEnum { return false; } Order order = (Order) o; - return Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete); + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java index 1f9462ddc3a..02990adb380 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java @@ -135,12 +135,12 @@ public enum StatusEnum { return false; } Pet pet = (Pet) o; - return Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status); + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java index a4ca1074ca1..4f8217b7678 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java @@ -52,8 +52,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - return Objects.equals(id, tag.id) && - Objects.equals(name, tag.name); + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java index 072f510081a..bcec1fc0a1c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java @@ -137,14 +137,14 @@ public class User { return false; } User user = (User) o; - return Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus); + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java index c22da2acac6..9e6d5f42642 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java @@ -170,7 +170,13 @@ public class ApiClientTest { @Test public void testSetApiKeyAndPrefix() { - ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + ApiKeyAuth auth = null; + for (Authentication _auth : apiClient.getAuthentications().values()) { + if (_auth instanceof ApiKeyAuth) { + auth = (ApiKeyAuth) _auth; + break; + } + } auth.setApiKey(null); auth.setApiKeyPrefix(null); diff --git a/samples/client/petstore/javascript-promise/package.json b/samples/client/petstore/javascript-promise/package.json index 1fdf78cf217..72a48ac71de 100644 --- a/samples/client/petstore/javascript-promise/package.json +++ b/samples/client/petstore/javascript-promise/package.json @@ -12,6 +12,7 @@ }, "devDependencies": { "mocha": "~2.3.4", + "sinon": "1.17.3", "expect.js": "~0.3.1" } } diff --git a/samples/client/petstore/javascript-promise/src/ApiClient.js b/samples/client/petstore/javascript-promise/src/ApiClient.js index 353494ea941..a0c70eb10ee 100644 --- a/samples/client/petstore/javascript-promise/src/ApiClient.js +++ b/samples/client/petstore/javascript-promise/src/ApiClient.js @@ -21,6 +21,15 @@ */ this.basePath = 'http://petstore.swagger.io/v2'.replace(/\/+$/, ''); + this.authentications = { + 'petstore_auth': {type: 'oauth2'}, + 'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'}, + 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, + 'test_api_key_query': {type: 'apiKey', in: 'query', name: 'test_api_key_query'}, + 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'} + }; + /** * The default HTTP headers to be included for all API calls. */ @@ -158,6 +167,42 @@ } }; + ApiClient.prototype.applyAuthToRequest = function applyAuthToRequest(request, authNames) { + var _this = this; + authNames.forEach(function(authName) { + var auth = _this.authentications[authName]; + switch (auth.type) { + case 'basic': + if (auth.username || auth.password) { + request.auth(auth.username || '', auth.password || ''); + } + break; + case 'apiKey': + if (auth.apiKey) { + var data = {}; + if (auth.apiKeyPrefix) { + data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey; + } else { + data[auth.name] = auth.apiKey; + } + if (auth.in === 'header') { + request.set(data); + } else { + request.query(data); + } + } + break; + case 'oauth2': + if (auth.accessToken) { + request.set({'Authorization': 'Bearer ' + auth.accessToken}); + } + break; + default: + throw new Error('Unknown authentication type: ' + auth.type); + } + }); + }; + ApiClient.prototype.deserialize = function deserialize(response, returnType) { if (response == null || returnType == null) { return null; @@ -166,18 +211,23 @@ // See http://visionmedia.github.io/superagent/#parsing-response-bodies var data = response.body; if (data == null) { - return null; + // Superagent does not always produce a body; use the unparsed response + // as a fallback + data = response.text; } return ApiClient.convertToType(data, returnType); }; ApiClient.prototype.callApi = function callApi(path, httpMethod, pathParams, - queryParams, headerParams, formParams, bodyParam, contentTypes, accepts, - returnType) { + queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, + accepts, returnType) { var _this = this; var url = this.buildUrl(path, pathParams); var request = superagent(httpMethod, url); + // apply authentications + this.applyAuthToRequest(request, authNames); + // set query parameters request.query(this.normalizeParams(queryParams)); diff --git a/samples/client/petstore/javascript-promise/src/api/PetApi.js b/samples/client/petstore/javascript-promise/src/api/PetApi.js index d2ece31da91..d6f7bd8275a 100644 --- a/samples/client/petstore/javascript-promise/src/api/PetApi.js +++ b/samples/client/petstore/javascript-promise/src/api/PetApi.js @@ -41,6 +41,7 @@ var formParams = { }; + var authNames = ['petstore_auth']; var contentTypes = ['application/json', 'application/xml']; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -48,7 +49,7 @@ return this.apiClient.callApi( '/pet', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -73,6 +74,7 @@ var formParams = { }; + var authNames = ['petstore_auth']; var contentTypes = ['application/json', 'application/xml']; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -80,7 +82,7 @@ return this.apiClient.callApi( '/pet', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -107,6 +109,7 @@ var formParams = { }; + var authNames = ['petstore_auth']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = [Pet]; @@ -114,7 +117,7 @@ return this.apiClient.callApi( '/pet/findByStatus', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -141,6 +144,7 @@ var formParams = { }; + var authNames = ['petstore_auth']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = [Pet]; @@ -148,7 +152,7 @@ return this.apiClient.callApi( '/pet/findByTags', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -180,6 +184,7 @@ var formParams = { }; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Pet; @@ -187,7 +192,7 @@ return this.apiClient.callApi( '/pet/{petId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -222,6 +227,7 @@ 'status': status }; + var authNames = ['petstore_auth']; var contentTypes = ['application/x-www-form-urlencoded']; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -229,7 +235,7 @@ return this.apiClient.callApi( '/pet/{petId}', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -262,6 +268,7 @@ var formParams = { }; + var authNames = ['petstore_auth']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -269,7 +276,7 @@ return this.apiClient.callApi( '/pet/{petId}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -304,6 +311,7 @@ 'file': file }; + var authNames = ['petstore_auth']; var contentTypes = ['multipart/form-data']; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -311,7 +319,7 @@ return this.apiClient.callApi( '/pet/{petId}/uploadImage', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -343,6 +351,7 @@ var formParams = { }; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = 'String'; @@ -350,7 +359,7 @@ return this.apiClient.callApi( '/pet/{petId}?testing_byte_array=true', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -375,6 +384,7 @@ var formParams = { }; + var authNames = ['petstore_auth']; var contentTypes = ['application/json', 'application/xml']; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -382,7 +392,7 @@ return this.apiClient.callApi( '/pet?testing_byte_array=true', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } diff --git a/samples/client/petstore/javascript-promise/src/api/StoreApi.js b/samples/client/petstore/javascript-promise/src/api/StoreApi.js index d6f0503c136..57a3c57d86f 100644 --- a/samples/client/petstore/javascript-promise/src/api/StoreApi.js +++ b/samples/client/petstore/javascript-promise/src/api/StoreApi.js @@ -41,6 +41,7 @@ var formParams = { }; + var authNames = ['api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = {'String': 'Integer'}; @@ -48,7 +49,7 @@ return this.apiClient.callApi( '/store/inventory', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -74,6 +75,7 @@ var formParams = { }; + var authNames = ['test_api_client_id', 'test_api_client_secret']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Order; @@ -81,7 +83,7 @@ return this.apiClient.callApi( '/store/order', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -113,6 +115,7 @@ var formParams = { }; + var authNames = ['test_api_key_query', 'test_api_key_header']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Order; @@ -120,7 +123,7 @@ return this.apiClient.callApi( '/store/order/{orderId}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -151,6 +154,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -158,7 +162,7 @@ return this.apiClient.callApi( '/store/order/{orderId}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } diff --git a/samples/client/petstore/javascript-promise/src/api/UserApi.js b/samples/client/petstore/javascript-promise/src/api/UserApi.js index 09f7c9e0d5b..bb93561ec1b 100644 --- a/samples/client/petstore/javascript-promise/src/api/UserApi.js +++ b/samples/client/petstore/javascript-promise/src/api/UserApi.js @@ -41,6 +41,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -48,7 +49,7 @@ return this.apiClient.callApi( '/user', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -73,6 +74,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -80,7 +82,7 @@ return this.apiClient.callApi( '/user/createWithArray', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -105,6 +107,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -112,7 +115,7 @@ return this.apiClient.callApi( '/user/createWithList', 'POST', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -141,6 +144,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = 'String'; @@ -148,7 +152,7 @@ return this.apiClient.callApi( '/user/login', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -172,6 +176,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -179,7 +184,7 @@ return this.apiClient.callApi( '/user/logout', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -211,6 +216,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = User; @@ -218,7 +224,7 @@ return this.apiClient.callApi( '/user/{username}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -250,6 +256,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -257,7 +264,7 @@ return this.apiClient.callApi( '/user/{username}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } @@ -288,6 +295,7 @@ var formParams = { }; + var authNames = []; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = null; @@ -295,7 +303,7 @@ return this.apiClient.callApi( '/user/{username}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, - contentTypes, accepts, returnType + authNames, contentTypes, accepts, returnType ); } diff --git a/samples/client/petstore/javascript/src/ApiClient.js b/samples/client/petstore/javascript/src/ApiClient.js index 5f6def1e17e..d4377e34d1a 100644 --- a/samples/client/petstore/javascript/src/ApiClient.js +++ b/samples/client/petstore/javascript/src/ApiClient.js @@ -23,7 +23,11 @@ this.authentications = { 'petstore_auth': {type: 'oauth2'}, - 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'} + 'test_api_client_id': {type: 'apiKey', in: 'header', name: 'x-test_api_client_id'}, + 'test_api_client_secret': {type: 'apiKey', in: 'header', name: 'x-test_api_client_secret'}, + 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'}, + 'test_api_key_query': {type: 'apiKey', in: 'query', name: 'test_api_key_query'}, + 'test_api_key_header': {type: 'apiKey', in: 'header', name: 'test_api_key_header'} }; /** @@ -207,7 +211,9 @@ // See http://visionmedia.github.io/superagent/#parsing-response-bodies var data = response.body; if (data == null) { - return null; + // Superagent does not always produce a body; use the unparsed response + // as a fallback + data = response.text; } return ApiClient.convertToType(data, returnType); }; diff --git a/samples/client/petstore/javascript/src/api/PetApi.js b/samples/client/petstore/javascript/src/api/PetApi.js index 5843f850b4d..07520e12414 100644 --- a/samples/client/petstore/javascript/src/api/PetApi.js +++ b/samples/client/petstore/javascript/src/api/PetApi.js @@ -102,7 +102,7 @@ var pathParams = { }; var queryParams = { - 'status': this.buildCollectionParam(status, 'multi') + 'status': this.apiClient.buildCollectionParam(status, 'multi') }; var headerParams = { }; @@ -137,7 +137,7 @@ var pathParams = { }; var queryParams = { - 'tags': this.buildCollectionParam(tags, 'multi') + 'tags': this.apiClient.buildCollectionParam(tags, 'multi') }; var headerParams = { }; @@ -184,7 +184,7 @@ var formParams = { }; - var authNames = ['api_key']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Pet; @@ -351,7 +351,7 @@ var formParams = { }; - var authNames = ['api_key']; + var authNames = ['petstore_auth', 'api_key']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = 'String'; diff --git a/samples/client/petstore/javascript/src/api/StoreApi.js b/samples/client/petstore/javascript/src/api/StoreApi.js index 15fc97eac25..cf9bc1c78af 100644 --- a/samples/client/petstore/javascript/src/api/StoreApi.js +++ b/samples/client/petstore/javascript/src/api/StoreApi.js @@ -75,7 +75,7 @@ var formParams = { }; - var authNames = []; + var authNames = ['test_api_client_id', 'test_api_client_secret']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Order; @@ -115,7 +115,7 @@ var formParams = { }; - var authNames = []; + var authNames = ['test_api_key_query', 'test_api_key_header']; var contentTypes = []; var accepts = ['application/json', 'application/xml']; var returnType = Order; diff --git a/samples/client/petstore/javascript/test/ApiClientTest.js b/samples/client/petstore/javascript/test/ApiClientTest.js index 58444eaef2f..b149175d682 100644 --- a/samples/client/petstore/javascript/test/ApiClientTest.js +++ b/samples/client/petstore/javascript/test/ApiClientTest.js @@ -12,8 +12,28 @@ describe('ApiClient', function() { expect(apiClient).to.be.ok(); expect(apiClient.basePath).to.be('http://petstore.swagger.io/v2'); expect(apiClient.authentications).to.eql({ - 'petstore_auth': {type: 'oauth2'}, - 'api_key': {type: 'apiKey', in: 'header', name: 'api_key'} + petstore_auth: {type: 'oauth2'}, + api_key: {type: 'apiKey', in: 'header', name: 'api_key'}, + test_api_client_id: { + type: 'apiKey', + in: 'header', + name: 'x-test_api_client_id' + }, + test_api_client_secret: { + type: 'apiKey', + in: 'header', + name: 'x-test_api_client_secret' + }, + test_api_key_query: { + type: 'apiKey', + in: 'query', + name: 'test_api_key_query' + }, + test_api_key_header: { + type: 'apiKey', + in: 'header', + name: 'test_api_key_header' + } }); }); diff --git a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php index 58f4ca7b65d..65cf886f561 100644 --- a/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/tests/PetApiTest.php @@ -2,6 +2,10 @@ require_once('autoload.php'); +// increase memory limit to avoid fatal error due to findPetByStatus +// returning a lot of data +ini_set('memory_limit', '256M'); + class PetApiTest extends \PHPUnit_Framework_TestCase {