diff --git a/.gitignore b/.gitignore index 20b9a13e93f..0dc52799236 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ samples/server-generator/scalatra/output/.history # nodejs samples/server-generator/node/output/node_modules samples/server/petstore/nodejs/node_modules +samples/server/petstore/nodejs-server/node_modules # qt5 cpp samples/client/petstore/qt5cpp/PetStore/moc_* @@ -55,6 +56,12 @@ samples/client/petstore/qt5cpp/PetStore/Makefile **/.gradle/ samples/client/petstore/java/hello.txt samples/client/petstore/android/default/hello.txt +samples/client/petstore/android/volley/.gradle/ +samples/client/petstore/android/volley/build/ +samples/client/petstore/java/jersey2/.gradle/ +samples/client/petstore/java/jersey2/build/ +samples/client/petstore/java/okhttp-gson/.gradle/ +samples/client/petstore/java/okhttp-gson/build/ #PHP samples/client/petstore/php/SwaggerClient-php/composer.lock @@ -87,6 +94,10 @@ samples/client/petstore/csharp/SwaggerClientTest/bin samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/vendor/ samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/ samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/ +samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/nuget.exe +samples/client/petstore/csharp/SwaggerClientTest/TestResult.xml +samples/client/petstore/csharp/SwaggerClientTest/nuget.exe +samples/client/petstore/csharp/SwaggerClientTest/testrunner/ # Python *.pyc diff --git a/README.md b/README.md index 3cc10ca1e4d..1c7ecb5758d 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20 Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes -------------------------- | ------------ | -------------------------- | ----- 2.1.7-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) -2.1.6 (**current stable**) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.5) +2.1.6 (**current stable**) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6) 2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) 1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java index 0091204a0ab..a7045738cc3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenProperty.java @@ -32,6 +32,7 @@ public class CodegenProperty { public Boolean exclusiveMinimum; public Boolean exclusiveMaximum; public Boolean hasMore, required, secondaryParam; + public Boolean hasMoreNonReadOnly; // for model constructor, true if next properyt is not readonly public Boolean isPrimitiveType, isContainer, isNotContainer; public Boolean isString, isInteger, isLong, isFloat, isDouble, isByteArray, isBinary, isBoolean, isDate, isDateTime; public Boolean isListContainer, isMapContainer; @@ -63,6 +64,7 @@ public class CodegenProperty { result = prime * result + ((exclusiveMinimum == null) ? 0 : exclusiveMinimum.hashCode()); result = prime * result + ((getter == null) ? 0 : getter.hashCode()); result = prime * result + ((hasMore == null) ? 0 : hasMore.hashCode()); + result = prime * result + ((hasMoreNonReadOnly == null) ? 0 : hasMoreNonReadOnly.hashCode()); result = prime * result + ((isContainer == null) ? 0 : isContainer.hashCode()); result = prime * result + (isEnum ? 1231 : 1237); result = prime * result + ((isNotContainer == null) ? 0 : isNotContainer.hashCode()); 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 b2a28287471..9cd719dbe87 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 @@ -2220,9 +2220,12 @@ public class DefaultCodegen { } private void addVars(CodegenModel m, List vars, Map properties, Set mandatory) { - final int totalCount = properties.size(); - int count = 0; - for (Map.Entry entry : properties.entrySet()) { + // convert set to list so that we can access the next entry in the loop + List> propertyList = new ArrayList>(properties.entrySet()); + final int totalCount = propertyList.size(); + for (int i = 0; i < totalCount; i++) { + Map.Entry entry = propertyList.get(i); + final String key = entry.getKey(); final Property prop = entry.getValue(); @@ -2236,13 +2239,19 @@ public class DefaultCodegen { // m.hasEnums to be set incorrectly if allProperties has enumerations but properties does not. m.hasEnums = true; } - count++; - if (count != totalCount) { + + if (i+1 != totalCount) { cp.hasMore = true; + // check the next entry to see if it's read only + if (!Boolean.TRUE.equals(propertyList.get(i+1).getValue().getReadOnly())) { + cp.hasMoreNonReadOnly = true; // next entry is not ready only + } } + if (cp.isContainer != null) { addImport(m, typeMapping.get("array")); } + addImport(m, cp.baseType); addImport(m, cp.complexType); vars.add(cp); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java index db5847d9672..76c0d1277b1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractCSharpCodegen.java @@ -101,6 +101,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co typeMapping = new HashMap(); typeMapping.put("string", "string"); typeMapping.put("binary", "byte[]"); + typeMapping.put("bytearray", "byte[]"); typeMapping.put("boolean", "bool?"); typeMapping.put("integer", "int?"); typeMapping.put("float", "float?"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java index cb2547b67a0..70b98676ab3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java @@ -52,9 +52,8 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { Arrays.asList( "String", "bool", - "num", "int", - "float") + "double") ); instantiationTypes.put("array", "List"); instantiationTypes.put("map", "Map"); @@ -66,11 +65,11 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("boolean", "bool"); typeMapping.put("string", "String"); typeMapping.put("int", "int"); - typeMapping.put("float", "num"); + typeMapping.put("float", "double"); typeMapping.put("long", "int"); typeMapping.put("short", "int"); typeMapping.put("char", "String"); - typeMapping.put("double", "num"); + typeMapping.put("double", "double"); typeMapping.put("object", "Object"); typeMapping.put("integer", "int"); typeMapping.put("Date", "DateTime"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java index 007b3a8f36b..234bda9adb7 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/GoClientCodegen.java @@ -131,6 +131,7 @@ public class GoClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("README.mustache", "", "README.md")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + supportingFiles.add(new SupportingFile("configuration.mustache", packageName, "Configuration.go")); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index 4ec5fa0693b..74553f0e33c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java @@ -4,6 +4,7 @@ import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; +import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; @@ -36,6 +37,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { protected String license = "MIT"; protected String gitRepoURL = "https://github.com/swagger-api/swagger-codegen"; protected String[] specialWords = {"new", "copy"}; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public ObjcClientCodegen() { super(); @@ -46,6 +49,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { apiTemplateFiles.put("api-header.mustache", ".h"); apiTemplateFiles.put("api-body.mustache", ".m"); embeddedTemplateDir = templateDir = "objc"; + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); defaultIncludes.clear(); defaultIncludes.add("bool"); @@ -199,6 +204,10 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put(GIT_REPO_URL, gitRepoURL); additionalProperties.put(LICENSE, license); + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + String swaggerFolder = podName; modelPackage = swaggerFolder; @@ -388,6 +397,26 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { return name; } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath).replace("/", File.separator); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath).replace("/", File.separator); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + @Override public String apiFileFolder() { return outputFolder + File.separatorChar + apiPackage(); @@ -562,4 +591,75 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { return null; } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("NSString*".equalsIgnoreCase(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "@\"" + escapeText(example) + "\""; + } else if ("NSNumber*".equals(type)) { + if (example == null) { + example = "56"; + } + example = "@" + example; + /* OBJC uses NSNumber to represent both int, long, double and float + } else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) { + if (example == null) { + example = "3.4"; + } */ + } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) { + if (example == null) { + example = "True"; + } + } else if ("NSURL*".equalsIgnoreCase(type)) { + if (example == null) { + example = "/path/to/file"; + } + //[NSURL fileURLWithPath:@"path/to/file"] + example = "[NSURL fileURLWithPath:@\"" + escapeText(example) + "\"]"; + /*} else if ("NSDate".equalsIgnoreCase(type)) { + if (example == null) { + example = "2013-10-20"; + } + example = "'" + escapeText(example) + "'";*/ + } else if ("NSDate*".equalsIgnoreCase(type)) { + if (example == null) { + example = "2013-10-20T19:20:30+01:00"; + } + example = "@\"" + escapeText(example) + "\""; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + type = type.replace("*", ""); + // e.g. [[SWGPet alloc] init + example = "[[" + type + " alloc] init]"; + } else { + LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); + } + + if (example == null) { + example = "NULL"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "@[" + example + "]"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "@{@\"key\" : " + example + "}"; + } + + p.example = example; + } + + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index e8ee2e0d1ad..33d5875de6e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -96,6 +96,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping = new HashMap(); typeMapping.put("integer", "int"); typeMapping.put("long", "int"); + typeMapping.put("number", "float"); typeMapping.put("float", "float"); typeMapping.put("double", "double"); typeMapping.put("string", "string"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 2b10bdd86d0..6091b36b90a 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -3,6 +3,7 @@ package io.swagger.codegen.languages; import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; +import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenType; import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.SupportingFile; @@ -17,6 +18,8 @@ import org.apache.commons.lang.StringUtils; public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig { protected String packageName; protected String packageVersion; + protected String apiDocPath = "docs/"; + protected String modelDocPath = "docs/"; public PythonClientCodegen() { super(); @@ -28,6 +31,9 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig apiTemplateFiles.put("api.mustache", ".py"); embeddedTemplateDir = templateDir = "python"; + modelDocTemplateFiles.put("model_doc.mustache", ".md"); + apiDocTemplateFiles.put("api_doc.mustache", ".md"); + languageSpecificPrimitives.clear(); languageSpecificPrimitives.add("int"); languageSpecificPrimitives.add("float"); @@ -36,6 +42,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig languageSpecificPrimitives.add("str"); languageSpecificPrimitives.add("datetime"); languageSpecificPrimitives.add("date"); + languageSpecificPrimitives.add("object"); typeMapping.clear(); typeMapping.put("integer", "int"); @@ -97,6 +104,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion); + // make api and model doc path available in mustache template + additionalProperties.put("apiDocPath", apiDocPath); + additionalProperties.put("modelDocPath", modelDocPath); + String swaggerFolder = packageName; modelPackage = swaggerFolder + File.separatorChar + "models"; @@ -138,6 +149,27 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig return "_" + name; } + @Override + public String apiDocFileFolder() { + return (outputFolder + "/" + apiDocPath); + } + + @Override + public String modelDocFileFolder() { + return (outputFolder + "/" + modelDocPath); + } + + @Override + public String toModelDocFilename(String name) { + return toModelName(name); + } + + @Override + public String toApiDocFilename(String name) { + return toApiName(name); + } + + @Override public String apiFileFolder() { return outputFolder + File.separatorChar + apiPackage().replace('.', File.separatorChar); @@ -388,4 +420,70 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig return null; } + @Override + public void setParameterExampleValue(CodegenParameter p) { + String example; + + if (p.defaultValue == null) { + example = p.example; + } else { + example = p.defaultValue; + } + + String type = p.baseType; + if (type == null) { + type = p.dataType; + } + + if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) { + if (example == null) { + example = p.paramName + "_example"; + } + example = "'" + escapeText(example) + "'"; + } else if ("Integer".equals(type) || "int".equals(type)) { + if (example == null) { + example = "56"; + } + } else if ("Float".equalsIgnoreCase(type) || "Double".equalsIgnoreCase(type)) { + if (example == null) { + example = "3.4"; + } + } else if ("BOOLEAN".equalsIgnoreCase(type) || "bool".equalsIgnoreCase(type)) { + if (example == null) { + example = "True"; + } + } else if ("file".equalsIgnoreCase(type)) { + if (example == null) { + example = "/path/to/file"; + } + example = "'" + escapeText(example) + "'"; + } else if ("Date".equalsIgnoreCase(type)) { + if (example == null) { + example = "2013-10-20"; + } + example = "'" + escapeText(example) + "'"; + } else if ("DateTime".equalsIgnoreCase(type)) { + if (example == null) { + example = "2013-10-20T19:20:30+01:00"; + } + example = "'" + escapeText(example) + "'"; + } else if (!languageSpecificPrimitives.contains(type)) { + // type is a model class, e.g. User + example = this.packageName + "." + type + "()"; + } else { + LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); + } + + if (example == null) { + example = "NULL"; + } else if (Boolean.TRUE.equals(p.isListContainer)) { + example = "[" + example + "]"; + } else if (Boolean.TRUE.equals(p.isMapContainer)) { + example = "{'key': " + example + "}"; + } + + p.example = example; + } + + } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 003dbba2b79..0725d36eec8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -74,6 +74,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { languageSpecificPrimitives = new HashSet( Arrays.asList( "Int", + "Int32", + "Int64", "Float", "Double", "Bool", @@ -115,10 +117,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("string", "String"); typeMapping.put("char", "Character"); typeMapping.put("short", "Int"); - typeMapping.put("int", "Int"); - typeMapping.put("long", "Int"); - typeMapping.put("integer", "Int"); - typeMapping.put("Integer", "Int"); + typeMapping.put("int", "Int32"); + typeMapping.put("long", "Int64"); + typeMapping.put("integer", "Int32"); + typeMapping.put("Integer", "Int32"); typeMapping.put("float", "Float"); typeMapping.put("number", "Double"); typeMapping.put("double", "Double"); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache index a5cfd0ebef2..9f34c16afc5 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/retrofit2/build.gradle.mustache @@ -46,6 +46,10 @@ if(hasProperty('target') && target == 'android') { } } } + + dependencies { + provided 'javax.annotation:jsr250-api:1.0' + } } afterEvaluate { diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index 347834f329a..4f33807f978 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -41,7 +41,7 @@ namespace {{packageName}}.Model /// {{#vars}}{{^isReadOnly}} /// {{#description}}{{description}}{{/description}}{{^description}}{{name}}{{/description}}{{#required}} (required){{/required}}{{#defaultValue}} (default to {{defaultValue}}){{/defaultValue}}. {{/isReadOnly}}{{/vars}} - public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{#hasMore}}, {{/hasMore}}{{/isReadOnly}}{{/vars}}) + public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}} {{name}} = null{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/isReadOnly}}{{/vars}}) { {{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null) if ({{name}} == null) diff --git a/modules/swagger-codegen/src/main/resources/dart/apilib.mustache b/modules/swagger-codegen/src/main/resources/dart/apilib.mustache index f9699315566..178fe027e39 100644 --- a/modules/swagger-codegen/src/main/resources/dart/apilib.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/apilib.mustache @@ -18,5 +18,5 @@ part 'auth/http_basic_auth.dart'; {{#apiInfo}}{{#apis}}part 'api/{{classVarName}}_api.dart'; {{/apis}}{{/apiInfo}} -{{#models}}{{#model}}part 'model/{{classVarName}}.dart'; -{{/model}}{{/models}} \ No newline at end of file +{{#models}}{{#model}}part 'model/{{classFilename}}.dart'; +{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/go/api.mustache b/modules/swagger-codegen/src/main/resources/go/api.mustache index 49b7f92693e..d1cf877cd43 100644 --- a/modules/swagger-codegen/src/main/resources/go/api.mustache +++ b/modules/swagger-codegen/src/main/resources/go/api.mustache @@ -12,18 +12,22 @@ import ( ) type {{classname}} struct { - basePath string + Configuration Configuration } func New{{classname}}() *{{classname}}{ + configuration := NewConfiguration() return &{{classname}} { - basePath: "{{basePath}}", + Configuration: *configuration, } } func New{{classname}}WithBasePath(basePath string) *{{classname}}{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &{{classname}} { - basePath: basePath, + Configuration: *configuration, } } @@ -37,7 +41,7 @@ func New{{classname}}WithBasePath(basePath string) *{{classname}}{ //func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { func (a {{classname}}) {{nickname}} ({{#allParams}}{{paramName}} {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) ({{#returnType}}{{{returnType}}}, {{/returnType}}error) { - _sling := sling.New().{{httpMethod}}(a.basePath) + _sling := sling.New().{{httpMethod}}(a.Configuration.BasePath) // create path and map variables path := "{{basePathWithoutHost}}{{path}}" diff --git a/modules/swagger-codegen/src/main/resources/go/configuration.mustache b/modules/swagger-codegen/src/main/resources/go/configuration.mustache new file mode 100644 index 00000000000..bf3a8f92bed --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/go/configuration.mustache @@ -0,0 +1,25 @@ +package {{packageName}} + +import ( + +) + +type Configuration struct { + UserName string `json:"userName,omitempty"` + ApiKey string `json:"apiKey,omitempty"` + Debug bool `json:"debug,omitempty"` + DebugFile string `json:"debugFile,omitempty"` + OAuthToken string `json:"oAuthToken,omitempty"` + Timeout int `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` +} + +func NewConfiguration() *Configuration { + return &Configuration{ + BasePath: "{{basePath}}", + UserName: "", + Debug: false, + } +} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index a7dec733321..142e14a9e80 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -716,11 +716,11 @@ static void (^reachabilityChangeBlock)(int); for (NSString *auth in authSettings) { NSDictionary *authSetting = [[config authSettings] objectForKey:auth]; - if (authSetting) { - if ([authSetting[@"in"] isEqualToString:@"header"]) { + if (authSetting) { // auth setting is set only if the key is non-empty + if ([authSetting[@"in"] isEqualToString:@"header"] && [authSetting[@"key"] length] != 0) { [headersWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; } - else if ([authSetting[@"in"] isEqualToString:@"query"]) { + else if ([authSetting[@"in"] isEqualToString:@"query"] && [authSetting[@"key"] length] != 0) { [querysWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; } } diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache index 167b05aef1f..4f5442ed213 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache @@ -29,6 +29,7 @@ self.host = @"{{basePath}}"; self.username = @""; self.password = @""; + self.accessToken= @""; self.tempFolderPath = nil; self.debug = NO; self.verifySSL = YES; @@ -42,18 +43,23 @@ #pragma mark - Instance Methods - (NSString *) getApiKeyWithPrefix:(NSString *)key { - if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { + if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // both api key prefix and api key are set return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; } - else if ([self.apiKey objectForKey:key]) { + else if ([self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // only api key, no api key prefix return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; } - else { + else { // return empty string if nothing is set return @""; } } - (NSString *) getBasicAuthToken { + // return empty string if username and password are empty + if (self.username.length == 0 && self.password.length == 0){ + return @""; + } + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; @@ -61,6 +67,15 @@ return basicAuthCredentials; } +- (NSString *) getAccessToken { + if (self.accessToken.length == 0) { // token not set, return empty string + return @""; + } + else { + return [NSString stringWithFormat:@"BEARER %@", self.accessToken]; + } +} + #pragma mark - Setter Methods - (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier { @@ -126,6 +141,15 @@ @"value": [self getBasicAuthToken] }, {{/isBasic}} +{{#isOAuth}} + @"{{name}}": + @{ + @"type": @"oauth", + @"in": @"header", + @"key": @"Authorization", + @"value": [self getAccessToken] + }, +{{/isOAuth}} {{/authMethods}} }; } diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache index 9abe135bc47..b77ddfe5dee 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache @@ -46,6 +46,11 @@ */ @property (nonatomic) NSString *password; +/** + * Access token for OAuth + */ +@property (nonatomic) NSString *accessToken; + /** * Temp folder for file download */ @@ -132,6 +137,11 @@ */ - (NSString *) getBasicAuthToken; +/** + * Gets OAuth access token + */ +- (NSString *) getAccessToken; + /** * Gets Authentication Setings */ diff --git a/modules/swagger-codegen/src/main/resources/objc/README.mustache b/modules/swagger-codegen/src/main/resources/objc/README.mustache index 30a8927c41a..2e6ffe2f060 100644 --- a/modules/swagger-codegen/src/main/resources/objc/README.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/README.mustache @@ -1,20 +1,147 @@ # {{podName}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- Package version: {{artifactVersion}} +- Build date: {{generatedDate}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + ## Requirements -The API client library requires ARC (Automatic Reference Counting) to be enabled in your Xcode project. +The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.com/questions/7778356/how-to-enable-disable-automatic-reference-counting) to be enabled in the Xcode project. -## Installation +## Installation & Usage +### Install from Github using [CocoaPods](https://cocoapods.org/) -To install it, put the API client library in your project and then simply add the following line to your Podfile: +Add the following to the Podfile: ```ruby -pod "{{podName}}", :path => "/path/to/lib" +pod '{{podName}}', :git => 'https://github.com/{{gitUserId}}/{{gitRepoId}}.git' +``` + +To specify a particular branch, append `, :branch => 'branch-name-here'` + +To specify a particular commit, append `, :commit => '11aa22'` + +### Install from local path using [CocoaPods](https://cocoapods.org/) + +Put the SDK under your project folder (e.g. /path/to/objc_project/Vendor/{{podName}}) and then add the following to the Podfile: + +```ruby +pod '{{podName}}', :path => 'Vendor/{{podName}}' +``` + +### Usage + +Import the following: +```objc +#import <{{podName}}/{{{classPrefix}}}ApiClient.h> +#import <{{podName}}/{{{classPrefix}}}Configuration.h> +// load models +{{#models}}{{#model}}#import <{{podName}}/{{{classname}}}.h> +{{/model}}{{/models}}// load API classes for accessing endpoints +{{#apiInfo}}{{#apis}}#import <{{podName}}/{{{classname}}}.h> +{{/apis}}{{/apiInfo}} ``` ## Recommendation -It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issue. +It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```objc +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{#hasAuthMethods}} +{{classPrefix}}Configuration *apiConfig = [{{classPrefix}}Configuration sharedConfig]; +{{#authMethods}}{{#isBasic}}// Configure HTTP basic authorization (authentication scheme: {{{name}}}) +[apiConfig setUsername:@"YOUR_USERNAME"]; +[apiConfig setPassword:@"YOUR_PASSWORD"]; +{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: (authentication scheme: {{{name}}}) +[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"]; +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"{{{keyParamName}}}"]; +{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}}) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; +{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} + +{{#allParams}}{{{dataType}}} *{{paramName}} = {{{example}}}; // {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +@try +{ + {{classname}} *apiInstance = [[{{classname}} alloc] init]; + +{{#summary}} // {{{.}}} +{{/summary}} [apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}} + {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}} + {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error)) { +{{#returnType}} + if (output) { + NSLog(@"%@", output); + } +{{/returnType}} + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling {{classname}}->{{operationId}}: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorizatoin URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} ## Author diff --git a/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache b/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache new file mode 100644 index 00000000000..109128c1ca1 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache @@ -0,0 +1,93 @@ +# {{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +```objc +-(NSNumber*) {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}} + {{paramName}}{{/secondaryParam}}: ({{{dataType}}}) {{paramName}}{{/allParams}} + {{#hasParams}}completionHandler: {{/hasParams}}(void (^)({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error)) handler; +``` + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```objc +{{#hasAuthMethods}} +{{classPrefix}}Configuration *apiConfig = [{{classPrefix}}Configuration sharedConfig]; +{{#authMethods}}{{#isBasic}}// Configure HTTP basic authorization (authentication scheme: {{{name}}}) +[apiConfig setUsername:@"YOUR_USERNAME"]; +[apiConfig setPassword:@"YOUR_PASSWORD"]; +{{/isBasic}}{{#isApiKey}} +// Configure API key authorization: (authentication scheme: {{{name}}}) +[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"]; +// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"{{{keyParamName}}}"]; +{{/isApiKey}}{{#isOAuth}} +// Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}}) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; +{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} + +{{#allParams}}{{{dataType}}} {{paramName}} = {{{example}}}; // {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +@try +{ + {{classname}} *apiInstance = [[{{classname}} alloc] init]; + +{{#summary}} // {{{.}}} +{{/summary}} [apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}} + {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}} + {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) { +{{#returnType}} + if (output) { + NSLog(@"%@", output); + } +{{/returnType}} + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling {{classname}}->{{operationId}}: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP reuqest headers + + - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/objc/model_doc.mustache b/modules/swagger-codegen/src/main/resources/objc/model_doc.mustache new file mode 100644 index 00000000000..569550df372 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/model_doc.mustache @@ -0,0 +1,11 @@ +{{#models}}{{#model}}# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache index 891149d8f55..7945137c664 100644 --- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache @@ -259,7 +259,7 @@ class ApiClient * * @return string Accept (e.g. application/json) */ - public static function selectHeaderAccept($accept) + public function selectHeaderAccept($accept) { if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { return null; @@ -277,7 +277,7 @@ class ApiClient * * @return string Content-Type (e.g. application/json) */ - public static function selectHeaderContentType($content_type) + public function selectHeaderContentType($content_type) { if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { return 'application/json'; @@ -299,9 +299,9 @@ class ApiClient { // ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986 $headers = array(); - $key = ''; // [+] + $key = ''; - foreach(explode("\n", $raw_headers) as $i => $h) + foreach(explode("\n", $raw_headers) as $h) { $h = explode(':', $h, 2); @@ -311,26 +311,22 @@ class ApiClient $headers[$h[0]] = trim($h[1]); elseif (is_array($headers[$h[0]])) { - // $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-] - // $headers[$h[0]] = $tmp; // [-] - $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+] + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); } else { - // $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-] - // $headers[$h[0]] = $tmp; // [-] - $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+] + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); } - $key = $h[0]; // [+] + $key = $h[0]; + } + else + { + if (substr($h[0], 0, 1) == "\t") + $headers[$key] .= "\r\n\t".trim($h[0]); + elseif (!$key) + $headers[0] = trim($h[0]);trim($h[0]); } - else // [+] - { // [+] - if (substr($h[0], 0, 1) == "\t") // [+] - $headers[$key] .= "\r\n\t".trim($h[0]); // [+] - elseif (!$key) // [+] - $headers[0] = trim($h[0]);trim($h[0]); // [+] - } // [+] } return $headers; diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache index 759bf3c6bfb..34d79b0ae39 100644 --- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache +++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache @@ -55,14 +55,14 @@ class ObjectSerializer public static function sanitizeForSerialization($data) { if (is_scalar($data) || null === $data) { - $sanitized = $data; + return $data; } elseif ($data instanceof \DateTime) { - $sanitized = $data->format(\DateTime::ATOM); + return $data->format(\DateTime::ATOM); } elseif (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = self::sanitizeForSerialization($value); } - $sanitized = $data; + return $data; } elseif (is_object($data)) { $values = array(); foreach (array_keys($data::swaggerTypes()) as $property) { @@ -71,12 +71,10 @@ class ObjectSerializer $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($data->$getter()); } } - $sanitized = (object)$values; + return (object)$values; } else { - $sanitized = (string)$data; + return (string)$data; } - - return $sanitized; } /** @@ -224,7 +222,7 @@ class ObjectSerializer public static function deserialize($data, $class, $httpHeaders=null, $discriminator=null) { if (null === $data) { - $deserialized = null; + return null; } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] $inner = substr($class, 4, -1); $deserialized = array(); @@ -235,16 +233,17 @@ class ObjectSerializer $deserialized[$key] = self::deserialize($value, $subClass, null, $discriminator); } } + return $deserialized; } elseif (strcasecmp(substr($class, -2), '[]') == 0) { $subClass = substr($class, 0, -2); $values = array(); foreach ($data as $key => $value) { $values[] = self::deserialize($value, $subClass, null, $discriminator); } - $deserialized = $values; + return $values; } elseif ($class === 'object') { settype($data, 'array'); - $deserialized = $data; + return $data; } elseif ($class === '\DateTime') { // Some API's return an invalid, empty string as a // date-time property. DateTime::__construct() will return @@ -253,13 +252,13 @@ class ObjectSerializer // be interpreted as a missing field/value. Let's handle // this graceful. if (!empty($data)) { - $deserialized = new \DateTime($data); + return new \DateTime($data); } else { - $deserialized = null; + return null; } } elseif (in_array($class, array({{&primitives}}))) { settype($data, $class); - $deserialized = $data; + return $data; } elseif ($class === '\SplFileObject') { // determine file name if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { @@ -270,7 +269,8 @@ class ObjectSerializer $deserialized = new \SplFileObject($filename, "w"); $byte_written = $deserialized->fwrite($data); error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile()); - + return $deserialized; + } else { // If a discriminator is defined and points to a valid subclass, use it. if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { @@ -292,9 +292,7 @@ class ObjectSerializer $instance->$propertySetter(self::deserialize($propertyValue, $type, null, $discriminator)); } } - $deserialized = $instance; + return $instance; } - - return $deserialized; } } diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index adbbd8e1fe2..2692ba66f94 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -102,7 +102,7 @@ use \{{invokerPackage}}\ObjectSerializer; */ public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { - list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); + list($response) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}); return $response; } @@ -130,11 +130,11 @@ use \{{invokerPackage}}\ObjectSerializer; $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}})); + $_header_accept = $this->apiClient->selectHeaderAccept(array({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}})); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}})); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}})); {{#queryParams}}// query params {{#collectionFormat}} @@ -223,14 +223,14 @@ use \{{invokerPackage}}\ObjectSerializer; return array(null, $statusCode, $httpHeader); } - return array(\{{invokerPackage}}\ObjectSerializer::deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader); + return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader); {{/returnType}}{{^returnType}} return array(null, $statusCode, $httpHeader); {{/returnType}} } catch (ApiException $e) { switch ($e->getCode()) { {{#responses}}{{#dataType}} {{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}} - $data = \{{invokerPackage}}\ObjectSerializer::deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders()); $e->setResponseObject($data); break;{{/dataType}}{{/responses}} } diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache index b58af994c24..f19787f50b0 100644 --- a/modules/swagger-codegen/src/main/resources/php/model.mustache +++ b/modules/swagger-codegen/src/main/resources/php/model.mustache @@ -192,11 +192,11 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this)); } } {{/model}} diff --git a/modules/swagger-codegen/src/main/resources/python/README.mustache b/modules/swagger-codegen/src/main/resources/python/README.mustache index 463bbb37a18..a1ba2f0d298 100644 --- a/modules/swagger-codegen/src/main/resources/python/README.mustache +++ b/modules/swagger-codegen/src/main/resources/python/README.mustache @@ -1,73 +1,122 @@ +# {{packageName}} +{{#appDescription}} +{{{appDescription}}} +{{/appDescription}} + +This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: {{appVersion}} +- Package version: {{packageVersion}} +- Build date: {{generatedDate}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + ## Requirements. -Python 2.7 and later. -## Setuptools -You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools). +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on Github, you can install directly from Github ```sh -python setup.py install +pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git +``` +(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`) + +Then import the package: +```python +import {{{packageName}}} ``` -Or you can install from Github via pip: +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). ```sh -pip install git+https://github.com/geekerzp/swagger_client.git +python setup.py install --user ``` +(or `sudo python setup.py install` to install the package for all users) -To use the bindings, import the pacakge: - +Then import the package: ```python -import swagger_client -``` - -## Manual Installation -If you do not wish to use setuptools, you can download the latest release. -Then, to use the bindings, import the package: - -```python -import path.to.swagger_client +import {{{packageName}}} ``` ## Getting Started -TODO +Please follow the [installation procedure](#installation--usage) and then run the following: -## Documentation +```python +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +{{{packageName}}}.configuration.username = 'YOUR_USERNAME' +{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'BEARER'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}} +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} -TODO - -## Tests - -(Please make sure you have [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) installed) - - Execute the following command to run the tests in the current Python (v2 or v3) environment: - -```sh -$ make test -[... magically installs dependencies and runs tests on your virtualenv] -Ran 7 tests in 19.289s - -OK +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print "Exception when calling {{classname}}->{{operationId}}: %s\n" % e +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} ``` -or -``` -$ mvn integration-test -rf :PythonPetstoreClientTests -Using 2195432783 as seed -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 37.594 s -[INFO] Finished at: 2015-05-16T18:00:35+08:00 -[INFO] Final Memory: 11M/156M -[INFO] ------------------------------------------------------------------------ -``` -If you want to run the tests in all the python platforms: +## Documentation for API Endpoints -```sh -$ make test-all -[... tox creates a virtualenv for every platform and runs tests inside of each] - py27: commands succeeded - py34: commands succeeded - congratulations :) -``` +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation For Models + +{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md) +{{/model}}{{/models}} + +## Documentation For Authorization + +{{^authMethods}} All endpoints do not require authorization. +{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}} +{{#authMethods}}## {{{name}}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{{keyParamName}}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{{flow}}} +- **Authorizatoin URL**: {{{authorizationUrl}}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - **{{{scope}}}**: {{{description}}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache index 230f05d94af..0967a2ec6b3 100644 --- a/modules/swagger-codegen/src/main/resources/python/api.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api.mustache @@ -47,7 +47,7 @@ class {{classname}}(object): self.api_client = config.api_client {{#operation}} - def {{nickname}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): + def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs): """ {{{summary}}} {{{notes}}} @@ -59,10 +59,10 @@ class {{classname}}(object): >>> pprint(response) >>> {{#sortParamsByRequiredFlag}} - >>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function) + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function) {{/sortParamsByRequiredFlag}} {{^sortParamsByRequiredFlag}} - >>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function) + >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function) {{/sortParamsByRequiredFlag}} :param callback function: The callback function @@ -83,7 +83,7 @@ class {{classname}}(object): if key not in all_params: raise TypeError( "Got an unexpected keyword argument '%s'" - " to method {{nickname}}" % key + " to method {{operationId}}" % key ) params[key] = val del params['kwargs'] @@ -92,7 +92,7 @@ class {{classname}}(object): {{#required}} # verify the required parameter '{{paramName}}' is set if ('{{paramName}}' not in params) or (params['{{paramName}}'] is None): - raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{nickname}}`") + raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") {{/required}} {{/allParams}} diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 98fee823591..07b9419e08f 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -371,7 +371,8 @@ class ApiClient(object): elif method == "DELETE": return self.rest_client.DELETE(url, query_params=query_params, - headers=headers) + headers=headers, + body=body) else: raise ValueError( "http method must be `GET`, `HEAD`," diff --git a/modules/swagger-codegen/src/main/resources/python/api_doc.mustache b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache new file mode 100644 index 00000000000..b4f921fa870 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache @@ -0,0 +1,74 @@ +# {{packageName}}.{{classname}}{{#description}} +{{description}}{{/description}} + +All URIs are relative to *{{basePath}}* + +Method | HTTP request | Description +------------- | ------------- | ------------- +{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}} + +{{#operations}} +{{#operation}} +# **{{{operationId}}}** +> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) + +{{{summary}}}{{#notes}} + +{{{notes}}}{{/notes}} + +### Example +```python +import time +import {{{packageName}}} +from {{{packageName}}}.rest import ApiException +from pprint import pprint +{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +# Configure HTTP basic authorization: {{{name}}} +{{{packageName}}}.configuration.username = 'YOUR_USERNAME' +{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}} +# Configure API key authorization: {{{name}}} +{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY' +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'BEARER'{{/isApiKey}}{{#isOAuth}} +# Configure OAuth2 access token for authorization: {{{name}}} +{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} +{{/hasAuthMethods}} + +# create an instance of the API class +api_instance = {{{packageName}}}.{{{classname}}}() +{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} +{{/allParams}} + +try: +{{#summary}} # {{{.}}} +{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}} + pprint(api_response){{/returnType}} +except ApiException as e: + print "Exception when calling {{classname}}->{{operationId}}: %s\n" % e +``` + +### Parameters +{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} +Name | Type | Description | Notes +------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{/allParams}} + +### Return type + +{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}} + +### Authorization + +{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}} + +### HTTP reuqest headers + + - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}} + - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}} + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +{{/operation}} +{{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/python/model_doc.mustache b/modules/swagger-codegen/src/main/resources/python/model_doc.mustache new file mode 100644 index 00000000000..569550df372 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/python/model_doc.mustache @@ -0,0 +1,11 @@ +{{#models}}{{#model}}# {{classname}} + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}} +{{/vars}} + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + +{{/model}}{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/python/rest.mustache b/modules/swagger-codegen/src/main/resources/python/rest.mustache index c5b9a4e6f91..352bb503ac5 100644 --- a/modules/swagger-codegen/src/main/resources/python/rest.mustache +++ b/modules/swagger-codegen/src/main/resources/python/rest.mustache @@ -133,8 +133,8 @@ class RESTClientObject(object): headers['Content-Type'] = 'application/json' try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) if headers['Content-Type'] == 'application/json': @@ -154,7 +154,7 @@ class RESTClientObject(object): fields=post_params, encode_multipart=True, headers=headers) - # For `GET`, `HEAD`, `DELETE` + # For `GET`, `HEAD` else: r = self.pool_manager.request(method, url, fields=query_params, @@ -195,10 +195,11 @@ class RESTClientObject(object): post_params=post_params, body=body) - def DELETE(self, url, headers=None, query_params=None): + def DELETE(self, url, headers=None, query_params=None, body=None): return self.request("DELETE", url, headers=headers, - query_params=query_params) + query_params=query_params, + body=body) def POST(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("POST", url, diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache index d67b39f0d48..594a813de72 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache @@ -21,7 +21,7 @@ module {{moduleName}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}] def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) - {{#returnType}}data, status_code, headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) + {{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) {{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}} end @@ -58,12 +58,12 @@ module {{moduleName}} header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type){{#headerParams}}{{#required}} + local_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type){{#headerParams}}{{#required}} header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}{{/required}}{{/headerParams}}{{#headerParams}}{{^required}} header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if opts[:'{{{paramName}}}']{{/required}}{{/headerParams}} diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache index 520a50b76ca..d423ec82a19 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache @@ -19,6 +19,8 @@ module {{moduleName}} # @return [Hash] attr_accessor :default_headers + # Initializes the ApiClient + # @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config @user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}" @@ -59,6 +61,15 @@ module {{moduleName}} return data, response.code, response.headers end + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Typhoeus::Request] A Typhoeus Request def build_request(http_method, path, opts = {}) url = build_request_url(path) http_method = http_method.to_sym.downcase @@ -100,12 +111,15 @@ module {{moduleName}} # application/json # application/json; charset=UTF8 # APPLICATION/JSON + # @param [String] mime MIME + # @return [Boolean] True if the MIME is applicaton/json def json_mime?(mime) - !!(mime =~ /\Aapplication\/json(;.*)?\z/i) + !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil? end # Deserialize the response to the given return type. # + # @param [Response] response HTTP response # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]" def deserialize(response, return_type) body = response.body @@ -136,6 +150,9 @@ module {{moduleName}} end # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type def convert_to_type(data, return_type) return nil if data.nil? case return_type @@ -208,7 +225,7 @@ module {{moduleName}} # @param [String] filename the filename to be sanitized # @return [String] the sanitized filename def sanitize_filename(filename) - filename.gsub /.*[\/\\]/, '' + filename.gsub(/.*[\/\\]/, '') end def build_request_url(path) @@ -217,6 +234,12 @@ module {{moduleName}} URI.encode(@config.base_url + path) end + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string def build_request_body(header_params, form_params, body) # http form if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || @@ -240,6 +263,10 @@ module {{moduleName}} end # Update hearder and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [String] auth_names Authentication scheme name def update_params_for_auth!(header_params, query_params, auth_names) Array(auth_names).each do |auth_name| auth_setting = @config.auth_settings[auth_name] @@ -252,6 +279,9 @@ module {{moduleName}} end end + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0) def user_agent=(user_agent) @user_agent = user_agent @default_headers['User-Agent'] = @user_agent @@ -283,13 +313,13 @@ module {{moduleName}} # @return [String] JSON string representation of the object def object_to_http_body(model) return model if model.nil? || model.is_a?(String) - _body = nil + local_body = nil if model.is_a?(Array) - _body = model.map{|m| object_to_hash(m) } + local_body = model.map{|m| object_to_hash(m) } else - _body = object_to_hash(model) + local_body = object_to_hash(model) end - _body.to_json + local_body.to_json end # Convert object(non-array) to hash. diff --git a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache index 2c7747c4127..87877d1763e 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache @@ -1,23 +1,27 @@ - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -51,21 +55,25 @@ end end else # model - _model = {{moduleName}}.const_get(type).new - _model.build_from_hash(value) + temp_model = {{moduleName}}.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -76,8 +84,10 @@ hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache index 86567e1d594..373a0634be2 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache @@ -28,11 +28,13 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} {{#vars}} if attributes[:'{{{baseName}}}'] @@ -46,6 +48,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end {{#vars}}{{#isEnum}} # Custom attribute writer method checking allowed values (enum). + # @param [Object] {{{name}}} Object to be assigned def {{{name}}}=({{{name}}}) allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}] if {{{name}}} && !allowed_values.include?({{{name}}}) @@ -54,7 +57,8 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} @{{{name}}} = {{{name}}} end {{/isEnum}}{{/vars}} - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class{{#vars}} && @@ -62,11 +66,13 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}} end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash end diff --git a/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache b/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache index ed5786d3faa..54a1f127ef7 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache @@ -19,6 +19,14 @@ extension Int: JSONEncodable { func encodeToJSON() -> AnyObject { return self } } +extension Int32: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(int: self) } +} + +extension Int64: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(longLong: self) } +} + extension Double: JSONEncodable { func encodeToJSON() -> AnyObject { return self } } diff --git a/modules/swagger-codegen/src/main/resources/swift/Models.mustache b/modules/swagger-codegen/src/main/resources/swift/Models.mustache index d3090faf2a0..31cb4a2e219 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Models.mustache @@ -56,6 +56,12 @@ class Decoders { static func decode(clazz clazz: T.Type, source: AnyObject) -> T { initialize() + if T.self is Int32.Type && source is NSNumber { + return source.intValue as! T; + } + if T.self is Int64.Type && source is NSNumber { + return source.longLongValue as! T; + } if source is T { return source as! T } diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache index f095940a0c1..7e2f99a9de8 100644 --- a/modules/swagger-codegen/src/main/resources/swift/model.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache @@ -25,8 +25,10 @@ public class {{classname}}: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { - var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}} - nillableDictionary["{{baseName}}"] = self.{{name}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}} + var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}} + nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isInteger}}{{#isLong}} + nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isLong}}{{^isLong}}{{^isInteger}} + nillableDictionary["{{baseName}}"] = self.{{name}}{{/isInteger}}{{/isLong}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}} nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.rawValue{{/isEnum}}{{^isPrimitiveType}} nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isNotContainer}}{{#isContainer}} nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isContainer}}{{/vars}} diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index dfd7937242e..64b56377393 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -1314,12 +1314,16 @@ }, "Name": { "description": "Model for testing model name same as property name", + "required": [ + "name" + ], "properties": { "name": { "type": "integer", "format": "int32" }, "snake_case": { + "readOnly": true, "type": "integer", "format": "int32" } @@ -1375,6 +1379,59 @@ "type" : "string" } } + }, + "format_test" : { + "type" : "object", + "required": [ + "number" + ], + "properties" : { + "integer" : { + "type": "integer" + }, + "int32" : { + "type": "integer", + "format": "int32" + }, + "int64" : { + "type": "integer", + "format": "int64" + }, + "number" : { + "type": "number" + }, + "float" : { + "type": "number", + "format": "float" + }, + "double" : { + "type": "number", + "format": "double" + }, + "string" : { + "type": "string" + }, + "byte" : { + "type": "string", + "format": "byte" + }, + "binary" : { + "type": "string", + "format": "binary" + }, + "date" : { + "type": "string", + "format": "date" + }, + "dateTime" : { + "type": "string", + "format": "date-time" + }, + "dateTime" : { + "type": "string", + "format": "password" + } + } } } } diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml index cbfae8e4c45..cb34cd3b51d 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml @@ -8,7 +8,7 @@ info: For this sample, you can use the api key `special-key` to test the authorization filters version: "1.0.0" title: Swagger Petstore - termsOfService: http://helloreverb.com/terms/ + termsOfService: http://swagger.io/terms/ contact: name: apiteam@swagger.io license: @@ -573,4 +573,4 @@ definitions: type: string description: Order Status complete: - type: boolean \ No newline at end of file + type: boolean diff --git a/pom.xml b/pom.xml index 3df725ed581..9ac1890ea91 100644 --- a/pom.xml +++ b/pom.xml @@ -570,7 +570,7 @@ 2.4 1.7.12 3.2.1 - 1.9 + 1.12 6.9.6 2.18.1 1.19 diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/FormatTest.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/FormatTest.cs new file mode 100644 index 00000000000..bfcd371a1df --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/FormatTest.cs @@ -0,0 +1,291 @@ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public partial class FormatTest : IEquatable + { + + /// + /// Initializes a new instance of the class. + /// Initializes a new instance of the class. + /// + /// Integer. + /// Int32. + /// Int64. + /// Number (required). + /// _Float. + /// _Double. + /// _String. + /// _Byte. + /// Binary. + /// Date. + /// DateTime. + + public FormatTest(int? Integer = null, int? Int32 = null, long? Int64 = null, double? Number = null, float? _Float = null, double? _Double = null, string _String = null, byte[] _Byte = null, byte[] Binary = null, DateTime? Date = null, string DateTime = null) + { + // to ensure "Number" is required (not null) + if (Number == null) + { + throw new InvalidDataException("Number is a required property for FormatTest and cannot be null"); + } + else + { + this.Number = Number; + } + this.Integer = Integer; + this.Int32 = Int32; + this.Int64 = Int64; + this._Float = _Float; + this._Double = _Double; + this._String = _String; + this._Byte = _Byte; + this.Binary = Binary; + this.Date = Date; + this.DateTime = DateTime; + + } + + + /// + /// Gets or Sets Integer + /// + [DataMember(Name="integer", EmitDefaultValue=false)] + public int? Integer { get; set; } + + /// + /// Gets or Sets Int32 + /// + [DataMember(Name="int32", EmitDefaultValue=false)] + public int? Int32 { get; set; } + + /// + /// Gets or Sets Int64 + /// + [DataMember(Name="int64", EmitDefaultValue=false)] + public long? Int64 { get; set; } + + /// + /// Gets or Sets Number + /// + [DataMember(Name="number", EmitDefaultValue=false)] + public double? Number { get; set; } + + /// + /// Gets or Sets _Float + /// + [DataMember(Name="float", EmitDefaultValue=false)] + public float? _Float { get; set; } + + /// + /// Gets or Sets _Double + /// + [DataMember(Name="double", EmitDefaultValue=false)] + public double? _Double { get; set; } + + /// + /// Gets or Sets _String + /// + [DataMember(Name="string", EmitDefaultValue=false)] + public string _String { get; set; } + + /// + /// Gets or Sets _Byte + /// + [DataMember(Name="byte", EmitDefaultValue=false)] + public byte[] _Byte { get; set; } + + /// + /// Gets or Sets Binary + /// + [DataMember(Name="binary", EmitDefaultValue=false)] + public byte[] Binary { get; set; } + + /// + /// Gets or Sets Date + /// + [DataMember(Name="date", EmitDefaultValue=false)] + public DateTime? Date { get; set; } + + /// + /// Gets or Sets DateTime + /// + [DataMember(Name="dateTime", EmitDefaultValue=false)] + public string DateTime { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class FormatTest {\n"); + sb.Append(" Integer: ").Append(Integer).Append("\n"); + sb.Append(" Int32: ").Append(Int32).Append("\n"); + sb.Append(" Int64: ").Append(Int64).Append("\n"); + sb.Append(" Number: ").Append(Number).Append("\n"); + sb.Append(" _Float: ").Append(_Float).Append("\n"); + sb.Append(" _Double: ").Append(_Double).Append("\n"); + sb.Append(" _String: ").Append(_String).Append("\n"); + sb.Append(" _Byte: ").Append(_Byte).Append("\n"); + sb.Append(" Binary: ").Append(Binary).Append("\n"); + sb.Append(" Date: ").Append(Date).Append("\n"); + sb.Append(" DateTime: ").Append(DateTime).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as FormatTest); + } + + /// + /// Returns true if FormatTest instances are equal + /// + /// Instance of FormatTest to be compared + /// Boolean + public bool Equals(FormatTest other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.Integer == other.Integer || + this.Integer != null && + this.Integer.Equals(other.Integer) + ) && + ( + this.Int32 == other.Int32 || + this.Int32 != null && + this.Int32.Equals(other.Int32) + ) && + ( + this.Int64 == other.Int64 || + this.Int64 != null && + this.Int64.Equals(other.Int64) + ) && + ( + this.Number == other.Number || + this.Number != null && + this.Number.Equals(other.Number) + ) && + ( + this._Float == other._Float || + this._Float != null && + this._Float.Equals(other._Float) + ) && + ( + this._Double == other._Double || + this._Double != null && + this._Double.Equals(other._Double) + ) && + ( + this._String == other._String || + this._String != null && + this._String.Equals(other._String) + ) && + ( + this._Byte == other._Byte || + this._Byte != null && + this._Byte.Equals(other._Byte) + ) && + ( + this.Binary == other.Binary || + this.Binary != null && + this.Binary.Equals(other.Binary) + ) && + ( + this.Date == other.Date || + this.Date != null && + this.Date.Equals(other.Date) + ) && + ( + this.DateTime == other.DateTime || + this.DateTime != null && + this.DateTime.Equals(other.DateTime) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + + if (this.Integer != null) + hash = hash * 59 + this.Integer.GetHashCode(); + + if (this.Int32 != null) + hash = hash * 59 + this.Int32.GetHashCode(); + + if (this.Int64 != null) + hash = hash * 59 + this.Int64.GetHashCode(); + + if (this.Number != null) + hash = hash * 59 + this.Number.GetHashCode(); + + if (this._Float != null) + hash = hash * 59 + this._Float.GetHashCode(); + + if (this._Double != null) + hash = hash * 59 + this._Double.GetHashCode(); + + if (this._String != null) + hash = hash * 59 + this._String.GetHashCode(); + + if (this._Byte != null) + hash = hash * 59 + this._Byte.GetHashCode(); + + if (this.Binary != null) + hash = hash * 59 + this.Binary.GetHashCode(); + + if (this.Date != null) + hash = hash * 59 + this.Date.GetHashCode(); + + if (this.DateTime != null) + hash = hash * 59 + this.DateTime.GetHashCode(); + + return hash; + } + } + + } +} diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs index 55fd01dfb97..6e5661e1d44 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Name.cs @@ -22,13 +22,19 @@ namespace IO.Swagger.Model /// Initializes a new instance of the class. /// Initializes a new instance of the class. /// - /// _Name. - /// SnakeCase. + /// _Name (required). - public Name(int? _Name = null, int? SnakeCase = null) + public Name(int? _Name = null) { - this._Name = _Name; - this.SnakeCase = SnakeCase; + // to ensure "_Name" is required (not null) + if (_Name == null) + { + throw new InvalidDataException("_Name is a required property for Name and cannot be null"); + } + else + { + this._Name = _Name; + } } @@ -43,7 +49,7 @@ namespace IO.Swagger.Model /// Gets or Sets SnakeCase /// [DataMember(Name="snake_case", EmitDefaultValue=false)] - public int? SnakeCase { get; set; } + public int? SnakeCase { get; private set; } /// /// Returns the string presentation of the object diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj index 83c4f19ab17..67c8e73b6e5 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj @@ -66,6 +66,10 @@ + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index c507559e57d..d261de4844c 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -1,9 +1,11 @@  - + - + + + diff --git a/samples/client/petstore/go/swagger/Configuration.go b/samples/client/petstore/go/swagger/Configuration.go new file mode 100644 index 00000000000..7535db5e67f --- /dev/null +++ b/samples/client/petstore/go/swagger/Configuration.go @@ -0,0 +1,25 @@ +package swagger + +import ( + +) + +type Configuration struct { + UserName string `json:"userName,omitempty"` + ApiKey string `json:"apiKey,omitempty"` + Debug bool `json:"debug,omitempty"` + DebugFile string `json:"debugFile,omitempty"` + OAuthToken string `json:"oAuthToken,omitempty"` + Timeout int `json:"timeout,omitempty"` + BasePath string `json:"basePath,omitempty"` + Host string `json:"host,omitempty"` + Scheme string `json:"scheme,omitempty"` +} + +func NewConfiguration() *Configuration { + return &Configuration{ + BasePath: "http://petstore.swagger.io/v2", + UserName: "", + Debug: false, + } +} \ No newline at end of file diff --git a/samples/client/petstore/go/swagger/PetApi.go b/samples/client/petstore/go/swagger/PetApi.go index c0219568729..80853fbb2a0 100644 --- a/samples/client/petstore/go/swagger/PetApi.go +++ b/samples/client/petstore/go/swagger/PetApi.go @@ -1,29 +1,36 @@ package swagger + import ( "strings" "fmt" "encoding/json" "errors" "github.com/dghubble/sling" + ) type PetApi struct { - basePath string + Configuration Configuration } func NewPetApi() *PetApi{ + configuration := NewConfiguration() return &PetApi { - basePath: "http://petstore.swagger.io/v2", + Configuration: *configuration, } } func NewPetApiWithBasePath(basePath string) *PetApi{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &PetApi { - basePath: basePath, + Configuration: *configuration, } } + /** * Add a new pet to the store * @@ -33,13 +40,15 @@ func NewPetApiWithBasePath(basePath string) *PetApi{ //func (a PetApi) AddPet (body Pet) (error) { func (a PetApi) AddPet (body Pet) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/pets" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -47,6 +56,7 @@ func (a PetApi) AddPet (body Pet) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -84,6 +94,7 @@ func (a PetApi) AddPet (body Pet) (error) { return err } + /** * Deletes a pet * @@ -94,14 +105,16 @@ func (a PetApi) AddPet (body Pet) (error) { //func (a PetApi) DeletePet (apiKey string, petId int64) (error) { func (a PetApi) DeletePet (apiKey string, petId int64) (error) { - _sling := sling.New().Delete(a.basePath) + _sling := sling.New().Delete(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -114,6 +127,7 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -146,6 +160,7 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) { return err } + /** * Finds Pets by status * Multiple status values can be provided with comma seperated strings @@ -155,11 +170,12 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) { //func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/findByStatus" + _sling = _sling.Path(path) type QueryParams struct { @@ -167,6 +183,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { } _sling = _sling.QueryStruct(&QueryParams{ status: status }) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -175,6 +192,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { } + var successPayload = new([]Pet) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -209,6 +227,7 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { return *successPayload, err } + /** * Finds Pets by tags * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. @@ -218,11 +237,12 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) { //func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/findByTags" + _sling = _sling.Path(path) type QueryParams struct { @@ -230,6 +250,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { } _sling = _sling.QueryStruct(&QueryParams{ tags: tags }) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -238,6 +259,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { } + var successPayload = new([]Pet) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -272,6 +294,7 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { return *successPayload, err } + /** * Find pet by ID * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions @@ -281,14 +304,16 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) { //func (a PetApi) GetPetById (petId int64) (Pet, error) { func (a PetApi) GetPetById (petId int64) (Pet, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -297,6 +322,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { } + var successPayload = new(Pet) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -331,6 +357,7 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { return *successPayload, err } + /** * Update an existing pet * @@ -340,13 +367,15 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) { //func (a PetApi) UpdatePet (body Pet) (error) { func (a PetApi) UpdatePet (body Pet) (error) { - _sling := sling.New().Put(a.basePath) + _sling := sling.New().Put(a.Configuration.BasePath) // create path and map variables path := "/v2/pets" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -354,6 +383,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -391,6 +421,7 @@ func (a PetApi) UpdatePet (body Pet) (error) { return err } + /** * Updates a pet in the store with form data * @@ -402,14 +433,16 @@ func (a PetApi) UpdatePet (body Pet) (error) { //func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) { func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/pets/{petId}" path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -420,11 +453,13 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er type FormParams struct { name string `url:"name,omitempty"` status string `url:"status,omitempty"` + } _sling = _sling.BodyForm(&FormParams{ name: name,status: status }) + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -457,3 +492,5 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er return err } + + diff --git a/samples/client/petstore/go/swagger/StoreApi.go b/samples/client/petstore/go/swagger/StoreApi.go index cdc56b3baae..05a3b3ae89c 100644 --- a/samples/client/petstore/go/swagger/StoreApi.go +++ b/samples/client/petstore/go/swagger/StoreApi.go @@ -1,29 +1,36 @@ package swagger + import ( "strings" "fmt" "encoding/json" "errors" "github.com/dghubble/sling" + ) type StoreApi struct { - basePath string + Configuration Configuration } func NewStoreApi() *StoreApi{ + configuration := NewConfiguration() return &StoreApi { - basePath: "http://petstore.swagger.io/v2", + Configuration: *configuration, } } func NewStoreApiWithBasePath(basePath string) *StoreApi{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &StoreApi { - basePath: basePath, + Configuration: *configuration, } } + /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors @@ -33,14 +40,16 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{ //func (a StoreApi) DeleteOrder (orderId string) (error) { func (a StoreApi) DeleteOrder (orderId string) (error) { - _sling := sling.New().Delete(a.basePath) + _sling := sling.New().Delete(a.Configuration.BasePath) // create path and map variables path := "/v2/stores/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -51,6 +60,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -83,6 +93,7 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { return err } + /** * Find purchase order by ID * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions @@ -92,14 +103,16 @@ func (a StoreApi) DeleteOrder (orderId string) (error) { //func (a StoreApi) GetOrderById (orderId string) (Order, error) { func (a StoreApi) GetOrderById (orderId string) (Order, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/stores/order/{orderId}" path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -108,6 +121,7 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) { } + var successPayload = new(Order) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -142,6 +156,7 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) { return *successPayload, err } + /** * Place an order for a pet * @@ -151,13 +166,15 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) { //func (a StoreApi) PlaceOrder (body Order) (Order, error) { func (a StoreApi) PlaceOrder (body Order) (Order, error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/stores/order" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -165,6 +182,7 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -202,3 +220,5 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) { return *successPayload, err } + + diff --git a/samples/client/petstore/go/swagger/UserApi.go b/samples/client/petstore/go/swagger/UserApi.go index e90e72abaff..25bed9edbe0 100644 --- a/samples/client/petstore/go/swagger/UserApi.go +++ b/samples/client/petstore/go/swagger/UserApi.go @@ -1,29 +1,36 @@ package swagger + import ( "strings" "fmt" "encoding/json" "errors" "github.com/dghubble/sling" + ) type UserApi struct { - basePath string + Configuration Configuration } func NewUserApi() *UserApi{ + configuration := NewConfiguration() return &UserApi { - basePath: "http://petstore.swagger.io/v2", + Configuration: *configuration, } } func NewUserApiWithBasePath(basePath string) *UserApi{ + configuration := NewConfiguration() + configuration.BasePath = basePath + return &UserApi { - basePath: basePath, + Configuration: *configuration, } } + /** * Create user * This can only be done by the logged in user. @@ -33,13 +40,15 @@ func NewUserApiWithBasePath(basePath string) *UserApi{ //func (a UserApi) CreateUser (body User) (error) { func (a UserApi) CreateUser (body User) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/users" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -47,6 +56,7 @@ func (a UserApi) CreateUser (body User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -84,6 +94,7 @@ func (a UserApi) CreateUser (body User) (error) { return err } + /** * Creates list of users with given input array * @@ -93,13 +104,15 @@ func (a UserApi) CreateUser (body User) (error) { //func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/users/createWithArray" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -107,6 +120,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -144,6 +158,7 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { return err } + /** * Creates list of users with given input array * @@ -153,13 +168,15 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) { //func (a UserApi) CreateUsersWithListInput (body []User) (error) { func (a UserApi) CreateUsersWithListInput (body []User) (error) { - _sling := sling.New().Post(a.basePath) + _sling := sling.New().Post(a.Configuration.BasePath) // create path and map variables path := "/v2/users/createWithList" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -167,6 +184,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -204,6 +222,7 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { return err } + /** * Delete user * This can only be done by the logged in user. @@ -213,14 +232,16 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) { //func (a UserApi) DeleteUser (username string) (error) { func (a UserApi) DeleteUser (username string) (error) { - _sling := sling.New().Delete(a.basePath) + _sling := sling.New().Delete(a.Configuration.BasePath) // create path and map variables path := "/v2/users/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -231,6 +252,7 @@ func (a UserApi) DeleteUser (username string) (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -263,6 +285,7 @@ func (a UserApi) DeleteUser (username string) (error) { return err } + /** * Get user by user name * @@ -272,14 +295,16 @@ func (a UserApi) DeleteUser (username string) (error) { //func (a UserApi) GetUserByName (username string) (User, error) { func (a UserApi) GetUserByName (username string) (User, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/users/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -288,6 +313,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { } + var successPayload = new(User) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -322,6 +348,7 @@ func (a UserApi) GetUserByName (username string) (User, error) { return *successPayload, err } + /** * Logs user into the system * @@ -332,11 +359,12 @@ func (a UserApi) GetUserByName (username string) (User, error) { //func (a UserApi) LoginUser (username string, password string) (string, error) { func (a UserApi) LoginUser (username string, password string) (string, error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/users/login" + _sling = _sling.Path(path) type QueryParams struct { @@ -345,6 +373,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { } _sling = _sling.QueryStruct(&QueryParams{ username: username,password: password }) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -353,6 +382,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { } + var successPayload = new(string) // We use this map (below) so that any arbitrary error JSON can be handled. @@ -387,6 +417,7 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { return *successPayload, err } + /** * Logs out current logged in user session * @@ -395,13 +426,15 @@ func (a UserApi) LoginUser (username string, password string) (string, error) { //func (a UserApi) LogoutUser () (error) { func (a UserApi) LogoutUser () (error) { - _sling := sling.New().Get(a.basePath) + _sling := sling.New().Get(a.Configuration.BasePath) // create path and map variables path := "/v2/users/logout" + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -412,6 +445,7 @@ func (a UserApi) LogoutUser () (error) { + // We use this map (below) so that any arbitrary error JSON can be handled. // FIXME: This is in the absence of this Go generator honoring the non-2xx // response (error) models, which needs to be implemented at some point. @@ -444,6 +478,7 @@ func (a UserApi) LogoutUser () (error) { return err } + /** * Updated user * This can only be done by the logged in user. @@ -454,14 +489,16 @@ func (a UserApi) LogoutUser () (error) { //func (a UserApi) UpdateUser (username string, body User) (error) { func (a UserApi) UpdateUser (username string, body User) (error) { - _sling := sling.New().Put(a.basePath) + _sling := sling.New().Put(a.Configuration.BasePath) // create path and map variables path := "/v2/users/{username}" path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1) + _sling = _sling.Path(path) + // accept header accepts := []string { "application/json", "application/xml" } for key := range accepts { @@ -469,6 +506,7 @@ func (a UserApi) UpdateUser (username string, body User) (error) { break // only use the first Accept } + // body params _sling = _sling.BodyJSON(body) @@ -506,3 +544,5 @@ func (a UserApi) UpdateUser (username string, body User) (error) { return err } + + diff --git a/samples/client/petstore/java/retrofit2/build.gradle b/samples/client/petstore/java/retrofit2/build.gradle index ae27a595eb5..ab71653f739 100644 --- a/samples/client/petstore/java/retrofit2/build.gradle +++ b/samples/client/petstore/java/retrofit2/build.gradle @@ -46,6 +46,10 @@ if(hasProperty('target') && target == 'android') { } } } + + dependencies { + provided 'javax.annotation:jsr250-api:1.0' + } } afterEvaluate { diff --git a/samples/client/petstore/objc/README.md b/samples/client/petstore/objc/README.md index 10e44984683..47c20a7af6c 100644 --- a/samples/client/petstore/objc/README.md +++ b/samples/client/petstore/objc/README.md @@ -1,20 +1,200 @@ # SwaggerClient +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Package version: +- Build date: 2016-04-05T23:29:02.396+08:00 +- Build package: class io.swagger.codegen.languages.ObjcClientCodegen + ## Requirements -The API client library requires ARC (Automatic Reference Counting) to be enabled in your Xcode project. +The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.com/questions/7778356/how-to-enable-disable-automatic-reference-counting) to be enabled in the Xcode project. -## Installation +## Installation & Usage +### Install from Github using [CocoaPods](https://cocoapods.org/) -To install it, put the API client library in your project and then simply add the following line to your Podfile: +Add the following to the Podfile: ```ruby -pod "SwaggerClient", :path => "/path/to/lib" +pod 'SwaggerClient', :git => 'https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git' +``` + +To specify a particular branch, append `, :branch => 'branch-name-here'` + +To specify a particular commit, append `, :commit => '11aa22'` + +### Install from local path using [CocoaPods](https://cocoapods.org/) + +Put the SDK under your project folder (e.g. /path/to/objc_project/Vendor/SwaggerClient) and then add the following to the Podfile: + +```ruby +pod 'SwaggerClient', :path => 'Vendor/SwaggerClient' +``` + +### Usage + +Import the following: +```objc +#import +#import +// load models +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +#import +// load API classes for accessing endpoints +#import +#import +#import + ``` ## Recommendation -It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issue. +It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue. + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```objc + +SWGConfiguration *apiConfig = [SWGConfiguration sharedConfig]; + +// Configure OAuth2 access token for authorization: (authentication scheme: petstore_auth) +[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"]; + + +SWGPet* *body = [[SWGPet alloc] init]; // Pet object that needs to be added to the store (optional) + +@try +{ + SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; + + // Add a new pet to the store + [apiInstance addPetWithBody:body + completionHandler: ^(NSError* error)) { + if (error) { + NSLog(@"Error: %@", error); + } + }]; +} +@catch (NSException *exception) +{ + NSLog(@"Exception when calling SWGPetApi->addPet: %@ ", exception.name); + NSLog(@"Reason: %@ ", exception.reason); +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*SWGPetApi* | [**addPet**](docs/SWGPetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*SWGPetApi* | [**addPetUsingByteArray**](docs/SWGPetApi.md#addpetusingbytearray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*SWGPetApi* | [**deletePet**](docs/SWGPetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*SWGPetApi* | [**findPetsByStatus**](docs/SWGPetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*SWGPetApi* | [**findPetsByTags**](docs/SWGPetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*SWGPetApi* | [**getPetById**](docs/SWGPetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*SWGPetApi* | [**getPetByIdInObject**](docs/SWGPetApi.md#getpetbyidinobject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*SWGPetApi* | [**petPetIdtestingByteArraytrueGet**](docs/SWGPetApi.md#petpetidtestingbytearraytrueget) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*SWGPetApi* | [**updatePet**](docs/SWGPetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*SWGPetApi* | [**updatePetWithForm**](docs/SWGPetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*SWGPetApi* | [**uploadFile**](docs/SWGPetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*SWGStoreApi* | [**deleteOrder**](docs/SWGStoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*SWGStoreApi* | [**findOrdersByStatus**](docs/SWGStoreApi.md#findordersbystatus) | **GET** /store/findByStatus | Finds orders by status +*SWGStoreApi* | [**getInventory**](docs/SWGStoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*SWGStoreApi* | [**getInventoryInObject**](docs/SWGStoreApi.md#getinventoryinobject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*SWGStoreApi* | [**getOrderById**](docs/SWGStoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*SWGStoreApi* | [**placeOrder**](docs/SWGStoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*SWGUserApi* | [**createUser**](docs/SWGUserApi.md#createuser) | **POST** /user | Create user +*SWGUserApi* | [**createUsersWithArrayInput**](docs/SWGUserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*SWGUserApi* | [**createUsersWithListInput**](docs/SWGUserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*SWGUserApi* | [**deleteUser**](docs/SWGUserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*SWGUserApi* | [**getUserByName**](docs/SWGUserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*SWGUserApi* | [**loginUser**](docs/SWGUserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*SWGUserApi* | [**logoutUser**](docs/SWGUserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*SWGUserApi* | [**updateUser**](docs/SWGUserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [SWG200Response](docs/SWG200Response.md) + - [SWGAnimal](docs/SWGAnimal.md) + - [SWGCat](docs/SWGCat.md) + - [SWGCategory](docs/SWGCategory.md) + - [SWGDog](docs/SWGDog.md) + - [SWGInlineResponse200](docs/SWGInlineResponse200.md) + - [SWGName](docs/SWGName.md) + - [SWGOrder](docs/SWGOrder.md) + - [SWGPet](docs/SWGPet.md) + - [SWGReturn](docs/SWGReturn.md) + - [SWGSpecialModelName_](docs/SWGSpecialModelName_.md) + - [SWGTag](docs/SWGTag.md) + - [SWGUser](docs/SWGUser.md) + + +## Documentation For Authorization + + +## test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## test_http_basic + +- **Type**: HTTP basic authentication + +## test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +## test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +## test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + ## Author diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index a9e9590610e..a52df223080 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -13,7 +13,10 @@ */ #import "SWG200Response.h" +#import "SWGAnimal.h" +#import "SWGCat.h" #import "SWGCategory.h" +#import "SWGDog.h" #import "SWGInlineResponse200.h" #import "SWGName.h" #import "SWGOrder.h" @@ -81,7 +84,7 @@ extern NSString *const SWGResponseObjectErrorKey; +(bool) getOfflineState; /** - * Sets the client reachability, this may be override by the reachability manager if reachability changes + * Sets the client reachability, this may be overridden by the reachability manager if reachability changes * * @param The client reachability. */ diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index 042f282b885..0c8f21d3ae7 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -716,11 +716,11 @@ static void (^reachabilityChangeBlock)(int); for (NSString *auth in authSettings) { NSDictionary *authSetting = [[config authSettings] objectForKey:auth]; - if (authSetting) { - if ([authSetting[@"in"] isEqualToString:@"header"]) { + if (authSetting) { // auth setting is set only if the key is non-empty + if ([authSetting[@"in"] isEqualToString:@"header"] && [authSetting[@"key"] length] != 0) { [headersWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; } - else if ([authSetting[@"in"] isEqualToString:@"query"]) { + else if ([authSetting[@"in"] isEqualToString:@"query"] && [authSetting[@"key"] length] != 0) { [querysWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; } } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h index cd4e7117e89..27cfe5d6d24 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h @@ -46,6 +46,11 @@ */ @property (nonatomic) NSString *password; +/** + * Access token for OAuth + */ +@property (nonatomic) NSString *accessToken; + /** * Temp folder for file download */ @@ -132,6 +137,11 @@ */ - (NSString *) getBasicAuthToken; +/** + * Gets OAuth access token + */ +- (NSString *) getAccessToken; + /** * Gets Authentication Setings */ diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index af44693778e..0e5b36f4a81 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -29,6 +29,7 @@ self.host = @"http://petstore.swagger.io/v2"; self.username = @""; self.password = @""; + self.accessToken= @""; self.tempFolderPath = nil; self.debug = NO; self.verifySSL = YES; @@ -42,18 +43,23 @@ #pragma mark - Instance Methods - (NSString *) getApiKeyWithPrefix:(NSString *)key { - if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { + if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // both api key prefix and api key are set return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; } - else if ([self.apiKey objectForKey:key]) { + else if ([self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // only api key, no api key prefix return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; } - else { + else { // return empty string if nothing is set return @""; } } - (NSString *) getBasicAuthToken { + // return empty string if username and password are empty + if (self.username.length == 0 && self.password.length == 0){ + return @""; + } + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; @@ -61,6 +67,15 @@ return basicAuthCredentials; } +- (NSString *) getAccessToken { + if (self.accessToken.length == 0) { // token not set, return empty string + return @""; + } + else { + return [NSString stringWithFormat:@"BEARER %@", self.accessToken]; + } +} + #pragma mark - Setter Methods - (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier { @@ -149,6 +164,13 @@ @"key": @"test_api_key_query", @"value": [self getApiKeyWithPrefix:@"test_api_key_query"] }, + @"petstore_auth": + @{ + @"type": @"oauth", + @"in": @"header", + @"key": @"Authorization", + @"value": [self getAccessToken] + }, }; } diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 79dbf6ee5bf..37f92af6e6f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -5,7 +5,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-30T20:57:56.803+08:00 +- Build date: 2016-04-09T18:00:55.578+08:00 - Build package: class io.swagger.codegen.languages.PhpClientCodegen ## Requirements @@ -80,20 +80,20 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addpetusingbytearray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*PetApi* | [**addPetUsingByteArray**](docs/PetApi.md#addpetusingbytearray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store *PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet *PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status *PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags *PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getpetbyidinobject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petpetidtestingbytearraytrueget) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**getPetByIdInObject**](docs/PetApi.md#getpetbyidinobject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**petPetIdtestingByteArraytrueGet**](docs/PetApi.md#petpetidtestingbytearraytrueget) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' *PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet *PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data *PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image *StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID *StoreApi* | [**findOrdersByStatus**](docs/StoreApi.md#findordersbystatus) | **GET** /store/findByStatus | Finds orders by status *StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getinventoryinobject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**getInventoryInObject**](docs/StoreApi.md#getinventoryinobject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' *StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID *StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet *UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md index b21d4b595b1..9164cd27876 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md @@ -5,13 +5,13 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -[**addPetUsingByteArray**](PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**addPetUsingByteArray**](PetApi.md#addPetUsingByteArray) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store [**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet [**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status [**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags [**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -[**getPetByIdInObject**](PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -[**petPetIdtestingByteArraytrueGet**](PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**getPetByIdInObject**](PetApi.md#getPetByIdInObject) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**petPetIdtestingByteArraytrueGet**](PetApi.md#petPetIdtestingByteArraytrueGet) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' [**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet [**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data [**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md index a414755a82d..c60ac603299 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md @@ -7,7 +7,7 @@ Method | HTTP request | Description [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID [**findOrdersByStatus**](StoreApi.md#findOrdersByStatus) | **GET** /store/findByStatus | Finds orders by status [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -[**getInventoryInObject**](StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**getInventoryInObject**](StoreApi.md#getInventoryInObject) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md index 46f508fe293..e6a19891ba5 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/UserApi.md @@ -207,7 +207,7 @@ Get user by user name require_once(__DIR__ . '/vendor/autoload.php'); $api_instance = new Swagger\Client\Api\UserApi(); -$username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing. +$username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing. try { $result = $api_instance->getUserByName($username); @@ -222,7 +222,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **string**| The name that needs to be fetched. Use user1 for testing. | + **username** | **string**| The name that needs to be fetched. Use user1 for testing. | ### Return type diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 5c2c0564c70..4661a5b3bd8 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -90,7 +90,6 @@ class PetApi return $this; } - /** * addPet * @@ -102,7 +101,7 @@ class PetApi */ public function addPet($body = null) { - list($response, $statusCode, $httpHeader) = $this->addPetWithHttpInfo ($body); + list($response) = $this->addPetWithHttpInfo ($body); return $response; } @@ -126,11 +125,11 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml')); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); @@ -156,7 +155,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -164,9 +162,8 @@ class PetApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -174,7 +171,6 @@ class PetApi throw $e; } } - /** * addPetUsingByteArray * @@ -186,7 +182,7 @@ class PetApi */ public function addPetUsingByteArray($body = null) { - list($response, $statusCode, $httpHeader) = $this->addPetUsingByteArrayWithHttpInfo ($body); + list($response) = $this->addPetUsingByteArrayWithHttpInfo ($body); return $response; } @@ -205,16 +201,16 @@ class PetApi // parse inputs - $resourcePath = "/pet?testing_byte_array=true"; + $resourcePath = "/pet?testing_byte_array=true"; $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml')); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); @@ -240,7 +236,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -248,9 +243,8 @@ class PetApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -258,7 +252,6 @@ class PetApi throw $e; } } - /** * deletePet * @@ -271,7 +264,7 @@ class PetApi */ public function deletePet($pet_id, $api_key = null) { - list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key); + list($response) = $this->deletePetWithHttpInfo ($pet_id, $api_key); return $response; } @@ -300,20 +293,18 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // header params - if ($api_key !== null) { $headerParams['api_key'] = $this->apiClient->getSerializer()->toHeaderValue($api_key); } // path params - if ($pet_id !== null) { $resourcePath = str_replace( "{" . "petId" . "}", @@ -338,7 +329,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -346,9 +336,8 @@ class PetApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -356,7 +345,6 @@ class PetApi throw $e; } } - /** * findPetsByStatus * @@ -368,7 +356,7 @@ class PetApi */ public function findPetsByStatus($status = null) { - list($response, $statusCode, $httpHeader) = $this->findPetsByStatusWithHttpInfo ($status); + list($response) = $this->findPetsByStatusWithHttpInfo ($status); return $response; } @@ -392,18 +380,16 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // query params - if (is_array($status)) { $status = $this->apiClient->getSerializer()->serializeCollection($status, 'multi', true); } - if ($status !== null) { $queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status); } @@ -426,7 +412,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -434,17 +419,15 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet[]' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -452,7 +435,6 @@ class PetApi throw $e; } } - /** * findPetsByTags * @@ -464,7 +446,7 @@ class PetApi */ public function findPetsByTags($tags = null) { - list($response, $statusCode, $httpHeader) = $this->findPetsByTagsWithHttpInfo ($tags); + list($response) = $this->findPetsByTagsWithHttpInfo ($tags); return $response; } @@ -488,18 +470,16 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // query params - if (is_array($tags)) { $tags = $this->apiClient->getSerializer()->serializeCollection($tags, 'multi', true); } - if ($tags !== null) { $queryParams['tags'] = $this->apiClient->getSerializer()->toQueryValue($tags); } @@ -522,7 +502,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -530,17 +509,15 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet[]' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -548,7 +525,6 @@ class PetApi throw $e; } } - /** * getPetById * @@ -560,7 +536,7 @@ class PetApi */ public function getPetById($pet_id) { - list($response, $statusCode, $httpHeader) = $this->getPetByIdWithHttpInfo ($pet_id); + list($response) = $this->getPetByIdWithHttpInfo ($pet_id); return $response; } @@ -588,16 +564,15 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($pet_id !== null) { $resourcePath = str_replace( "{" . "petId" . "}", @@ -624,12 +599,11 @@ class PetApi $headerParams['api_key'] = $apiKey; } - + // this endpoint requires OAuth (access token) if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -637,17 +611,15 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -655,7 +627,6 @@ class PetApi throw $e; } } - /** * getPetByIdInObject * @@ -667,7 +638,7 @@ class PetApi */ public function getPetByIdInObject($pet_id) { - list($response, $statusCode, $httpHeader) = $this->getPetByIdInObjectWithHttpInfo ($pet_id); + list($response) = $this->getPetByIdInObjectWithHttpInfo ($pet_id); return $response; } @@ -690,21 +661,20 @@ class PetApi } // parse inputs - $resourcePath = "/pet/{petId}?response=inline_arbitrary_object"; + $resourcePath = "/pet/{petId}?response=inline_arbitrary_object"; $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($pet_id !== null) { $resourcePath = str_replace( "{" . "petId" . "}", @@ -731,12 +701,11 @@ class PetApi $headerParams['api_key'] = $apiKey; } - + // this endpoint requires OAuth (access token) if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -744,17 +713,15 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\InlineResponse200' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\InlineResponse200', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\InlineResponse200', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\InlineResponse200', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\InlineResponse200', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -762,7 +729,6 @@ class PetApi throw $e; } } - /** * petPetIdtestingByteArraytrueGet * @@ -774,7 +740,7 @@ class PetApi */ public function petPetIdtestingByteArraytrueGet($pet_id) { - list($response, $statusCode, $httpHeader) = $this->petPetIdtestingByteArraytrueGetWithHttpInfo ($pet_id); + list($response) = $this->petPetIdtestingByteArraytrueGetWithHttpInfo ($pet_id); return $response; } @@ -797,21 +763,20 @@ class PetApi } // parse inputs - $resourcePath = "/pet/{petId}?testing_byte_array=true"; + $resourcePath = "/pet/{petId}?testing_byte_array=true"; $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($pet_id !== null) { $resourcePath = str_replace( "{" . "petId" . "}", @@ -838,12 +803,11 @@ class PetApi $headerParams['api_key'] = $apiKey; } - + // this endpoint requires OAuth (access token) if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -851,17 +815,15 @@ class PetApi $queryParams, $httpBody, $headerParams, 'string' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -869,7 +831,6 @@ class PetApi throw $e; } } - /** * updatePet * @@ -881,7 +842,7 @@ class PetApi */ public function updatePet($body = null) { - list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body); + list($response) = $this->updatePetWithHttpInfo ($body); return $response; } @@ -905,11 +866,11 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml')); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml')); @@ -935,7 +896,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -943,9 +903,8 @@ class PetApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -953,7 +912,6 @@ class PetApi throw $e; } } - /** * updatePetWithForm * @@ -967,7 +925,7 @@ class PetApi */ public function updatePetWithForm($pet_id, $name = null, $status = null) { - list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); + list($response) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status); return $response; } @@ -997,16 +955,15 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded')); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded')); // path params - if ($pet_id !== null) { $resourcePath = str_replace( "{" . "petId" . "}", @@ -1019,16 +976,10 @@ class PetApi // form params if ($name !== null) { - - $formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name); - }// form params if ($status !== null) { - - $formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status); - } @@ -1043,7 +994,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -1051,9 +1001,8 @@ class PetApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -1061,7 +1010,6 @@ class PetApi throw $e; } } - /** * uploadFile * @@ -1075,7 +1023,7 @@ class PetApi */ public function uploadFile($pet_id, $additional_metadata = null, $file = null) { - list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); + list($response) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file); return $response; } @@ -1105,16 +1053,15 @@ class PetApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('multipart/form-data')); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data')); // path params - if ($pet_id !== null) { $resourcePath = str_replace( "{" . "petId" . "}", @@ -1127,13 +1074,9 @@ class PetApi // form params if ($additional_metadata !== null) { - - $formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata); - }// form params if ($file !== null) { - // PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax // See: https://wiki.php.net/rfc/curl-file-upload if (function_exists('curl_file_create')) { @@ -1141,8 +1084,6 @@ class PetApi } else { $formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file); } - - } @@ -1157,7 +1098,6 @@ class PetApi if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) { $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -1165,9 +1105,8 @@ class PetApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -1175,5 +1114,4 @@ class PetApi throw $e; } } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index b510b4a3b6e..387cd476c55 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -90,7 +90,6 @@ class StoreApi return $this; } - /** * deleteOrder * @@ -102,7 +101,7 @@ class StoreApi */ public function deleteOrder($order_id) { - list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id); + list($response) = $this->deleteOrderWithHttpInfo ($order_id); return $response; } @@ -130,16 +129,15 @@ class StoreApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($order_id !== null) { $resourcePath = str_replace( "{" . "orderId" . "}", @@ -159,17 +157,15 @@ class StoreApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'DELETE', $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -177,7 +173,6 @@ class StoreApi throw $e; } } - /** * findOrdersByStatus * @@ -189,7 +184,7 @@ class StoreApi */ public function findOrdersByStatus($status = null) { - list($response, $statusCode, $httpHeader) = $this->findOrdersByStatusWithHttpInfo ($status); + list($response) = $this->findOrdersByStatusWithHttpInfo ($status); return $response; } @@ -213,14 +208,13 @@ class StoreApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // query params - if ($status !== null) { $queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status); } @@ -245,14 +239,13 @@ class StoreApi $headerParams['x-test_api_client_id'] = $apiKey; } - + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_secret'); if (strlen($apiKey) !== 0) { $headerParams['x-test_api_client_secret'] = $apiKey; } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -260,17 +253,15 @@ class StoreApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order[]' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Order[]', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order[]', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order[]', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order[]', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -278,7 +269,6 @@ class StoreApi throw $e; } } - /** * getInventory * @@ -289,7 +279,7 @@ class StoreApi */ public function getInventory() { - list($response, $statusCode, $httpHeader) = $this->getInventoryWithHttpInfo (); + list($response) = $this->getInventoryWithHttpInfo (); return $response; } @@ -312,11 +302,11 @@ class StoreApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -340,7 +330,6 @@ class StoreApi $headerParams['api_key'] = $apiKey; } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -348,17 +337,15 @@ class StoreApi $queryParams, $httpBody, $headerParams, 'map[string,int]' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'map[string,int]', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'map[string,int]', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -366,7 +353,6 @@ class StoreApi throw $e; } } - /** * getInventoryInObject * @@ -377,7 +363,7 @@ class StoreApi */ public function getInventoryInObject() { - list($response, $statusCode, $httpHeader) = $this->getInventoryInObjectWithHttpInfo (); + list($response) = $this->getInventoryInObjectWithHttpInfo (); return $response; } @@ -395,16 +381,16 @@ class StoreApi // parse inputs - $resourcePath = "/store/inventory?response=arbitrary_object"; + $resourcePath = "/store/inventory?response=arbitrary_object"; $httpBody = ''; $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -428,7 +414,6 @@ class StoreApi $headerParams['api_key'] = $apiKey; } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -436,17 +421,15 @@ class StoreApi $queryParams, $httpBody, $headerParams, 'object' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'object', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, 'object', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'object', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'object', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -454,7 +437,6 @@ class StoreApi throw $e; } } - /** * getOrderById * @@ -466,7 +448,7 @@ class StoreApi */ public function getOrderById($order_id) { - list($response, $statusCode, $httpHeader) = $this->getOrderByIdWithHttpInfo ($order_id); + list($response) = $this->getOrderByIdWithHttpInfo ($order_id); return $response; } @@ -494,16 +476,15 @@ class StoreApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($order_id !== null) { $resourcePath = str_replace( "{" . "orderId" . "}", @@ -530,14 +511,13 @@ class StoreApi $headerParams['test_api_key_header'] = $apiKey; } - + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query'); if (strlen($apiKey) !== 0) { $queryParams['test_api_key_query'] = $apiKey; } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -545,17 +525,15 @@ class StoreApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -563,7 +541,6 @@ class StoreApi throw $e; } } - /** * placeOrder * @@ -575,7 +552,7 @@ class StoreApi */ public function placeOrder($body = null) { - list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body); + list($response) = $this->placeOrderWithHttpInfo ($body); return $response; } @@ -599,11 +576,11 @@ class StoreApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -631,14 +608,13 @@ class StoreApi $headerParams['x-test_api_client_id'] = $apiKey; } - + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('x-test_api_client_secret'); if (strlen($apiKey) !== 0) { $headerParams['x-test_api_client_secret'] = $apiKey; } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -646,17 +622,15 @@ class StoreApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -664,5 +638,4 @@ class StoreApi throw $e; } } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index 259581ee2f5..23f682e4943 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -90,7 +90,6 @@ class UserApi return $this; } - /** * createUser * @@ -102,7 +101,7 @@ class UserApi */ public function createUser($body = null) { - list($response, $statusCode, $httpHeader) = $this->createUserWithHttpInfo ($body); + list($response) = $this->createUserWithHttpInfo ($body); return $response; } @@ -126,11 +125,11 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -151,17 +150,15 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'POST', $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -169,7 +166,6 @@ class UserApi throw $e; } } - /** * createUsersWithArrayInput * @@ -181,7 +177,7 @@ class UserApi */ public function createUsersWithArrayInput($body = null) { - list($response, $statusCode, $httpHeader) = $this->createUsersWithArrayInputWithHttpInfo ($body); + list($response) = $this->createUsersWithArrayInputWithHttpInfo ($body); return $response; } @@ -205,11 +201,11 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -230,17 +226,15 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'POST', $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -248,7 +242,6 @@ class UserApi throw $e; } } - /** * createUsersWithListInput * @@ -260,7 +253,7 @@ class UserApi */ public function createUsersWithListInput($body = null) { - list($response, $statusCode, $httpHeader) = $this->createUsersWithListInputWithHttpInfo ($body); + list($response) = $this->createUsersWithListInputWithHttpInfo ($body); return $response; } @@ -284,11 +277,11 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -309,17 +302,15 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'POST', $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -327,7 +318,6 @@ class UserApi throw $e; } } - /** * deleteUser * @@ -339,7 +329,7 @@ class UserApi */ public function deleteUser($username) { - list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username); + list($response) = $this->deleteUserWithHttpInfo ($username); return $response; } @@ -367,16 +357,15 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($username !== null) { $resourcePath = str_replace( "{" . "username" . "}", @@ -401,7 +390,6 @@ class UserApi if (strlen($this->apiClient->getConfig()->getUsername()) !== 0 or strlen($this->apiClient->getConfig()->getPassword()) !== 0) { $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword()); } - // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( @@ -409,9 +397,8 @@ class UserApi $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -419,19 +406,18 @@ class UserApi throw $e; } } - /** * getUserByName * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * @return \Swagger\Client\Model\User * @throws \Swagger\Client\ApiException on non-2xx response */ public function getUserByName($username) { - list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username); + list($response) = $this->getUserByNameWithHttpInfo ($username); return $response; } @@ -441,7 +427,7 @@ class UserApi * * Get user by user name * - * @param string $username The name that needs to be fetched. Use user1 for testing. (required) + * @param string $username The name that needs to be fetched. Use user1 for testing. (required) * @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings) * @throws \Swagger\Client\ApiException on non-2xx response */ @@ -459,16 +445,15 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($username !== null) { $resourcePath = str_replace( "{" . "username" . "}", @@ -488,25 +473,22 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\User' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\User', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\User', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -514,7 +496,6 @@ class UserApi throw $e; } } - /** * loginUser * @@ -527,7 +508,7 @@ class UserApi */ public function loginUser($username = null, $password = null) { - list($response, $statusCode, $httpHeader) = $this->loginUserWithHttpInfo ($username, $password); + list($response) = $this->loginUserWithHttpInfo ($username, $password); return $response; } @@ -552,18 +533,16 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // query params - if ($username !== null) { $queryParams['username'] = $this->apiClient->getSerializer()->toQueryValue($username); }// query params - if ($password !== null) { $queryParams['password'] = $this->apiClient->getSerializer()->toQueryValue($password); } @@ -581,25 +560,22 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, $headerParams, 'string' ); - if (!$response) { return array(null, $statusCode, $httpHeader); } - return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); - - } catch (ApiException $e) { + return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: - $data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); + $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders()); $e->setResponseObject($data); break; } @@ -607,7 +583,6 @@ class UserApi throw $e; } } - /** * logoutUser * @@ -618,7 +593,7 @@ class UserApi */ public function logoutUser() { - list($response, $statusCode, $httpHeader) = $this->logoutUserWithHttpInfo (); + list($response) = $this->logoutUserWithHttpInfo (); return $response; } @@ -641,11 +616,11 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); @@ -662,17 +637,15 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'GET', $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -680,7 +653,6 @@ class UserApi throw $e; } } - /** * updateUser * @@ -693,7 +665,7 @@ class UserApi */ public function updateUser($username, $body = null) { - list($response, $statusCode, $httpHeader) = $this->updateUserWithHttpInfo ($username, $body); + list($response) = $this->updateUserWithHttpInfo ($username, $body); return $response; } @@ -722,16 +694,15 @@ class UserApi $queryParams = array(); $headerParams = array(); $formParams = array(); - $_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml')); + $_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml')); if (!is_null($_header_accept)) { $headerParams['Accept'] = $_header_accept; } - $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array()); + $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array()); // path params - if ($username !== null) { $resourcePath = str_replace( "{" . "username" . "}", @@ -755,17 +726,15 @@ class UserApi } elseif (count($formParams) > 0) { $httpBody = $formParams; // for HTTP post (form) } - - // make the API Call + // make the API Call try { list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( $resourcePath, 'PUT', $queryParams, $httpBody, $headerParams ); - + return array(null, $statusCode, $httpHeader); - } catch (ApiException $e) { switch ($e->getCode()) { } @@ -773,5 +742,4 @@ class UserApi throw $e; } } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index df38b989f88..65ee9d27f29 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -259,7 +259,7 @@ class ApiClient * * @return string Accept (e.g. application/json) */ - public static function selectHeaderAccept($accept) + public function selectHeaderAccept($accept) { if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) { return null; @@ -277,7 +277,7 @@ class ApiClient * * @return string Content-Type (e.g. application/json) */ - public static function selectHeaderContentType($content_type) + public function selectHeaderContentType($content_type) { if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) { return 'application/json'; @@ -299,9 +299,9 @@ class ApiClient { // ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986 $headers = array(); - $key = ''; // [+] + $key = ''; - foreach(explode("\n", $raw_headers) as $i => $h) + foreach(explode("\n", $raw_headers) as $h) { $h = explode(':', $h, 2); @@ -311,26 +311,22 @@ class ApiClient $headers[$h[0]] = trim($h[1]); elseif (is_array($headers[$h[0]])) { - // $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-] - // $headers[$h[0]] = $tmp; // [-] - $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+] + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); } else { - // $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-] - // $headers[$h[0]] = $tmp; // [-] - $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+] + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); } - $key = $h[0]; // [+] + $key = $h[0]; + } + else + { + if (substr($h[0], 0, 1) == "\t") + $headers[$key] .= "\r\n\t".trim($h[0]); + elseif (!$key) + $headers[0] = trim($h[0]);trim($h[0]); } - else // [+] - { // [+] - if (substr($h[0], 0, 1) == "\t") // [+] - $headers[$key] .= "\r\n\t".trim($h[0]); // [+] - elseif (!$key) // [+] - $headers[0] = trim($h[0]);trim($h[0]); // [+] - } // [+] } return $headers; diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php index eaaa566f3be..c267c81b18e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Animal.php @@ -94,13 +94,11 @@ class Animal implements ArrayAccess return self::$getters; } - /** * $class_name * @var string */ protected $class_name; - /** * Constructor @@ -113,7 +111,6 @@ class Animal implements ArrayAccess $this->class_name = $data["class_name"]; } } - /** * Gets class_name * @return string @@ -134,7 +131,6 @@ class Animal implements ArrayAccess $this->class_name = $class_name; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -182,10 +178,10 @@ class Animal implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php index 962f8ec00b6..79acd0d1f22 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Cat.php @@ -94,13 +94,11 @@ class Cat extends Animal implements ArrayAccess return parent::getters() + self::$getters; } - /** * $declawed * @var bool */ protected $declawed; - /** * Constructor @@ -113,7 +111,6 @@ class Cat extends Animal implements ArrayAccess $this->declawed = $data["declawed"]; } } - /** * Gets declawed * @return bool @@ -134,7 +131,6 @@ class Cat extends Animal implements ArrayAccess $this->declawed = $declawed; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -182,10 +178,10 @@ class Cat extends Animal implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php index 65d736ce9d9..0f359589d0e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Category.php @@ -98,19 +98,16 @@ class Category implements ArrayAccess return self::$getters; } - /** * $id * @var int */ protected $id; - /** * $name * @var string */ protected $name; - /** * Constructor @@ -124,7 +121,6 @@ class Category implements ArrayAccess $this->name = $data["name"]; } } - /** * Gets id * @return int @@ -145,7 +141,6 @@ class Category implements ArrayAccess $this->id = $id; return $this; } - /** * Gets name * @return string @@ -166,7 +161,6 @@ class Category implements ArrayAccess $this->name = $name; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -214,10 +208,10 @@ class Category implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php index 2aef5757fe3..d12bde293fd 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Dog.php @@ -94,13 +94,11 @@ class Dog extends Animal implements ArrayAccess return parent::getters() + self::$getters; } - /** * $breed * @var string */ protected $breed; - /** * Constructor @@ -113,7 +111,6 @@ class Dog extends Animal implements ArrayAccess $this->breed = $data["breed"]; } } - /** * Gets breed * @return string @@ -134,7 +131,6 @@ class Dog extends Animal implements ArrayAccess $this->breed = $breed; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -182,10 +178,10 @@ class Dog extends Animal implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php index 8efea4018b1..c3bb9d03315 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/InlineResponse200.php @@ -114,43 +114,36 @@ class InlineResponse200 implements ArrayAccess return self::$getters; } - /** * $tags * @var \Swagger\Client\Model\Tag[] */ protected $tags; - /** * $id * @var int */ protected $id; - /** * $category * @var object */ protected $category; - /** * $status pet status in the store * @var string */ protected $status; - /** * $name * @var string */ protected $name; - /** * $photo_urls * @var string[] */ protected $photo_urls; - /** * Constructor @@ -168,7 +161,6 @@ class InlineResponse200 implements ArrayAccess $this->photo_urls = $data["photo_urls"]; } } - /** * Gets tags * @return \Swagger\Client\Model\Tag[] @@ -189,7 +181,6 @@ class InlineResponse200 implements ArrayAccess $this->tags = $tags; return $this; } - /** * Gets id * @return int @@ -210,7 +201,6 @@ class InlineResponse200 implements ArrayAccess $this->id = $id; return $this; } - /** * Gets category * @return object @@ -231,7 +221,6 @@ class InlineResponse200 implements ArrayAccess $this->category = $category; return $this; } - /** * Gets status * @return string @@ -255,7 +244,6 @@ class InlineResponse200 implements ArrayAccess $this->status = $status; return $this; } - /** * Gets name * @return string @@ -276,7 +264,6 @@ class InlineResponse200 implements ArrayAccess $this->name = $name; return $this; } - /** * Gets photo_urls * @return string[] @@ -297,7 +284,6 @@ class InlineResponse200 implements ArrayAccess $this->photo_urls = $photo_urls; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -345,10 +331,10 @@ class InlineResponse200 implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php index 57cb31c084b..a2b4d7691ed 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Model200Response.php @@ -38,7 +38,7 @@ use \ArrayAccess; * Model200Response Class Doc Comment * * @category Class - * @description + * @description Model for testing model name starting with number * @package Swagger\Client * @author http://github.com/swagger-api/swagger-codegen * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 @@ -94,13 +94,11 @@ class Model200Response implements ArrayAccess return self::$getters; } - /** * $name * @var int */ protected $name; - /** * Constructor @@ -113,7 +111,6 @@ class Model200Response implements ArrayAccess $this->name = $data["name"]; } } - /** * Gets name * @return int @@ -134,7 +131,6 @@ class Model200Response implements ArrayAccess $this->name = $name; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -182,10 +178,10 @@ class Model200Response implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php index fd8d1479ca0..d92e61cdcd6 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/ModelReturn.php @@ -38,7 +38,7 @@ use \ArrayAccess; * ModelReturn Class Doc Comment * * @category Class - * @description + * @description Model for testing reserved words * @package Swagger\Client * @author http://github.com/swagger-api/swagger-codegen * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 @@ -94,13 +94,11 @@ class ModelReturn implements ArrayAccess return self::$getters; } - /** * $return * @var int */ protected $return; - /** * Constructor @@ -113,7 +111,6 @@ class ModelReturn implements ArrayAccess $this->return = $data["return"]; } } - /** * Gets return * @return int @@ -134,7 +131,6 @@ class ModelReturn implements ArrayAccess $this->return = $return; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -182,10 +178,10 @@ class ModelReturn implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php index 9b52f9a6c00..dbe1349ab88 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Name.php @@ -38,7 +38,7 @@ use \ArrayAccess; * Name Class Doc Comment * * @category Class - * @description + * @description Model for testing model name same as property name * @package Swagger\Client * @author http://github.com/swagger-api/swagger-codegen * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 @@ -98,19 +98,16 @@ class Name implements ArrayAccess return self::$getters; } - /** * $name * @var int */ protected $name; - /** * $snake_case * @var int */ protected $snake_case; - /** * Constructor @@ -124,7 +121,6 @@ class Name implements ArrayAccess $this->snake_case = $data["snake_case"]; } } - /** * Gets name * @return int @@ -145,7 +141,6 @@ class Name implements ArrayAccess $this->name = $name; return $this; } - /** * Gets snake_case * @return int @@ -166,7 +161,6 @@ class Name implements ArrayAccess $this->snake_case = $snake_case; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -214,10 +208,10 @@ class Name implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php index 1c114a8392c..ae29bd61271 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Order.php @@ -114,43 +114,36 @@ class Order implements ArrayAccess return self::$getters; } - /** * $id * @var int */ protected $id; - /** * $pet_id * @var int */ protected $pet_id; - /** * $quantity * @var int */ protected $quantity; - /** * $ship_date * @var \DateTime */ protected $ship_date; - /** * $status Order Status * @var string */ protected $status; - /** * $complete * @var bool */ protected $complete; - /** * Constructor @@ -168,7 +161,6 @@ class Order implements ArrayAccess $this->complete = $data["complete"]; } } - /** * Gets id * @return int @@ -189,7 +181,6 @@ class Order implements ArrayAccess $this->id = $id; return $this; } - /** * Gets pet_id * @return int @@ -210,7 +201,6 @@ class Order implements ArrayAccess $this->pet_id = $pet_id; return $this; } - /** * Gets quantity * @return int @@ -231,7 +221,6 @@ class Order implements ArrayAccess $this->quantity = $quantity; return $this; } - /** * Gets ship_date * @return \DateTime @@ -252,7 +241,6 @@ class Order implements ArrayAccess $this->ship_date = $ship_date; return $this; } - /** * Gets status * @return string @@ -276,7 +264,6 @@ class Order implements ArrayAccess $this->status = $status; return $this; } - /** * Gets complete * @return bool @@ -297,7 +284,6 @@ class Order implements ArrayAccess $this->complete = $complete; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -345,10 +331,10 @@ class Order implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php index 39735aaa428..7a790869349 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Pet.php @@ -114,43 +114,36 @@ class Pet implements ArrayAccess return self::$getters; } - /** * $id * @var int */ protected $id; - /** * $category * @var \Swagger\Client\Model\Category */ protected $category; - /** * $name * @var string */ protected $name; - /** * $photo_urls * @var string[] */ protected $photo_urls; - /** * $tags * @var \Swagger\Client\Model\Tag[] */ protected $tags; - /** * $status pet status in the store * @var string */ protected $status; - /** * Constructor @@ -168,7 +161,6 @@ class Pet implements ArrayAccess $this->status = $data["status"]; } } - /** * Gets id * @return int @@ -189,7 +181,6 @@ class Pet implements ArrayAccess $this->id = $id; return $this; } - /** * Gets category * @return \Swagger\Client\Model\Category @@ -210,7 +201,6 @@ class Pet implements ArrayAccess $this->category = $category; return $this; } - /** * Gets name * @return string @@ -231,7 +221,6 @@ class Pet implements ArrayAccess $this->name = $name; return $this; } - /** * Gets photo_urls * @return string[] @@ -252,7 +241,6 @@ class Pet implements ArrayAccess $this->photo_urls = $photo_urls; return $this; } - /** * Gets tags * @return \Swagger\Client\Model\Tag[] @@ -273,7 +261,6 @@ class Pet implements ArrayAccess $this->tags = $tags; return $this; } - /** * Gets status * @return string @@ -297,7 +284,6 @@ class Pet implements ArrayAccess $this->status = $status; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -345,10 +331,10 @@ class Pet implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php index 0ce073a43aa..25248d949cf 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/SpecialModelName.php @@ -94,13 +94,11 @@ class SpecialModelName implements ArrayAccess return self::$getters; } - /** * $special_property_name * @var int */ protected $special_property_name; - /** * Constructor @@ -113,7 +111,6 @@ class SpecialModelName implements ArrayAccess $this->special_property_name = $data["special_property_name"]; } } - /** * Gets special_property_name * @return int @@ -134,7 +131,6 @@ class SpecialModelName implements ArrayAccess $this->special_property_name = $special_property_name; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -182,10 +178,10 @@ class SpecialModelName implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php index 129206e9650..8396a774e80 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/Tag.php @@ -98,19 +98,16 @@ class Tag implements ArrayAccess return self::$getters; } - /** * $id * @var int */ protected $id; - /** * $name * @var string */ protected $name; - /** * Constructor @@ -124,7 +121,6 @@ class Tag implements ArrayAccess $this->name = $data["name"]; } } - /** * Gets id * @return int @@ -145,7 +141,6 @@ class Tag implements ArrayAccess $this->id = $id; return $this; } - /** * Gets name * @return string @@ -166,7 +161,6 @@ class Tag implements ArrayAccess $this->name = $name; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -214,10 +208,10 @@ class Tag implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php index 662983d61b9..6e5c7de36f3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Model/User.php @@ -122,55 +122,46 @@ class User implements ArrayAccess return self::$getters; } - /** * $id * @var int */ protected $id; - /** * $username * @var string */ protected $username; - /** * $first_name * @var string */ protected $first_name; - /** * $last_name * @var string */ protected $last_name; - /** * $email * @var string */ protected $email; - /** * $password * @var string */ protected $password; - /** * $phone * @var string */ protected $phone; - /** * $user_status User Status * @var int */ protected $user_status; - /** * Constructor @@ -190,7 +181,6 @@ class User implements ArrayAccess $this->user_status = $data["user_status"]; } } - /** * Gets id * @return int @@ -211,7 +201,6 @@ class User implements ArrayAccess $this->id = $id; return $this; } - /** * Gets username * @return string @@ -232,7 +221,6 @@ class User implements ArrayAccess $this->username = $username; return $this; } - /** * Gets first_name * @return string @@ -253,7 +241,6 @@ class User implements ArrayAccess $this->first_name = $first_name; return $this; } - /** * Gets last_name * @return string @@ -274,7 +261,6 @@ class User implements ArrayAccess $this->last_name = $last_name; return $this; } - /** * Gets email * @return string @@ -295,7 +281,6 @@ class User implements ArrayAccess $this->email = $email; return $this; } - /** * Gets password * @return string @@ -316,7 +301,6 @@ class User implements ArrayAccess $this->password = $password; return $this; } - /** * Gets phone * @return string @@ -337,7 +321,6 @@ class User implements ArrayAccess $this->phone = $phone; return $this; } - /** * Gets user_status * @return int @@ -358,7 +341,6 @@ class User implements ArrayAccess $this->user_status = $user_status; return $this; } - /** * Returns true if offset exists. False otherwise. * @param integer $offset Offset @@ -406,10 +388,10 @@ class User implements ArrayAccess */ public function __toString() { - if (defined('JSON_PRETTY_PRINT')) { + if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT); - } else { - return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } + + return json_encode(\Swagger\Client\ObjectSerializer::sanitizeForSerialization($this)); } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index e0a0efc03ca..3adaa899f5f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -55,14 +55,14 @@ class ObjectSerializer public static function sanitizeForSerialization($data) { if (is_scalar($data) || null === $data) { - $sanitized = $data; + return $data; } elseif ($data instanceof \DateTime) { - $sanitized = $data->format(\DateTime::ATOM); + return $data->format(\DateTime::ATOM); } elseif (is_array($data)) { foreach ($data as $property => $value) { $data[$property] = self::sanitizeForSerialization($value); } - $sanitized = $data; + return $data; } elseif (is_object($data)) { $values = array(); foreach (array_keys($data::swaggerTypes()) as $property) { @@ -71,12 +71,10 @@ class ObjectSerializer $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($data->$getter()); } } - $sanitized = (object)$values; + return (object)$values; } else { - $sanitized = (string)$data; + return (string)$data; } - - return $sanitized; } /** @@ -224,7 +222,7 @@ class ObjectSerializer public static function deserialize($data, $class, $httpHeaders=null, $discriminator=null) { if (null === $data) { - $deserialized = null; + return null; } elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int] $inner = substr($class, 4, -1); $deserialized = array(); @@ -235,16 +233,17 @@ class ObjectSerializer $deserialized[$key] = self::deserialize($value, $subClass, null, $discriminator); } } + return $deserialized; } elseif (strcasecmp(substr($class, -2), '[]') == 0) { $subClass = substr($class, 0, -2); $values = array(); foreach ($data as $key => $value) { $values[] = self::deserialize($value, $subClass, null, $discriminator); } - $deserialized = $values; + return $values; } elseif ($class === 'object') { settype($data, 'array'); - $deserialized = $data; + return $data; } elseif ($class === '\DateTime') { // Some API's return an invalid, empty string as a // date-time property. DateTime::__construct() will return @@ -253,13 +252,13 @@ class ObjectSerializer // be interpreted as a missing field/value. Let's handle // this graceful. if (!empty($data)) { - $deserialized = new \DateTime($data); + return new \DateTime($data); } else { - $deserialized = null; + return null; } } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); - $deserialized = $data; + return $data; } elseif ($class === '\SplFileObject') { // determine file name if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) { @@ -270,7 +269,8 @@ class ObjectSerializer $deserialized = new \SplFileObject($filename, "w"); $byte_written = $deserialized->fwrite($data); error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile()); - + return $deserialized; + } else { // If a discriminator is defined and points to a valid subclass, use it. if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { @@ -292,9 +292,7 @@ class ObjectSerializer $instance->$propertySetter(self::deserialize($propertyValue, $type, null, $discriminator)); } } - $deserialized = $instance; + return $instance; } - - return $deserialized; } } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/Model200ResponseTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/Model200ResponseTest.php index b9c7b167d54..40a5fe6d8b7 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/Model200ResponseTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/Model200ResponseTest.php @@ -37,7 +37,7 @@ namespace Swagger\Client\Model; * Model200ResponseTest Class Doc Comment * * @category Class - * @description + * @description Model for testing model name starting with number * @package Swagger\Client * @author http://github.com/swagger-api/swagger-codegen * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php index b42efd5ef57..1f3424acf71 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/ModelReturnTest.php @@ -37,7 +37,7 @@ namespace Swagger\Client\Model; * ModelReturnTest Class Doc Comment * * @category Class - * @description + * @description Model for testing reserved words * @package Swagger\Client * @author http://github.com/swagger-api/swagger-codegen * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/NameTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/NameTest.php index 17a22692df8..c33395f2085 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/NameTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/NameTest.php @@ -37,7 +37,7 @@ namespace Swagger\Client\Model; * NameTest Class Doc Comment * * @category Class - * @description + * @description Model for testing model name same as property name * @package Swagger\Client * @author http://github.com/swagger-api/swagger-codegen * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php index 6cc0a6e217f..f70ddf00107 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/PetApiTest.php @@ -64,7 +64,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase } - /** * Test case for addPet * @@ -74,7 +73,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_addPet() { } - /** * Test case for addPetUsingByteArray * @@ -84,7 +82,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_addPetUsingByteArray() { } - /** * Test case for deletePet * @@ -94,7 +91,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_deletePet() { } - /** * Test case for findPetsByStatus * @@ -104,7 +100,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_findPetsByStatus() { } - /** * Test case for findPetsByTags * @@ -114,7 +109,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_findPetsByTags() { } - /** * Test case for getPetById * @@ -124,7 +118,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_getPetById() { } - /** * Test case for getPetByIdInObject * @@ -134,7 +127,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_getPetByIdInObject() { } - /** * Test case for petPetIdtestingByteArraytrueGet * @@ -144,7 +136,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_petPetIdtestingByteArraytrueGet() { } - /** * Test case for updatePet * @@ -154,7 +145,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_updatePet() { } - /** * Test case for updatePetWithForm * @@ -164,7 +154,6 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_updatePetWithForm() { } - /** * Test case for uploadFile * @@ -174,5 +163,4 @@ class PetApiTest extends \PHPUnit_Framework_TestCase public function test_uploadFile() { } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php index 0d6fdfd9d8c..2eaf5f5dd11 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/StoreApiTest.php @@ -64,7 +64,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase } - /** * Test case for deleteOrder * @@ -74,7 +73,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function test_deleteOrder() { } - /** * Test case for findOrdersByStatus * @@ -84,7 +82,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function test_findOrdersByStatus() { } - /** * Test case for getInventory * @@ -94,7 +91,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function test_getInventory() { } - /** * Test case for getInventoryInObject * @@ -104,7 +100,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function test_getInventoryInObject() { } - /** * Test case for getOrderById * @@ -114,7 +109,6 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function test_getOrderById() { } - /** * Test case for placeOrder * @@ -124,5 +118,4 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase public function test_placeOrder() { } - } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php index 8eddc284528..5df577e6d9e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Tests/UserApiTest.php @@ -64,7 +64,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase } - /** * Test case for createUser * @@ -74,7 +73,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_createUser() { } - /** * Test case for createUsersWithArrayInput * @@ -84,7 +82,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_createUsersWithArrayInput() { } - /** * Test case for createUsersWithListInput * @@ -94,7 +91,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_createUsersWithListInput() { } - /** * Test case for deleteUser * @@ -104,7 +100,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_deleteUser() { } - /** * Test case for getUserByName * @@ -114,7 +109,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_getUserByName() { } - /** * Test case for loginUser * @@ -124,7 +118,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_loginUser() { } - /** * Test case for logoutUser * @@ -134,7 +127,6 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_logoutUser() { } - /** * Test case for updateUser * @@ -144,5 +136,4 @@ class UserApiTest extends \PHPUnit_Framework_TestCase public function test_updateUser() { } - } diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index 463bbb37a18..9e99ae27370 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -1,28 +1,49 @@ +# swagger_client +This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters + +This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API verion: 1.0.0 +- Package version: +- Build date: 2016-03-30T17:18:44.943+08:00 +- Build package: class io.swagger.codegen.languages.PythonClientCodegen + ## Requirements. -Python 2.7 and later. -## Setuptools -You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools). +Python 2.7 and 3.4+ + +## Installation & Usage +### pip install + +If the python package is hosted on Github, you can install directly from Github ```sh -python setup.py install +pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git +``` +(you may need to run the command with root permission: `sudo pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git`) + +Import the pacakge: +```python +import swagger_client ``` -Or you can install from Github via pip: +### Setuptools + +Install via [Setuptools](http://pypi.python.org/pypi/setuptools). ```sh -pip install git+https://github.com/geekerzp/swagger_client.git +python setup.py install --user ``` +(or `sudo python setup.py install` to install the package for all users) -To use the bindings, import the pacakge: - +Import the pacakge: ```python import swagger_client ``` -## Manual Installation -If you do not wish to use setuptools, you can download the latest release. -Then, to use the bindings, import the package: +### Manual Installation + +Download the latest release to the project folder (e.g. ./path/to/swagger_client) and import the package: ```python import path.to.swagger_client @@ -30,44 +51,126 @@ import path.to.swagger_client ## Getting Started -TODO +Please follow the [installation procedure](#installation--usage) and then run the following: -## Documentation +```python +import time +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint -TODO +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' +# create an instance of the API class +api_instance = swagger_client.PetApi +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) -## Tests - -(Please make sure you have [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) installed) - - Execute the following command to run the tests in the current Python (v2 or v3) environment: - -```sh -$ make test -[... magically installs dependencies and runs tests on your virtualenv] -Ran 7 tests in 19.289s - -OK -``` -or +try: + # Add a new pet to the store + api_instance.add_pet(body=body); +except ApiException as e: + print "Exception when calling PetApi->add_pet: %s\n" % e ``` -$ mvn integration-test -rf :PythonPetstoreClientTests -Using 2195432783 as seed -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 37.594 s -[INFO] Finished at: 2015-05-16T18:00:35+08:00 -[INFO] Final Memory: 11M/156M -[INFO] ------------------------------------------------------------------------ -``` -If you want to run the tests in all the python platforms: -```sh -$ make test-all -[... tox creates a virtualenv for every platform and runs tests inside of each] - py27: commands succeeded - py34: commands succeeded - congratulations :) -``` +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +*PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**find_orders_by_status**](docs/StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +*StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet +*UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user +*UserApi* | [**create_users_with_array_input**](docs/UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**create_users_with_list_input**](docs/UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**delete_user**](docs/UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +*UserApi* | [**get_user_by_name**](docs/UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +*UserApi* | [**login_user**](docs/UserApi.md#login_user) | **GET** /user/login | Logs user into the system +*UserApi* | [**logout_user**](docs/UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**update_user**](docs/UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [Animal](docs/Animal.md) + - [Cat](docs/Cat.md) + - [Category](docs/Category.md) + - [Dog](docs/Dog.md) + - [InlineResponse200](docs/InlineResponse200.md) + - [Model200Response](docs/Model200Response.md) + - [ModelReturn](docs/ModelReturn.md) + - [Name](docs/Name.md) + - [Order](docs/Order.md) + - [Pet](docs/Pet.md) + - [SpecialModelName](docs/SpecialModelName.md) + - [Tag](docs/Tag.md) + - [User](docs/User.md) + + +## Documentation For Authorization + + +## test_api_key_header + +- **Type**: API key +- **API key parameter name**: test_api_key_header +- **Location**: HTTP header + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## test_http_basic + +- **Type**: HTTP basic authentication + +## test_api_client_secret + +- **Type**: API key +- **API key parameter name**: x-test_api_client_secret +- **Location**: HTTP header + +## test_api_client_id + +- **Type**: API key +- **API key parameter name**: x-test_api_client_id +- **Location**: HTTP header + +## test_api_key_query + +- **Type**: API key +- **API key parameter name**: test_api_key_query +- **Location**: URL query string + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + +apiteam@swagger.io + diff --git a/samples/client/petstore/python/docs/Animal.md b/samples/client/petstore/python/docs/Animal.md new file mode 100644 index 00000000000..ceb8002b4ab --- /dev/null +++ b/samples/client/petstore/python/docs/Animal.md @@ -0,0 +1,10 @@ +# Animal + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Cat.md b/samples/client/petstore/python/docs/Cat.md new file mode 100644 index 00000000000..fd4cd174fc2 --- /dev/null +++ b/samples/client/petstore/python/docs/Cat.md @@ -0,0 +1,11 @@ +# Cat + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**declawed** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Category.md b/samples/client/petstore/python/docs/Category.md new file mode 100644 index 00000000000..7f453539bf8 --- /dev/null +++ b/samples/client/petstore/python/docs/Category.md @@ -0,0 +1,11 @@ +# Category + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Dog.md b/samples/client/petstore/python/docs/Dog.md new file mode 100644 index 00000000000..a4b38a70335 --- /dev/null +++ b/samples/client/petstore/python/docs/Dog.md @@ -0,0 +1,11 @@ +# Dog + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**class_name** | **str** | | +**breed** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/InlineResponse200.md b/samples/client/petstore/python/docs/InlineResponse200.md new file mode 100644 index 00000000000..ec171d3a5d2 --- /dev/null +++ b/samples/client/petstore/python/docs/InlineResponse200.md @@ -0,0 +1,15 @@ +# InlineResponse200 + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tags** | [**list[Tag]**](Tag.md) | | [optional] +**id** | **int** | | +**category** | **object** | | [optional] +**status** | **str** | pet status in the store | [optional] +**name** | **str** | | [optional] +**photo_urls** | **list[str]** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Model200Response.md b/samples/client/petstore/python/docs/Model200Response.md new file mode 100644 index 00000000000..e29747a87e7 --- /dev/null +++ b/samples/client/petstore/python/docs/Model200Response.md @@ -0,0 +1,10 @@ +# Model200Response + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/ModelReturn.md b/samples/client/petstore/python/docs/ModelReturn.md new file mode 100644 index 00000000000..2b03798e301 --- /dev/null +++ b/samples/client/petstore/python/docs/ModelReturn.md @@ -0,0 +1,10 @@ +# ModelReturn + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**_return** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Name.md b/samples/client/petstore/python/docs/Name.md new file mode 100644 index 00000000000..26473221c32 --- /dev/null +++ b/samples/client/petstore/python/docs/Name.md @@ -0,0 +1,11 @@ +# Name + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **int** | | [optional] +**snake_case** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Order.md b/samples/client/petstore/python/docs/Order.md new file mode 100644 index 00000000000..4499eaa976d --- /dev/null +++ b/samples/client/petstore/python/docs/Order.md @@ -0,0 +1,15 @@ +# Order + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**pet_id** | **int** | | [optional] +**quantity** | **int** | | [optional] +**ship_date** | **datetime** | | [optional] +**status** | **str** | Order Status | [optional] +**complete** | **bool** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/Pet.md b/samples/client/petstore/python/docs/Pet.md new file mode 100644 index 00000000000..9e15090300f --- /dev/null +++ b/samples/client/petstore/python/docs/Pet.md @@ -0,0 +1,15 @@ +# Pet + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**category** | [**Category**](Category.md) | | [optional] +**name** | **str** | | +**photo_urls** | **list[str]** | | +**tags** | [**list[Tag]**](Tag.md) | | [optional] +**status** | **str** | pet status in the store | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/PetApi.md b/samples/client/petstore/python/docs/PetApi.md new file mode 100644 index 00000000000..3349a3cb7d4 --- /dev/null +++ b/samples/client/petstore/python/docs/PetApi.md @@ -0,0 +1,596 @@ +# swagger_client\PetApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store +[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet +[**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status +[**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags +[**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID +[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet +[**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **add_pet** +> add_pet(body=body) + +Add a new pet to the store + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + +try: + # Add a new pet to the store + api_instance.add_pet(body=body); +except ApiException as e: + print "Exception when calling PetApi->add_pet: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **add_pet_using_byte_array** +> add_pet_using_byte_array(body=body) + +Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +body = 'B' # str | Pet object in the form of byte array (optional) + +try: + # Fake endpoint to test byte array in body parameter for adding a new pet to the store + api_instance.add_pet_using_byte_array(body=body); +except ApiException as e: + print "Exception when calling PetApi->add_pet_using_byte_array: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | **str**| Pet object in the form of byte array | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_pet** +> delete_pet(pet_id, api_key=api_key) + +Deletes a pet + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | Pet id to delete +api_key = 'api_key_example' # str | (optional) + +try: + # Deletes a pet + api_instance.delete_pet(pet_id, api_key=api_key); +except ApiException as e: + print "Exception when calling PetApi->delete_pet: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| Pet id to delete | + **api_key** | **str**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_status** +> list[Pet] find_pets_by_status(status=status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +status = ['available'] # list[str] | Status values that need to be considered for query (optional) (default to available) + +try: + # Finds Pets by status + api_response = api_instance.find_pets_by_status(status=status); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->find_pets_by_status: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**list[str]**](str.md)| Status values that need to be considered for query | [optional] [default to available] + +### Return type + +[**list[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_pets_by_tags** +> list[Pet] find_pets_by_tags(tags=tags) + +Finds Pets by tags + +Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +tags = ['tags_example'] # list[str] | Tags to filter by (optional) + +try: + # Finds Pets by tags + api_response = api_instance.find_pets_by_tags(tags=tags); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->find_pets_by_tags: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**list[str]**](str.md)| Tags to filter by | [optional] + +### Return type + +[**list[Pet]**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_pet_by_id** +> Pet get_pet_by_id(pet_id) + +Find pet by ID + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet that needs to be fetched + +try: + # Find pet by ID + api_response = api_instance.get_pet_by_id(pet_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->get_pet_by_id: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_pet_by_id_in_object** +> InlineResponse200 get_pet_by_id_in_object(pet_id) + +Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + +Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet that needs to be fetched + +try: + # Fake endpoint to test inline arbitrary object return by 'Find pet by ID' + api_response = api_instance.get_pet_by_id_in_object(pet_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->get_pet_by_id_in_object: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**InlineResponse200**](InlineResponse200.md) + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **pet_pet_idtesting_byte_arraytrue_get** +> str pet_pet_idtesting_byte_arraytrue_get(pet_id) + +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 + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet that needs to be fetched + +try: + # Fake endpoint to test byte array return by 'Find pet by ID' + api_response = api_instance.pet_pet_idtesting_byte_arraytrue_get(pet_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling PetApi->pet_pet_idtesting_byte_arraytrue_get: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet that needs to be fetched | + +### Return type + +**str** + +### Authorization + +[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet** +> update_pet(body=body) + +Update an existing pet + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +body = swagger_client.Pet() # Pet | Pet object that needs to be added to the store (optional) + +try: + # Update an existing pet + api_instance.update_pet(body=body); +except ApiException as e: + print "Exception when calling PetApi->update_pet: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_pet_with_form** +> update_pet_with_form(pet_id, name=name, status=status) + +Updates a pet in the store with form data + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 'pet_id_example' # str | ID of pet that needs to be updated +name = 'name_example' # str | Updated name of the pet (optional) +status = 'status_example' # str | Updated status of the pet (optional) + +try: + # Updates a pet in the store with form data + api_instance.update_pet_with_form(pet_id, name=name, status=status); +except ApiException as e: + print "Exception when calling PetApi->update_pet_with_form: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **str**| ID of pet that needs to be updated | + **name** | **str**| Updated name of the pet | [optional] + **status** | **str**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **upload_file** +> upload_file(pet_id, additional_metadata=additional_metadata, file=file) + +uploads an image + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure OAuth2 access token for authorization: petstore_auth +swagger_client.configuration.access_token = 'YOUR_ACCESS_TOKEN' + +# create an instance of the API class +api_instance = swagger_client.PetApi() +pet_id = 789 # int | ID of pet to update +additional_metadata = 'additional_metadata_example' # str | Additional data to pass to server (optional) +file = '/path/to/file.txt' # file | file to upload (optional) + +try: + # uploads an image + api_instance.upload_file(pet_id, additional_metadata=additional_metadata, file=file); +except ApiException as e: + print "Exception when calling PetApi->upload_file: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **pet_id** | **int**| ID of pet to update | + **additional_metadata** | **str**| Additional data to pass to server | [optional] + **file** | **file**| file to upload | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP reuqest headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python/docs/SpecialModelName.md b/samples/client/petstore/python/docs/SpecialModelName.md new file mode 100644 index 00000000000..022ee19169c --- /dev/null +++ b/samples/client/petstore/python/docs/SpecialModelName.md @@ -0,0 +1,10 @@ +# SpecialModelName + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**special_property_name** | **int** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/StoreApi.md b/samples/client/petstore/python/docs/StoreApi.md new file mode 100644 index 00000000000..bbffc6e384b --- /dev/null +++ b/samples/client/petstore/python/docs/StoreApi.md @@ -0,0 +1,330 @@ +# swagger_client\StoreApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status +[**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status +[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID +[**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet + + +# **delete_order** +> delete_order(order_id) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.StoreApi() +order_id = 'order_id_example' # str | ID of the order that needs to be deleted + +try: + # Delete purchase order by ID + api_instance.delete_order(order_id); +except ApiException as e: + print "Exception when calling StoreApi->delete_order: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **str**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **find_orders_by_status** +> list[Order] find_orders_by_status(status=status) + +Finds orders by status + +A single status value can be provided as a string + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: test_api_client_id +swagger_client.configuration.api_key['x-test_api_client_id'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_id'] = 'BEARER' +# Configure API key authorization: test_api_client_secret +swagger_client.configuration.api_key['x-test_api_client_secret'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_secret'] = 'BEARER' + +# create an instance of the API class +api_instance = swagger_client.StoreApi() +status = 'placed' # str | Status value that needs to be considered for query (optional) (default to placed) + +try: + # Finds orders by status + api_response = api_instance.find_orders_by_status(status=status); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->find_orders_by_status: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | **str**| Status value that needs to be considered for query | [optional] [default to placed] + +### Return type + +[**list[Order]**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_inventory** +> dict(str, int) get_inventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' + +# create an instance of the API class +api_instance = swagger_client.StoreApi() + +try: + # Returns pet inventories by status + api_response = api_instance.get_inventory(); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->get_inventory: %s\n" % e +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**dict(str, int)**](dict.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_inventory_in_object** +> object get_inventory_in_object() + +Fake endpoint to test arbitrary object return by 'Get inventory' + +Returns an arbitrary object which is actually a map of status codes to quantities + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: api_key +swagger_client.configuration.api_key['api_key'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['api_key'] = 'BEARER' + +# create an instance of the API class +api_instance = swagger_client.StoreApi() + +try: + # Fake endpoint to test arbitrary object return by 'Get inventory' + api_response = api_instance.get_inventory_in_object(); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->get_inventory_in_object: %s\n" % e +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**object** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_order_by_id** +> Order get_order_by_id(order_id) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: test_api_key_header +swagger_client.configuration.api_key['test_api_key_header'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['test_api_key_header'] = 'BEARER' +# Configure API key authorization: test_api_key_query +swagger_client.configuration.api_key['test_api_key_query'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['test_api_key_query'] = 'BEARER' + +# create an instance of the API class +api_instance = swagger_client.StoreApi() +order_id = 'order_id_example' # str | ID of pet that needs to be fetched + +try: + # Find purchase order by ID + api_response = api_instance.get_order_by_id(order_id); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->get_order_by_id: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **order_id** | **str**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **place_order** +> Order place_order(body=body) + +Place an order for a pet + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure API key authorization: test_api_client_id +swagger_client.configuration.api_key['x-test_api_client_id'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_id'] = 'BEARER' +# Configure API key authorization: test_api_client_secret +swagger_client.configuration.api_key['x-test_api_client_secret'] = 'YOUR_API_KEY'; +# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed +# swagger_client.configuration.api_key_prefix['x-test_api_client_secret'] = 'BEARER' + +# create an instance of the API class +api_instance = swagger_client.StoreApi() +body = swagger_client.Order() # Order | order placed for purchasing the pet (optional) + +try: + # Place an order for a pet + api_response = api_instance.place_order(body=body); + pprint(api_response) +except ApiException as e: + print "Exception when calling StoreApi->place_order: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | [optional] + +### Return type + +[**Order**](Order.md) + +### Authorization + +[test_api_client_id](../README.md#test_api_client_id), [test_api_client_secret](../README.md#test_api_client_secret) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python/docs/Tag.md b/samples/client/petstore/python/docs/Tag.md new file mode 100644 index 00000000000..243cd98eda6 --- /dev/null +++ b/samples/client/petstore/python/docs/Tag.md @@ -0,0 +1,11 @@ +# Tag + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**name** | **str** | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/User.md b/samples/client/petstore/python/docs/User.md new file mode 100644 index 00000000000..443ac123fdc --- /dev/null +++ b/samples/client/petstore/python/docs/User.md @@ -0,0 +1,17 @@ +# User + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] +**username** | **str** | | [optional] +**first_name** | **str** | | [optional] +**last_name** | **str** | | [optional] +**email** | **str** | | [optional] +**password** | **str** | | [optional] +**phone** | **str** | | [optional] +**user_status** | **int** | User Status | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/python/docs/UserApi.md b/samples/client/petstore/python/docs/UserApi.md new file mode 100644 index 00000000000..8145147a6ff --- /dev/null +++ b/samples/client/petstore/python/docs/UserApi.md @@ -0,0 +1,398 @@ +# swagger_client\UserApi + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**create_user**](UserApi.md#create_user) | **POST** /user | Create user +[**create_users_with_array_input**](UserApi.md#create_users_with_array_input) | **POST** /user/createWithArray | Creates list of users with given input array +[**create_users_with_list_input**](UserApi.md#create_users_with_list_input) | **POST** /user/createWithList | Creates list of users with given input array +[**delete_user**](UserApi.md#delete_user) | **DELETE** /user/{username} | Delete user +[**get_user_by_name**](UserApi.md#get_user_by_name) | **GET** /user/{username} | Get user by user name +[**login_user**](UserApi.md#login_user) | **GET** /user/login | Logs user into the system +[**logout_user**](UserApi.md#logout_user) | **GET** /user/logout | Logs out current logged in user session +[**update_user**](UserApi.md#update_user) | **PUT** /user/{username} | Updated user + + +# **create_user** +> create_user(body=body) + +Create user + +This can only be done by the logged in user. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() +body = swagger_client.User() # User | Created user object (optional) + +try: + # Create user + api_instance.create_user(body=body); +except ApiException as e: + print "Exception when calling UserApi->create_user: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_array_input** +> create_users_with_array_input(body=body) + +Creates list of users with given input array + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() +body = [swagger_client.User()] # list[User] | List of user object (optional) + +try: + # Creates list of users with given input array + api_instance.create_users_with_array_input(body=body); +except ApiException as e: + print "Exception when calling UserApi->create_users_with_array_input: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**list[User]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **create_users_with_list_input** +> create_users_with_list_input(body=body) + +Creates list of users with given input array + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() +body = [swagger_client.User()] # list[User] | List of user object (optional) + +try: + # Creates list of users with given input array + api_instance.create_users_with_list_input(body=body); +except ApiException as e: + print "Exception when calling UserApi->create_users_with_list_input: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**list[User]**](User.md)| List of user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **delete_user** +> delete_user(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# Configure HTTP basic authorization: test_http_basic +swagger_client.configuration.username = 'YOUR_USERNAME' +swagger_client.configuration.password = 'YOUR_PASSWORD' + +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | The name that needs to be deleted + +try: + # Delete user + api_instance.delete_user(username); +except ApiException as e: + print "Exception when calling UserApi->delete_user: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +[test_http_basic](../README.md#test_http_basic) + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **get_user_by_name** +> User get_user_by_name(username) + +Get user by user name + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | The name that needs to be fetched. Use user1 for testing. + +try: + # Get user by user name + api_response = api_instance.get_user_by_name(username); + pprint(api_response) +except ApiException as e: + print "Exception when calling UserApi->get_user_by_name: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **login_user** +> str login_user(username=username, password=password) + +Logs user into the system + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | The user name for login (optional) +password = 'password_example' # str | The password for login in clear text (optional) + +try: + # Logs user into the system + api_response = api_instance.login_user(username=username, password=password); + pprint(api_response) +except ApiException as e: + print "Exception when calling UserApi->login_user: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| The user name for login | [optional] + **password** | **str**| The password for login in clear text | [optional] + +### Return type + +**str** + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logout_user** +> logout_user() + +Logs out current logged in user session + + + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() + +try: + # Logs out current logged in user session + api_instance.logout_user(); +except ApiException as e: + print "Exception when calling UserApi->logout_user: %s\n" % e +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **update_user** +> update_user(username, body=body) + +Updated user + +This can only be done by the logged in user. + +### Example +```python +import swagger_client +from swagger_client.rest import ApiException +from pprint import pprint +import time + + +# create an instance of the API class +api_instance = swagger_client.UserApi() +username = 'username_example' # str | name that need to be deleted +body = swagger_client.User() # User | Updated user object (optional) + +try: + # Updated user + api_instance.update_user(username, body=body); +except ApiException as e: + print "Exception when calling UserApi->update_user: %s\n" % e +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **str**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | [optional] + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP reuqest headers + + - **Content-Type**: Not defined + - **Accept**: application/json, application/xml + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/python/swagger_client/__init__.py b/samples/client/petstore/python/swagger_client/__init__.py index 3b52f200834..dbdd791ada2 100644 --- a/samples/client/petstore/python/swagger_client/__init__.py +++ b/samples/client/petstore/python/swagger_client/__init__.py @@ -1,7 +1,10 @@ from __future__ import absolute_import # import models into sdk package +from .models.animal import Animal +from .models.cat import Cat from .models.category import Category +from .models.dog import Dog from .models.inline_response_200 import InlineResponse200 from .models.model_200_response import Model200Response from .models.model_return import ModelReturn diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index e598115e319..5d5a5fccc4c 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -371,7 +371,8 @@ class ApiClient(object): elif method == "DELETE": return self.rest_client.DELETE(url, query_params=query_params, - headers=headers) + headers=headers, + body=body) else: raise ValueError( "http method must be `GET`, `HEAD`," diff --git a/samples/client/petstore/python/swagger_client/models/__init__.py b/samples/client/petstore/python/swagger_client/models/__init__.py index baccc53b4d6..c441500bc40 100644 --- a/samples/client/petstore/python/swagger_client/models/__init__.py +++ b/samples/client/petstore/python/swagger_client/models/__init__.py @@ -1,7 +1,10 @@ from __future__ import absolute_import # import models into model package +from .animal import Animal +from .cat import Cat from .category import Category +from .dog import Dog from .inline_response_200 import InlineResponse200 from .model_200_response import Model200Response from .model_return import ModelReturn diff --git a/samples/client/petstore/python/swagger_client/models/animal.py b/samples/client/petstore/python/swagger_client/models/animal.py new file mode 100644 index 00000000000..762e3df5b37 --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/animal.py @@ -0,0 +1,120 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Animal(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Animal - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str' + } + + self.attribute_map = { + 'class_name': 'className' + } + + self._class_name = None + + @property + def class_name(self): + """ + Gets the class_name of this Animal. + + + :return: The class_name of this Animal. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Animal. + + + :param class_name: The class_name of this Animal. + :type: str + """ + self._class_name = class_name + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/cat.py b/samples/client/petstore/python/swagger_client/models/cat.py new file mode 100644 index 00000000000..4744fc4821c --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/cat.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Cat(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Cat - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str', + 'declawed': 'bool' + } + + self.attribute_map = { + 'class_name': 'className', + 'declawed': 'declawed' + } + + self._class_name = None + self._declawed = None + + @property + def class_name(self): + """ + Gets the class_name of this Cat. + + + :return: The class_name of this Cat. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Cat. + + + :param class_name: The class_name of this Cat. + :type: str + """ + self._class_name = class_name + + @property + def declawed(self): + """ + Gets the declawed of this Cat. + + + :return: The declawed of this Cat. + :rtype: bool + """ + return self._declawed + + @declawed.setter + def declawed(self, declawed): + """ + Sets the declawed of this Cat. + + + :param declawed: The declawed of this Cat. + :type: bool + """ + self._declawed = declawed + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/dog.py b/samples/client/petstore/python/swagger_client/models/dog.py new file mode 100644 index 00000000000..3885dd314ef --- /dev/null +++ b/samples/client/petstore/python/swagger_client/models/dog.py @@ -0,0 +1,145 @@ +# coding: utf-8 + +""" +Copyright 2016 SmartBear Software + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Ref: https://github.com/swagger-api/swagger-codegen +""" + +from pprint import pformat +from six import iteritems + + +class Dog(object): + """ + NOTE: This class is auto generated by the swagger code generator program. + Do not edit the class manually. + """ + def __init__(self): + """ + Dog - a model defined in Swagger + + :param dict swaggerTypes: The key is attribute name + and the value is attribute type. + :param dict attributeMap: The key is attribute name + and the value is json key in definition. + """ + self.swagger_types = { + 'class_name': 'str', + 'breed': 'str' + } + + self.attribute_map = { + 'class_name': 'className', + 'breed': 'breed' + } + + self._class_name = None + self._breed = None + + @property + def class_name(self): + """ + Gets the class_name of this Dog. + + + :return: The class_name of this Dog. + :rtype: str + """ + return self._class_name + + @class_name.setter + def class_name(self, class_name): + """ + Sets the class_name of this Dog. + + + :param class_name: The class_name of this Dog. + :type: str + """ + self._class_name = class_name + + @property + def breed(self): + """ + Gets the breed of this Dog. + + + :return: The breed of this Dog. + :rtype: str + """ + return self._breed + + @breed.setter + def breed(self, breed): + """ + Sets the breed of this Dog. + + + :param breed: The breed of this Dog. + :type: str + """ + self._breed = breed + + def to_dict(self): + """ + Returns the model properties as a dict + """ + result = {} + + for attr, _ in iteritems(self.swagger_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """ + Returns the string representation of the model + """ + return pformat(self.to_dict()) + + def __repr__(self): + """ + For `print` and `pprint` + """ + return self.to_str() + + def __eq__(self, other): + """ + Returns true if both objects are equal + """ + return self.__dict__ == other.__dict__ + + def __ne__(self, other): + """ + Returns true if both objects are not equal + """ + return not self == other + diff --git a/samples/client/petstore/python/swagger_client/models/name.py b/samples/client/petstore/python/swagger_client/models/name.py index 52187bd7bc5..068bca97eea 100644 --- a/samples/client/petstore/python/swagger_client/models/name.py +++ b/samples/client/petstore/python/swagger_client/models/name.py @@ -37,14 +37,17 @@ class Name(object): and the value is json key in definition. """ self.swagger_types = { - 'name': 'int' + 'name': 'int', + 'snake_case': 'int' } self.attribute_map = { - 'name': 'name' + 'name': 'name', + 'snake_case': 'snake_case' } self._name = None + self._snake_case = None @property def name(self): @@ -68,6 +71,28 @@ class Name(object): """ self._name = name + @property + def snake_case(self): + """ + Gets the snake_case of this Name. + + + :return: The snake_case of this Name. + :rtype: int + """ + return self._snake_case + + @snake_case.setter + def snake_case(self, snake_case): + """ + Sets the snake_case of this Name. + + + :param snake_case: The snake_case of this Name. + :type: int + """ + self._snake_case = snake_case + def to_dict(self): """ Returns the model properties as a dict diff --git a/samples/client/petstore/python/swagger_client/rest.py b/samples/client/petstore/python/swagger_client/rest.py index c5b9a4e6f91..352bb503ac5 100644 --- a/samples/client/petstore/python/swagger_client/rest.py +++ b/samples/client/petstore/python/swagger_client/rest.py @@ -133,8 +133,8 @@ class RESTClientObject(object): headers['Content-Type'] = 'application/json' try: - # For `POST`, `PUT`, `PATCH`, `OPTIONS` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']: + # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: url += '?' + urlencode(query_params) if headers['Content-Type'] == 'application/json': @@ -154,7 +154,7 @@ class RESTClientObject(object): fields=post_params, encode_multipart=True, headers=headers) - # For `GET`, `HEAD`, `DELETE` + # For `GET`, `HEAD` else: r = self.pool_manager.request(method, url, fields=query_params, @@ -195,10 +195,11 @@ class RESTClientObject(object): post_params=post_params, body=body) - def DELETE(self, url, headers=None, query_params=None): + def DELETE(self, url, headers=None, query_params=None, body=None): return self.request("DELETE", url, headers=headers, - query_params=query_params) + query_params=query_params, + body=body) def POST(self, url, headers=None, query_params=None, post_params=None, body=None): return self.request("POST", url, diff --git a/samples/client/petstore/python/tests/test_api_exception.py b/samples/client/petstore/python/tests/test_api_exception.py index a60594b3edd..790a18dffd0 100644 --- a/samples/client/petstore/python/tests/test_api_exception.py +++ b/samples/client/petstore/python/tests/test_api_exception.py @@ -8,6 +8,7 @@ $ nosetests -v """ import os +import sys import time import unittest @@ -44,7 +45,7 @@ class ApiExceptionTests(unittest.TestCase): self.pet_api.add_pet(body=self.pet) self.pet_api.delete_pet(pet_id=self.pet.id) - with self.assertRaisesRegexp(ApiException, "Pet not found"): + with self.checkRaiseRegex(ApiException, "Pet not found"): self.pet_api.get_pet_by_id(pet_id=self.pet.id) try: @@ -52,12 +53,12 @@ class ApiExceptionTests(unittest.TestCase): except ApiException as e: self.assertEqual(e.status, 404) self.assertEqual(e.reason, "Not Found") - self.assertRegexpMatches(e.body, "Pet not found") + self.checkRegex(e.body, "Pet not found") def test_500_error(self): self.pet_api.add_pet(body=self.pet) - with self.assertRaisesRegexp(ApiException, "Internal Server Error"): + with self.checkRaiseRegex(ApiException, "Internal Server Error"): self.pet_api.upload_file( pet_id=self.pet.id, additional_metadata="special", @@ -73,4 +74,17 @@ class ApiExceptionTests(unittest.TestCase): except ApiException as e: self.assertEqual(e.status, 500) self.assertEqual(e.reason, "Internal Server Error") - self.assertRegexpMatches(e.body, "Error 500 Internal Server Error") + self.checkRegex(e.body, "Error 500 Internal Server Error") + + def checkRaiseRegex(self, expected_exception, expected_regex): + if sys.version_info < (3, 0): + return self.assertRaisesRegexp(expected_exception, expected_regex) + + return self.assertRaisesRegex(expected_exception, expected_regex) + + def checkRegex(self, text, expected_regex): + if sys.version_info < (3, 0): + return self.assertRegexpMatches(text, expected_regex) + + return self.assertRegex(text, expected_regex) + diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 9f04158f439..9294e57a882 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/ - API version: 1.0.0 - Package version: 1.0.0 -- Build date: 2016-03-30T20:58:00.549+08:00 +- Build date: 2016-04-09T17:50:53.781+08:00 - Build package: class io.swagger.codegen.languages.RubyClientCodegen ## Installation @@ -82,20 +82,20 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- *Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store -*Petstore::PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +*Petstore::PetApi* | [**add_pet_using_byte_array**](docs/PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store *Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet *Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status *Petstore::PetApi* | [**find_pets_by_tags**](docs/PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags *Petstore::PetApi* | [**get_pet_by_id**](docs/PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID -*Petstore::PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +*Petstore::PetApi* | [**get_pet_by_id_in_object**](docs/PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +*Petstore::PetApi* | [**pet_pet_idtesting_byte_arraytrue_get**](docs/PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' *Petstore::PetApi* | [**update_pet**](docs/PetApi.md#update_pet) | **PUT** /pet | Update an existing pet *Petstore::PetApi* | [**update_pet_with_form**](docs/PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data *Petstore::PetApi* | [**upload_file**](docs/PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image *Petstore::StoreApi* | [**delete_order**](docs/StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID *Petstore::StoreApi* | [**find_orders_by_status**](docs/StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status *Petstore::StoreApi* | [**get_inventory**](docs/StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status -*Petstore::StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +*Petstore::StoreApi* | [**get_inventory_in_object**](docs/StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' *Petstore::StoreApi* | [**get_order_by_id**](docs/StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID *Petstore::StoreApi* | [**place_order**](docs/StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet *Petstore::UserApi* | [**create_user**](docs/UserApi.md#create_user) | **POST** /user | Create user diff --git a/samples/client/petstore/ruby/docs/PetApi.md b/samples/client/petstore/ruby/docs/PetApi.md index c29505ff419..f817316359b 100644 --- a/samples/client/petstore/ruby/docs/PetApi.md +++ b/samples/client/petstore/ruby/docs/PetApi.md @@ -5,13 +5,13 @@ All URIs are relative to *http://petstore.swagger.io/v2* Method | HTTP request | Description ------------- | ------------- | ------------- [**add_pet**](PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store -[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store +[**add_pet_using_byte_array**](PetApi.md#add_pet_using_byte_array) | **POST** /pet?testing_byte_array=true | Fake endpoint to test byte array in body parameter for adding a new pet to the store [**delete_pet**](PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet [**find_pets_by_status**](PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status [**find_pets_by_tags**](PetApi.md#find_pets_by_tags) | **GET** /pet/findByTags | Finds Pets by tags [**get_pet_by_id**](PetApi.md#get_pet_by_id) | **GET** /pet/{petId} | Find pet by ID -[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' -[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' +[**get_pet_by_id_in_object**](PetApi.md#get_pet_by_id_in_object) | **GET** /pet/{petId}?response=inline_arbitrary_object | Fake endpoint to test inline arbitrary object return by 'Find pet by ID' +[**pet_pet_idtesting_byte_arraytrue_get**](PetApi.md#pet_pet_idtesting_byte_arraytrue_get) | **GET** /pet/{petId}?testing_byte_array=true | Fake endpoint to test byte array return by 'Find pet by ID' [**update_pet**](PetApi.md#update_pet) | **PUT** /pet | Update an existing pet [**update_pet_with_form**](PetApi.md#update_pet_with_form) | **POST** /pet/{petId} | Updates a pet in the store with form data [**upload_file**](PetApi.md#upload_file) | **POST** /pet/{petId}/uploadImage | uploads an image diff --git a/samples/client/petstore/ruby/docs/StoreApi.md b/samples/client/petstore/ruby/docs/StoreApi.md index 57717e2a159..1ed9970698c 100644 --- a/samples/client/petstore/ruby/docs/StoreApi.md +++ b/samples/client/petstore/ruby/docs/StoreApi.md @@ -7,7 +7,7 @@ Method | HTTP request | Description [**delete_order**](StoreApi.md#delete_order) | **DELETE** /store/order/{orderId} | Delete purchase order by ID [**find_orders_by_status**](StoreApi.md#find_orders_by_status) | **GET** /store/findByStatus | Finds orders by status [**get_inventory**](StoreApi.md#get_inventory) | **GET** /store/inventory | Returns pet inventories by status -[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' +[**get_inventory_in_object**](StoreApi.md#get_inventory_in_object) | **GET** /store/inventory?response=arbitrary_object | Fake endpoint to test arbitrary object return by 'Get inventory' [**get_order_by_id**](StoreApi.md#get_order_by_id) | **GET** /store/order/{orderId} | Find purchase order by ID [**place_order**](StoreApi.md#place_order) | **POST** /store/order | Place an order for a pet diff --git a/samples/client/petstore/ruby/docs/UserApi.md b/samples/client/petstore/ruby/docs/UserApi.md index c8c3f5a9ccc..7b1e241f835 100644 --- a/samples/client/petstore/ruby/docs/UserApi.md +++ b/samples/client/petstore/ruby/docs/UserApi.md @@ -221,7 +221,7 @@ require 'petstore' api_instance = Petstore::UserApi.new -username = "username_example" # String | The name that needs to be fetched. Use user1 for testing. +username = "username_example" # String | The name that needs to be fetched. Use user1 for testing. begin @@ -237,7 +237,7 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | ### Return type diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index a2828c18873..3bff1eda69a 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -54,19 +54,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = ['application/json', 'application/xml'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = ['application/json', 'application/xml'] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, @@ -101,7 +100,7 @@ module Petstore end # resource path - local_var_path = "/pet?testing_byte_array=true".sub('{format}','json') + local_var_path = "/pet?testing_byte_array=true".sub('{format}','json') # query parameters query_params = {} @@ -110,19 +109,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = ['application/json', 'application/xml'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = ['application/json', 'application/xml'] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, @@ -171,12 +169,12 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key'] # form parameters @@ -184,8 +182,7 @@ module Petstore # http body (model) post_body = nil - - auth_names = ['petstore_auth'] + auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, @@ -204,7 +201,7 @@ module Petstore # @option opts [Array] :status Status values that need to be considered for query (default to available) # @return [Array] def find_pets_by_status(opts = {}) - data, status_code, headers = find_pets_by_status_with_http_info(opts) + data, _status_code, _headers = find_pets_by_status_with_http_info(opts) return data end @@ -229,20 +226,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['petstore_auth'] + auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -262,7 +258,7 @@ module Petstore # @option opts [Array] :tags Tags to filter by # @return [Array] def find_pets_by_tags(opts = {}) - data, status_code, headers = find_pets_by_tags_with_http_info(opts) + data, _status_code, _headers = find_pets_by_tags_with_http_info(opts) return data end @@ -287,20 +283,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['petstore_auth'] + auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -320,7 +315,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Pet] def get_pet_by_id(pet_id, opts = {}) - data, status_code, headers = get_pet_by_id_with_http_info(pet_id, opts) + data, _status_code, _headers = get_pet_by_id_with_http_info(pet_id, opts) return data end @@ -347,20 +342,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['api_key', 'petstore_auth'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -380,7 +374,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [InlineResponse200] def get_pet_by_id_in_object(pet_id, opts = {}) - data, status_code, headers = get_pet_by_id_in_object_with_http_info(pet_id, opts) + data, _status_code, _headers = get_pet_by_id_in_object_with_http_info(pet_id, opts) return data end @@ -398,7 +392,7 @@ module Petstore fail "Missing the required parameter 'pet_id' when calling get_pet_by_id_in_object" if pet_id.nil? # resource path - local_var_path = "/pet/{petId}?response=inline_arbitrary_object".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + local_var_path = "/pet/{petId}?response=inline_arbitrary_object".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) # query parameters query_params = {} @@ -407,20 +401,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['api_key', 'petstore_auth'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -440,7 +433,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [String] def pet_pet_idtesting_byte_arraytrue_get(pet_id, opts = {}) - data, status_code, headers = pet_pet_idtesting_byte_arraytrue_get_with_http_info(pet_id, opts) + data, _status_code, _headers = pet_pet_idtesting_byte_arraytrue_get_with_http_info(pet_id, opts) return data end @@ -458,7 +451,7 @@ module Petstore fail "Missing the required parameter 'pet_id' when calling pet_pet_idtesting_byte_arraytrue_get" if pet_id.nil? # resource path - local_var_path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) + local_var_path = "/pet/{petId}?testing_byte_array=true".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s) # query parameters query_params = {} @@ -467,20 +460,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['api_key', 'petstore_auth'] + auth_names = ['api_key', 'petstore_auth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -524,19 +516,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = ['application/json', 'application/xml'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = ['application/json', 'application/xml'] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, @@ -587,12 +578,12 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = ['application/x-www-form-urlencoded'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = ['application/x-www-form-urlencoded'] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} @@ -601,8 +592,7 @@ module Petstore # http body (model) post_body = nil - - auth_names = ['petstore_auth'] + auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, @@ -652,12 +642,12 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = ['multipart/form-data'] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = ['multipart/form-data'] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} @@ -666,8 +656,7 @@ module Petstore # http body (model) post_body = nil - - auth_names = ['petstore_auth'] + auth_names = ['petstore_auth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 5c154f6ccd6..548b5a355e0 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -57,20 +57,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = [] + auth_names = [] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, @@ -89,7 +88,7 @@ module Petstore # @option opts [String] :status Status value that needs to be considered for query (default to placed) # @return [Array] def find_orders_by_status(opts = {}) - data, status_code, headers = find_orders_by_status_with_http_info(opts) + data, _status_code, _headers = find_orders_by_status_with_http_info(opts) return data end @@ -118,20 +117,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['test_api_client_id', 'test_api_client_secret'] + auth_names = ['test_api_client_id', 'test_api_client_secret'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -150,7 +148,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Hash] def get_inventory(opts = {}) - data, status_code, headers = get_inventory_with_http_info(opts) + data, _status_code, _headers = get_inventory_with_http_info(opts) return data end @@ -173,20 +171,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['api_key'] + auth_names = ['api_key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -205,7 +202,7 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Object] def get_inventory_in_object(opts = {}) - data, status_code, headers = get_inventory_in_object_with_http_info(opts) + data, _status_code, _headers = get_inventory_in_object_with_http_info(opts) return data end @@ -219,7 +216,7 @@ module Petstore end # resource path - local_var_path = "/store/inventory?response=arbitrary_object".sub('{format}','json') + local_var_path = "/store/inventory?response=arbitrary_object".sub('{format}','json') # query parameters query_params = {} @@ -228,20 +225,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['api_key'] + auth_names = ['api_key'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -261,12 +257,12 @@ module Petstore # @param [Hash] opts the optional parameters # @return [Order] def get_order_by_id(order_id, opts = {}) - data, status_code, headers = get_order_by_id_with_http_info(order_id, opts) + data, _status_code, _headers = get_order_by_id_with_http_info(order_id, opts) return data end # Find purchase order by ID - # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # @param order_id ID of pet that needs to be fetched # @param [Hash] opts the optional parameters # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers @@ -288,20 +284,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['test_api_key_header', 'test_api_key_query'] + auth_names = ['test_api_key_header', 'test_api_key_query'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -321,7 +316,7 @@ module Petstore # @option opts [Order] :body order placed for purchasing the pet # @return [Order] def place_order(opts = {}) - data, status_code, headers = place_order_with_http_info(opts) + data, _status_code, _headers = place_order_with_http_info(opts) return data end @@ -345,19 +340,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['test_api_client_id', 'test_api_client_secret'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 54d943bdc44..0f9af5bb7f0 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -54,19 +54,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, @@ -110,19 +109,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, @@ -166,19 +164,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, @@ -225,20 +222,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = ['test_http_basic'] + auth_names = ['test_http_basic'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, @@ -253,17 +249,17 @@ module Petstore # Get user by user name # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) - data, status_code, headers = get_user_by_name_with_http_info(username, opts) + data, _status_code, _headers = get_user_by_name_with_http_info(username, opts) return data end # Get user by user name # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers def get_user_by_name_with_http_info(username, opts = {}) @@ -284,20 +280,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = [] + auth_names = [] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -318,7 +313,7 @@ module Petstore # @option opts [String] :password The password for login in clear text # @return [String] def login_user(opts = {}) - data, status_code, headers = login_user_with_http_info(opts) + data, _status_code, _headers = login_user_with_http_info(opts) return data end @@ -345,20 +340,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = [] + auth_names = [] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -400,20 +394,19 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = nil - - auth_names = [] + auth_names = [] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, @@ -461,19 +454,18 @@ module Petstore header_params = {} # HTTP header 'Accept' (if needed) - _header_accept = ['application/json', 'application/xml'] - _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result + local_header_accept = ['application/json', 'application/xml'] + local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result # HTTP header 'Content-Type' - _header_content_type = [] - header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type) + local_header_content_type = [] + header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 7ec9de18a3e..70111d07438 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -31,6 +31,8 @@ module Petstore # @return [Hash] attr_accessor :default_headers + # Initializes the ApiClient + # @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default def initialize(config = Configuration.default) @config = config @user_agent = "Swagger-Codegen/#{VERSION}/ruby" @@ -71,6 +73,15 @@ module Petstore return data, response.code, response.headers end + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Typhoeus::Request] A Typhoeus Request def build_request(http_method, path, opts = {}) url = build_request_url(path) http_method = http_method.to_sym.downcase @@ -79,9 +90,7 @@ module Petstore query_params = opts[:query_params] || {} form_params = opts[:form_params] || {} - update_params_for_auth! header_params, query_params, opts[:auth_names] - req_opts = { :method => http_method, @@ -112,12 +121,15 @@ module Petstore # application/json # application/json; charset=UTF8 # APPLICATION/JSON + # @param [String] mime MIME + # @return [Boolean] True if the MIME is applicaton/json def json_mime?(mime) - !!(mime =~ /\Aapplication\/json(;.*)?\z/i) + !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil? end # Deserialize the response to the given return type. # + # @param [Response] response HTTP response # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]" def deserialize(response, return_type) body = response.body @@ -148,6 +160,9 @@ module Petstore end # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type def convert_to_type(data, return_type) return nil if data.nil? case return_type @@ -220,7 +235,7 @@ module Petstore # @param [String] filename the filename to be sanitized # @return [String] the sanitized filename def sanitize_filename(filename) - filename.gsub /.*[\/\\]/, '' + filename.gsub(/.*[\/\\]/, '') end def build_request_url(path) @@ -229,6 +244,12 @@ module Petstore URI.encode(@config.base_url + path) end + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string def build_request_body(header_params, form_params, body) # http form if header_params['Content-Type'] == 'application/x-www-form-urlencoded' || @@ -252,6 +273,10 @@ module Petstore end # Update hearder and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [String] auth_names Authentication scheme name def update_params_for_auth!(header_params, query_params, auth_names) Array(auth_names).each do |auth_name| auth_setting = @config.auth_settings[auth_name] @@ -264,6 +289,9 @@ module Petstore end end + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0) def user_agent=(user_agent) @user_agent = user_agent @default_headers['User-Agent'] = @user_agent @@ -295,13 +323,13 @@ module Petstore # @return [String] JSON string representation of the object def object_to_http_body(model) return model if model.nil? || model.is_a?(String) - _body = nil + local_body = nil if model.is_a?(Array) - _body = model.map{|m| object_to_hash(m) } + local_body = model.map{|m| object_to_hash(m) } else - _body = object_to_hash(model) + local_body = object_to_hash(model) end - _body.to_json + local_body.to_json end # Convert object(non-array) to hash. diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index cf5fa7c1c94..325898c5676 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -23,9 +23,7 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'class_name' => :'className' - } end @@ -33,24 +31,24 @@ module Petstore def self.swagger_types { :'class_name' => :'String' - } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] self.class_name = attributes[:'className'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -58,35 +56,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [class_name].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -120,21 +124,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -145,8 +153,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index db40e8eab2c..1de8e299b37 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -25,11 +25,8 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'class_name' => :'className', - :'declawed' => :'declawed' - } end @@ -37,29 +34,28 @@ module Petstore def self.swagger_types { :'class_name' => :'String', - :'declawed' => :'BOOLEAN' - +:'declawed' => :'BOOLEAN' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] self.class_name = attributes[:'className'] end - if attributes[:'declawed'] self.declawed = attributes[:'declawed'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -68,35 +64,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [class_name, declawed].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -130,21 +132,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -155,8 +161,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/category.rb b/samples/client/petstore/ruby/lib/petstore/models/category.rb index 3defc6193d1..cb7091dc788 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/category.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/category.rb @@ -25,11 +25,8 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'name' => :'name' - } end @@ -37,29 +34,28 @@ module Petstore def self.swagger_types { :'id' => :'Integer', - :'name' => :'String' - +:'name' => :'String' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] self.id = attributes[:'id'] end - if attributes[:'name'] self.name = attributes[:'name'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -68,35 +64,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [id, name].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -130,21 +132,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -155,8 +161,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index a7f19f2b913..b0efe164eb7 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -25,11 +25,8 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'class_name' => :'className', - :'breed' => :'breed' - } end @@ -37,29 +34,28 @@ module Petstore def self.swagger_types { :'class_name' => :'String', - :'breed' => :'String' - +:'breed' => :'String' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'className'] self.class_name = attributes[:'className'] end - if attributes[:'breed'] self.breed = attributes[:'breed'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -68,35 +64,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [class_name, breed].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -130,21 +132,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -155,8 +161,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb index 190170f18eb..3b75ff5e41e 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/inline_response_200.rb @@ -34,19 +34,12 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'tags' => :'tags', - :'id' => :'id', - :'category' => :'category', - :'status' => :'status', - :'name' => :'name', - :'photo_urls' => :'photoUrls' - } end @@ -54,53 +47,48 @@ module Petstore def self.swagger_types { :'tags' => :'Array', - :'id' => :'Integer', - :'category' => :'Object', - :'status' => :'String', - :'name' => :'String', - :'photo_urls' => :'Array' - +:'id' => :'Integer', +:'category' => :'Object', +:'status' => :'String', +:'name' => :'String', +:'photo_urls' => :'Array' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'tags'] if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes[:'id'] self.id = attributes[:'id'] end - if attributes[:'category'] self.category = attributes[:'category'] end - if attributes[:'status'] self.status = attributes[:'status'] end - if attributes[:'name'] self.name = attributes[:'name'] end - if attributes[:'photoUrls'] if (value = attributes[:'photoUrls']).is_a?(Array) self.photo_urls = value end end - end # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned def status=(status) allowed_values = ["available", "pending", "sold"] if status && !allowed_values.include?(status) @@ -109,7 +97,8 @@ module Petstore @status = status end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -122,35 +111,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [tags, id, category, status, name, photo_urls].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -184,21 +179,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -209,8 +208,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb index e98cac47609..4e198a489b3 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_200_response.rb @@ -17,15 +17,14 @@ Terms of Service: http://swagger.io/terms/ require 'date' module Petstore + # Model for testing model name starting with number class Model200Response attr_accessor :name # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'name' => :'name' - } end @@ -33,24 +32,24 @@ module Petstore def self.swagger_types { :'name' => :'Integer' - } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] self.name = attributes[:'name'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -58,35 +57,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [name].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -120,21 +125,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -145,8 +154,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb index 4f8cb498690..f016ff32fe9 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/model_return.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/model_return.rb @@ -17,15 +17,14 @@ Terms of Service: http://swagger.io/terms/ require 'date' module Petstore + # Model for testing reserved words class ModelReturn attr_accessor :_return # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'_return' => :'return' - } end @@ -33,24 +32,24 @@ module Petstore def self.swagger_types { :'_return' => :'Integer' - } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'return'] self._return = attributes[:'return'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -58,35 +57,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [_return].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -120,21 +125,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -145,8 +154,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 478bd018788..35ed30e193c 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -17,6 +17,7 @@ Terms of Service: http://swagger.io/terms/ require 'date' module Petstore + # Model for testing model name same as property name class Name attr_accessor :name @@ -25,11 +26,8 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'name' => :'name', - :'snake_case' => :'snake_case' - } end @@ -37,29 +35,28 @@ module Petstore def self.swagger_types { :'name' => :'Integer', - :'snake_case' => :'Integer' - +:'snake_case' => :'Integer' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'name'] self.name = attributes[:'name'] end - if attributes[:'snake_case'] self.snake_case = attributes[:'snake_case'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -68,35 +65,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [name, snake_case].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -130,21 +133,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -155,8 +162,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/object_return.rb b/samples/client/petstore/ruby/lib/petstore/models/object_return.rb deleted file mode 100644 index 06c9d99fccc..00000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/object_return.rb +++ /dev/null @@ -1,165 +0,0 @@ -=begin -Swagger Petstore - -This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters - -OpenAPI spec version: 1.0.0 -Contact: apiteam@swagger.io -Generated by: https://github.com/swagger-api/swagger-codegen.git - -License: Apache 2.0 -http://www.apache.org/licenses/LICENSE-2.0.html - -Terms of Service: http://swagger.io/terms/ - -=end - -require 'date' - -module Petstore - class ObjectReturn - attr_accessor :_return - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - - :'_return' => :'return' - - } - end - - # Attribute type mapping. - def self.swagger_types - { - :'_return' => :'Integer' - - } - end - - def initialize(attributes = {}) - return unless attributes.is_a?(Hash) - - # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} - - - if attributes[:'return'] - self._return = attributes[:'return'] - end - - end - - # Check equality by comparing each attribute. - def ==(o) - return true if self.equal?(o) - self.class == o.class && - _return == o._return - end - - # @see the `==` method - def eql?(o) - self == o - end - - # Calculate hash code according to all attributes. - def hash - [_return].hash - end - - # build the object from hash - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.swagger_types.each_pair do |key, type| - if type =~ /^Array<(.*)>/i - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end - end - - self - end - - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :BOOLEAN - if value.to_s =~ /^(true|t|yes|y|1)$/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) - end - end - - def to_s - to_hash.to_s - end - - # to_body is an alias to to_body (backward compatibility)) - def to_body - to_hash - end - - # return the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - next if value.nil? - hash[param] = _to_hash(value) - end - hash - end - - # Method to output non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - def _to_hash(value) - if value.is_a?(Array) - value.compact.map{ |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - - end -end diff --git a/samples/client/petstore/ruby/lib/petstore/models/order.rb b/samples/client/petstore/ruby/lib/petstore/models/order.rb index c7a6076a269..223d748e990 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/order.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/order.rb @@ -34,19 +34,12 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'pet_id' => :'petId', - :'quantity' => :'quantity', - :'ship_date' => :'shipDate', - :'status' => :'status', - :'complete' => :'complete' - } end @@ -54,49 +47,44 @@ module Petstore def self.swagger_types { :'id' => :'Integer', - :'pet_id' => :'Integer', - :'quantity' => :'Integer', - :'ship_date' => :'DateTime', - :'status' => :'String', - :'complete' => :'BOOLEAN' - +:'pet_id' => :'Integer', +:'quantity' => :'Integer', +:'ship_date' => :'DateTime', +:'status' => :'String', +:'complete' => :'BOOLEAN' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] self.id = attributes[:'id'] end - if attributes[:'petId'] self.pet_id = attributes[:'petId'] end - if attributes[:'quantity'] self.quantity = attributes[:'quantity'] end - if attributes[:'shipDate'] self.ship_date = attributes[:'shipDate'] end - if attributes[:'status'] self.status = attributes[:'status'] end - if attributes[:'complete'] self.complete = attributes[:'complete'] end - end # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned def status=(status) allowed_values = ["placed", "approved", "delivered"] if status && !allowed_values.include?(status) @@ -105,7 +93,8 @@ module Petstore @status = status end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -118,35 +107,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [id, pet_id, quantity, ship_date, status, complete].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -180,21 +175,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -205,8 +204,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index fb0eaa05a72..07c5ee9d75b 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -34,19 +34,12 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'category' => :'category', - :'name' => :'name', - :'photo_urls' => :'photoUrls', - :'tags' => :'tags', - :'status' => :'status' - } end @@ -54,53 +47,48 @@ module Petstore def self.swagger_types { :'id' => :'Integer', - :'category' => :'Category', - :'name' => :'String', - :'photo_urls' => :'Array', - :'tags' => :'Array', - :'status' => :'String' - +:'category' => :'Category', +:'name' => :'String', +:'photo_urls' => :'Array', +:'tags' => :'Array', +:'status' => :'String' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] self.id = attributes[:'id'] end - if attributes[:'category'] self.category = attributes[:'category'] end - if attributes[:'name'] self.name = attributes[:'name'] end - if attributes[:'photoUrls'] if (value = attributes[:'photoUrls']).is_a?(Array) self.photo_urls = value end end - if attributes[:'tags'] if (value = attributes[:'tags']).is_a?(Array) self.tags = value end end - if attributes[:'status'] self.status = attributes[:'status'] end - end # Custom attribute writer method checking allowed values (enum). + # @param [Object] status Object to be assigned def status=(status) allowed_values = ["available", "pending", "sold"] if status && !allowed_values.include?(status) @@ -109,7 +97,8 @@ module Petstore @status = status end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -122,35 +111,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [id, category, name, photo_urls, tags, status].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -184,21 +179,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -209,8 +208,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb index b8e97d55940..b0509903ef2 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/special_model_name.rb @@ -23,9 +23,7 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'special_property_name' => :'$special[property.name]' - } end @@ -33,24 +31,24 @@ module Petstore def self.swagger_types { :'special_property_name' => :'Integer' - } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'$special[property.name]'] self.special_property_name = attributes[:'$special[property.name]'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -58,35 +56,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [special_property_name].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -120,21 +124,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -145,8 +153,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/tag.rb b/samples/client/petstore/ruby/lib/petstore/models/tag.rb index 8c4bb743bf3..c1a07d1b5e6 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/tag.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/tag.rb @@ -25,11 +25,8 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'name' => :'name' - } end @@ -37,29 +34,28 @@ module Petstore def self.swagger_types { :'id' => :'Integer', - :'name' => :'String' - +:'name' => :'String' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] self.id = attributes[:'id'] end - if attributes[:'name'] self.name = attributes[:'name'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -68,35 +64,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [id, name].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -130,21 +132,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -155,8 +161,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/lib/petstore/models/user.rb b/samples/client/petstore/ruby/lib/petstore/models/user.rb index dd37878bdc1..8e0c4fc99db 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/user.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/user.rb @@ -38,23 +38,14 @@ module Petstore # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'username' => :'username', - :'first_name' => :'firstName', - :'last_name' => :'lastName', - :'email' => :'email', - :'password' => :'password', - :'phone' => :'phone', - :'user_status' => :'userStatus' - } end @@ -62,59 +53,52 @@ module Petstore def self.swagger_types { :'id' => :'Integer', - :'username' => :'String', - :'first_name' => :'String', - :'last_name' => :'String', - :'email' => :'String', - :'password' => :'String', - :'phone' => :'String', - :'user_status' => :'Integer' - +:'username' => :'String', +:'first_name' => :'String', +:'last_name' => :'String', +:'email' => :'String', +:'password' => :'String', +:'phone' => :'String', +:'user_status' => :'Integer' } end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key - attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} + attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} - if attributes[:'id'] self.id = attributes[:'id'] end - if attributes[:'username'] self.username = attributes[:'username'] end - if attributes[:'firstName'] self.first_name = attributes[:'firstName'] end - if attributes[:'lastName'] self.last_name = attributes[:'lastName'] end - if attributes[:'email'] self.email = attributes[:'email'] end - if attributes[:'password'] self.password = attributes[:'password'] end - if attributes[:'phone'] self.phone = attributes[:'phone'] end - if attributes[:'userStatus'] self.user_status = attributes[:'userStatus'] end - end - # Check equality by comparing each attribute. + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared def ==(o) return true if self.equal?(o) self.class == o.class && @@ -129,35 +113,41 @@ module Petstore end # @see the `==` method + # @param [Object] Object to be compared def eql?(o) self == o end - # Calculate hash code according to all attributes. + # Calculates hash code according to all attributes. + # @return [Fixnum] Hash code def hash [id, username, first_name, last_name, email, password, phone, user_status].hash end - # build the object from hash + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i + # check to ensure the input is an array given that the the attribute + # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) - else - #TODO show warning in debug mode end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - else - # data not found in attributes(hash), not an issue as the data can be optional - end + end # or else data not found in attributes(hash), not an issue as the data can be optional end self end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data def _deserialize(type, value) case type.to_sym when :DateTime @@ -191,21 +181,25 @@ module Petstore end end else # model - _model = Petstore.const_get(type).new - _model.build_from_hash(value) + temp_model = Petstore.const_get(type).new + temp_model.build_from_hash(value) end end + # Returns the string representation of the object + # @return [String] String presentation of the object def to_s to_hash.to_s end - # to_body is an alias to to_body (backward compatibility)) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash def to_body to_hash end - # return the object in the form of hash + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| @@ -216,8 +210,10 @@ module Petstore hash end - # Method to output non-array value in the form of hash + # Outputs non-array value in the form of hash # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash def _to_hash(value) if value.is_a?(Array) value.compact.map{ |v| _to_hash(v) } diff --git a/samples/client/petstore/ruby/spec/api/store_api_spec.rb b/samples/client/petstore/ruby/spec/api/store_api_spec.rb index 3c6e2f2deac..0952b075bf4 100644 --- a/samples/client/petstore/ruby/spec/api/store_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/store_api_spec.rb @@ -100,7 +100,7 @@ describe 'StoreApi' do # unit tests for get_order_by_id # Find purchase order by ID - # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # @param order_id ID of pet that needs to be fetched # @param [Hash] opts the optional parameters # @return [Order] diff --git a/samples/client/petstore/ruby/spec/api/user_api_spec.rb b/samples/client/petstore/ruby/spec/api/user_api_spec.rb index 408e4544c51..60f1dcda16f 100644 --- a/samples/client/petstore/ruby/spec/api/user_api_spec.rb +++ b/samples/client/petstore/ruby/spec/api/user_api_spec.rb @@ -103,7 +103,7 @@ describe 'UserApi' do # unit tests for get_user_by_name # Get user by user name # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [User] describe 'get_user_by_name test' do diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift index ddb328e8ee5..a76f0352f52 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/PetAPI.swift @@ -132,7 +132,7 @@ public class PetAPI: APIBase { - parameter petId: (path) Pet id to delete - parameter completion: completion handler to receive the data and the error objects */ - public class func deletePet(petId petId: Int, completion: ((error: ErrorType?) -> Void)) { + public class func deletePet(petId petId: Int64, completion: ((error: ErrorType?) -> Void)) { deletePetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(error: error); } @@ -145,7 +145,7 @@ public class PetAPI: APIBase { - parameter petId: (path) Pet id to delete - returns: Promise */ - public class func deletePet(petId petId: Int) -> Promise { + public class func deletePet(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() deletePet(petId: petId) { error in if let error = error { @@ -171,7 +171,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func deletePetWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func deletePetWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -225,20 +225,20 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -247,21 +247,21 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], +}] + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -270,7 +270,7 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter status: (query) Status values that need to be considered for query (optional, default to available) @@ -331,20 +331,20 @@ public class PetAPI: APIBase { - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -353,21 +353,21 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] - - examples: [{example=[ { - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], +}] + - examples: [{contentType=application/json, example=[ { + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -} ], contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 doggie @@ -376,7 +376,7 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter tags: (query) Tags to filter by (optional) @@ -403,7 +403,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - public class func getPetById(petId petId: Int, completion: ((data: Pet?, error: ErrorType?) -> Void)) { + public class func getPetById(petId petId: Int64, completion: ((data: Pet?, error: ErrorType?) -> Void)) { getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -416,7 +416,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - returns: Promise */ - public class func getPetById(petId petId: Int) -> Promise { + public class func getPetById(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() getPetById(petId: petId) { data, error in if let error = error { @@ -434,26 +434,26 @@ public class PetAPI: APIBase { - GET /pet/{petId} - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - API Key: - - type: apiKey api_key - - name: api_key - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 doggie @@ -462,21 +462,21 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] - - examples: [{example={ - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], +}] + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], + "name" : "doggie", "id" : 123456789, "category" : { - "id" : 123456789, - "name" : "aeiou" + "name" : "aeiou", + "id" : 123456789 }, - "status" : "aeiou", - "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 doggie @@ -485,13 +485,13 @@ public class PetAPI: APIBase { string -, contentType=application/xml}] +}] - parameter petId: (path) ID of pet that needs to be fetched - returns: RequestBuilder */ - public class func getPetByIdWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func getPetByIdWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -511,7 +511,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - public class func getPetByIdInObject(petId petId: Int, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { + public class func getPetByIdInObject(petId petId: Int64, completion: ((data: InlineResponse200?, error: ErrorType?) -> Void)) { getPetByIdInObjectWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -524,7 +524,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - returns: Promise */ - public class func getPetByIdInObject(petId petId: Int) -> Promise { + public class func getPetByIdInObject(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() getPetByIdInObject(petId: petId) { data, error in if let error = error { @@ -542,52 +542,52 @@ public class PetAPI: APIBase { - GET /pet/{petId}?response=inline_arbitrary_object - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - API Key: - - type: apiKey api_key - - name: api_key - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example={ - "id" : 123456789, - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], - "category" : "{}", - "status" : "aeiou", + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "id" : 123456789, + "category" : "{}", + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= + string + doggie 123456 not implemented io.swagger.models.properties.ObjectProperty@37ff6855 string - doggie - string -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, - "tags" : [ { - "id" : 123456789, - "name" : "aeiou" - } ], - "category" : "{}", - "status" : "aeiou", +}] + - examples: [{contentType=application/json, example={ + "photoUrls" : [ "aeiou" ], "name" : "doggie", - "photoUrls" : [ "aeiou" ] -}, contentType=application/json}, {example= + "id" : 123456789, + "category" : "{}", + "tags" : [ { + "name" : "aeiou", + "id" : 123456789 + } ], + "status" : "aeiou" +}}, {contentType=application/xml, example= + string + doggie 123456 not implemented io.swagger.models.properties.ObjectProperty@37ff6855 string - doggie - string -, contentType=application/xml}] +}] - parameter petId: (path) ID of pet that needs to be fetched - returns: RequestBuilder */ - public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func getPetByIdInObjectWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}?response=inline_arbitrary_object" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -607,7 +607,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - parameter completion: completion handler to receive the data and the error objects */ - public class func petPetIdtestingByteArraytrueGet(petId petId: Int, completion: ((data: String?, error: ErrorType?) -> Void)) { + public class func petPetIdtestingByteArraytrueGet(petId petId: Int64, completion: ((data: String?, error: ErrorType?) -> Void)) { petPetIdtestingByteArraytrueGetWithRequestBuilder(petId: petId).execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -620,7 +620,7 @@ public class PetAPI: APIBase { - parameter petId: (path) ID of pet that needs to be fetched - returns: Promise */ - public class func petPetIdtestingByteArraytrueGet(petId petId: Int) -> Promise { + public class func petPetIdtestingByteArraytrueGet(petId petId: Int64) -> Promise { let deferred = Promise.pendingPromise() petPetIdtestingByteArraytrueGet(petId: petId) { data, error in if let error = error { @@ -638,20 +638,20 @@ public class PetAPI: APIBase { - GET /pet/{petId}?testing_byte_array=true - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - - API Key: - - type: apiKey api_key - - name: api_key - OAuth: - type: oauth2 - name: petstore_auth - - examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}] - - examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}] + - API Key: + - type: apiKey api_key + - name: api_key + - examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] + - examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}] - parameter petId: (path) ID of pet that needs to be fetched - returns: RequestBuilder */ - public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int) -> RequestBuilder { + public class func petPetIdtestingByteArraytrueGetWithRequestBuilder(petId petId: Int64) -> RequestBuilder { var path = "/pet/{petId}?testing_byte_array=true" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path @@ -798,7 +798,7 @@ public class PetAPI: APIBase { - parameter _file: (form) file to upload (optional) - parameter completion: completion handler to receive the data and the error objects */ - public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { + public class func uploadFile(petId petId: Int64, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) { uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in completion(error: error); } @@ -813,7 +813,7 @@ public class PetAPI: APIBase { - parameter _file: (form) file to upload (optional) - returns: Promise */ - public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> Promise { + public class func uploadFile(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> Promise { let deferred = Promise.pendingPromise() uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in if let error = error { @@ -841,7 +841,7 @@ public class PetAPI: APIBase { - returns: RequestBuilder */ - public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { + public class func uploadFileWithRequestBuilder(petId petId: Int64, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder { var path = "/pet/{petId}/uploadImage" path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil) let URLString = PetstoreClientAPI.basePath + path diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift index 09390bc4728..82d8ff179e5 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/StoreAPI.swift @@ -111,36 +111,36 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey x-test_api_client_secret - name: test_api_client_secret - - examples: [{example=[ { - "id" : 123456789, + - examples: [{contentType=application/json, example=[ { "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -} ], contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] - - examples: [{example=[ { - "id" : 123456789, +}] + - examples: [{contentType=application/json, example=[ { "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -} ], contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +} ]}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] +}] - parameter status: (query) Status value that needs to be considered for query (optional, default to placed) @@ -166,7 +166,7 @@ public class StoreAPI: APIBase { - parameter completion: completion handler to receive the data and the error objects */ - public class func getInventory(completion: ((data: [String:Int]?, error: ErrorType?) -> Void)) { + public class func getInventory(completion: ((data: [String:Int32]?, error: ErrorType?) -> Void)) { getInventoryWithRequestBuilder().execute { (response, error) -> Void in completion(data: response?.body, error: error); } @@ -176,10 +176,10 @@ public class StoreAPI: APIBase { Returns pet inventories by status - - returns: Promise<[String:Int]> + - returns: Promise<[String:Int32]> */ - public class func getInventory() -> Promise<[String:Int]> { - let deferred = Promise<[String:Int]>.pendingPromise() + public class func getInventory() -> Promise<[String:Int32]> { + let deferred = Promise<[String:Int32]>.pendingPromise() getInventory() { data, error in if let error = error { deferred.reject(error) @@ -199,23 +199,23 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{example={ + - examples: [{contentType=application/json, example={ "key" : 123 -}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] - - examples: [{example={ +}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] + - examples: [{contentType=application/json, example={ "key" : 123 -}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}] +}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}] - - returns: RequestBuilder<[String:Int]> + - returns: RequestBuilder<[String:Int32]> */ - public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> { + public class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int32]> { let path = "/store/inventory" let URLString = PetstoreClientAPI.basePath + path let nillableParameters: [String:AnyObject?] = [:] let parameters = APIHelper.rejectNil(nillableParameters) - let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() + let requestBuilder: RequestBuilder<[String:Int32]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder() return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: true) } @@ -259,8 +259,8 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey api_key - name: api_key - - examples: [{example="{}", contentType=application/json}, {example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f, contentType=application/xml}] - - examples: [{example="{}", contentType=application/json}, {example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f, contentType=application/xml}] + - examples: [{contentType=application/json, example="{}"}, {contentType=application/xml, example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f}] + - examples: [{contentType=application/json, example="{}"}, {contentType=application/xml, example=not implemented io.swagger.models.properties.ObjectProperty@37aadb4f}] - returns: RequestBuilder */ @@ -314,42 +314,42 @@ public class StoreAPI: APIBase { - GET /store/order/{orderId} - For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions - - API Key: - - type: apiKey test_api_key_header - - name: test_api_key_header - API Key: - type: apiKey test_api_key_query (QUERY) - name: test_api_key_query - - examples: [{example={ - "id" : 123456789, + - API Key: + - type: apiKey test_api_key_header + - name: test_api_key_header + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, +}] + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] +}] - parameter orderId: (path) ID of pet that needs to be fetched @@ -412,36 +412,36 @@ public class StoreAPI: APIBase { - API Key: - type: apiKey x-test_api_client_secret - name: test_api_client_secret - - examples: [{example={ - "id" : 123456789, + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] - - examples: [{example={ - "id" : 123456789, +}] + - examples: [{contentType=application/json, example={ "petId" : 123456789, - "complete" : true, - "status" : "aeiou", "quantity" : 123, - "shipDate" : "2000-01-23T04:56:07.000+0000" -}, contentType=application/json}, {example= + "id" : 123456789, + "shipDate" : "2000-01-23T04:56:07.000+0000", + "complete" : true, + "status" : "aeiou" +}}, {contentType=application/xml, example= 123456 123456 0 2000-01-23T04:56:07.000Z string true -, contentType=application/xml}] +}] - parameter body: (body) order placed for purchasing the pet (optional) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift index 3f1d18dffb0..ec73c765ac1 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/APIs/UserAPI.swift @@ -270,7 +270,7 @@ public class UserAPI: APIBase { - GET /user/{username} - - - examples: [{example={ + - examples: [{contentType=application/json, example={ "id" : 1, "username" : "johnp", "firstName" : "John", @@ -279,7 +279,7 @@ public class UserAPI: APIBase { "password" : "-secret-", "phone" : "0123456789", "userStatus" : 0 -}, contentType=application/json}] +}}] - parameter username: (path) The name that needs to be fetched. Use user1 for testing. @@ -338,8 +338,8 @@ public class UserAPI: APIBase { - GET /user/login - - - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] - - examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}] + - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] + - examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}] - parameter username: (query) The user name for login (optional) - parameter password: (query) The password for login in clear text (optional) diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Extensions.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Extensions.swift index 8015d1bd3a2..62d374eed05 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Extensions.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Extensions.swift @@ -19,6 +19,14 @@ extension Int: JSONEncodable { func encodeToJSON() -> AnyObject { return self } } +extension Int32: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(int: self) } +} + +extension Int64: JSONEncodable { + func encodeToJSON() -> AnyObject { return NSNumber(longLong: self) } +} + extension Double: JSONEncodable { func encodeToJSON() -> AnyObject { return self } } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift index 3c62d5fa4c2..329eb295157 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models.swift @@ -56,6 +56,12 @@ class Decoders { static func decode(clazz clazz: T.Type, source: AnyObject) -> T { initialize() + if T.self is Int32.Type && source is NSNumber { + return source.intValue as! T; + } + if T.self is Int64.Type && source is NSNumber { + return source.longLongValue as! T; + } if source is T { return source as! T } @@ -132,7 +138,7 @@ class Decoders { Decoders.addDecoder(clazz: Category.self) { (source: AnyObject) -> Category in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Category() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) return instance } @@ -146,12 +152,12 @@ class Decoders { Decoders.addDecoder(clazz: InlineResponse200.self) { (source: AnyObject) -> InlineResponse200 in let sourceDictionary = source as! [NSObject:AnyObject] let instance = InlineResponse200() - instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) - instance.status = InlineResponse200.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") - instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) + instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.category = Decoders.decodeOptional(clazz: AnyObject.self, source: sourceDictionary["category"]) + instance.tags = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["tags"]) + instance.status = InlineResponse200.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") return instance } @@ -164,7 +170,7 @@ class Decoders { Decoders.addDecoder(clazz: Model200Response.self) { (source: AnyObject) -> Model200Response in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Model200Response() - instance.name = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["name"]) + instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"]) return instance } @@ -177,7 +183,7 @@ class Decoders { Decoders.addDecoder(clazz: ModelReturn.self) { (source: AnyObject) -> ModelReturn in let sourceDictionary = source as! [NSObject:AnyObject] let instance = ModelReturn() - instance._return = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["return"]) + instance._return = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["return"]) return instance } @@ -190,8 +196,8 @@ class Decoders { Decoders.addDecoder(clazz: Name.self) { (source: AnyObject) -> Name in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Name() - instance.name = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["name"]) - instance.snakeCase = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["snake_case"]) + instance.name = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["name"]) + instance.snakeCase = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["snake_case"]) return instance } @@ -204,9 +210,9 @@ class Decoders { Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Order() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) - instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"]) - instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) + instance.petId = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["petId"]) + instance.quantity = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["quantity"]) instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"]) instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "") instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"]) @@ -222,7 +228,7 @@ class Decoders { Decoders.addDecoder(clazz: Pet.self) { (source: AnyObject) -> Pet in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Pet() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.category = Decoders.decodeOptional(clazz: Category.self, source: sourceDictionary["category"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) instance.photoUrls = Decoders.decodeOptional(clazz: Array.self, source: sourceDictionary["photoUrls"]) @@ -240,7 +246,7 @@ class Decoders { Decoders.addDecoder(clazz: SpecialModelName.self) { (source: AnyObject) -> SpecialModelName in let sourceDictionary = source as! [NSObject:AnyObject] let instance = SpecialModelName() - instance.specialPropertyName = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["$special[property.name]"]) + instance.specialPropertyName = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["$special[property.name]"]) return instance } @@ -253,7 +259,7 @@ class Decoders { Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in let sourceDictionary = source as! [NSObject:AnyObject] let instance = Tag() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"]) return instance } @@ -267,14 +273,14 @@ class Decoders { Decoders.addDecoder(clazz: User.self) { (source: AnyObject) -> User in let sourceDictionary = source as! [NSObject:AnyObject] let instance = User() - instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"]) + instance.id = Decoders.decodeOptional(clazz: Int64.self, source: sourceDictionary["id"]) instance.username = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["username"]) instance.firstName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["firstName"]) instance.lastName = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["lastName"]) instance.email = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["email"]) instance.password = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["password"]) instance.phone = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["phone"]) - instance.userStatus = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["userStatus"]) + instance.userStatus = Decoders.decodeOptional(clazz: Int32.self, source: sourceDictionary["userStatus"]) return instance } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift index f542ea676f8..2f0ab835e8f 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Category.swift @@ -10,7 +10,7 @@ import Foundation public class Category: JSONEncodable { - public var id: Int? + public var id: Int64? public var name: String? @@ -19,7 +19,7 @@ public class Category: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id?.encodeToJSON() nillableDictionary["name"] = self.name let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift index 5835a8d9899..fcf0679aea2 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/InlineResponse200.swift @@ -16,13 +16,13 @@ public class InlineResponse200: JSONEncodable { case Sold = "sold" } - public var tags: [Tag]? - public var id: Int? + public var photoUrls: [String]? + public var name: String? + public var id: Int64? public var category: AnyObject? + public var tags: [Tag]? /** pet status in the store */ public var status: Status? - public var name: String? - public var photoUrls: [String]? public init() {} @@ -30,12 +30,12 @@ public class InlineResponse200: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["tags"] = self.tags?.encodeToJSON() - nillableDictionary["id"] = self.id - nillableDictionary["category"] = self.category - nillableDictionary["status"] = self.status?.rawValue - nillableDictionary["name"] = self.name nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() + nillableDictionary["name"] = self.name + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["category"] = self.category + nillableDictionary["tags"] = self.tags?.encodeToJSON() + nillableDictionary["status"] = self.status?.rawValue let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift index 69b18379b28..f929d282358 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Model200Response.swift @@ -10,7 +10,7 @@ import Foundation public class Model200Response: JSONEncodable { - public var name: Int? + public var name: Int32? public init() {} @@ -18,7 +18,7 @@ public class Model200Response: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["name"] = self.name + nillableDictionary["name"] = self.name?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift index fbbcd5ec56f..f3f16f2c13e 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/ModelReturn.swift @@ -10,7 +10,7 @@ import Foundation public class ModelReturn: JSONEncodable { - public var _return: Int? + public var _return: Int32? public init() {} @@ -18,7 +18,7 @@ public class ModelReturn: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["return"] = self._return + nillableDictionary["return"] = self._return?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift index 986d6f00041..4b49c8325d5 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Name.swift @@ -10,8 +10,8 @@ import Foundation public class Name: JSONEncodable { - public var name: Int? - public var snakeCase: Int? + public var name: Int32? + public var snakeCase: Int32? public init() {} @@ -19,8 +19,8 @@ public class Name: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["name"] = self.name - nillableDictionary["snake_case"] = self.snakeCase + nillableDictionary["name"] = self.name?.encodeToJSON() + nillableDictionary["snake_case"] = self.snakeCase?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift index f309744da99..03b977c88f7 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Order.swift @@ -16,9 +16,9 @@ public class Order: JSONEncodable { case Delivered = "delivered" } - public var id: Int? - public var petId: Int? - public var quantity: Int? + public var id: Int64? + public var petId: Int64? + public var quantity: Int32? public var shipDate: NSDate? /** Order Status */ public var status: Status? @@ -30,9 +30,9 @@ public class Order: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id - nillableDictionary["petId"] = self.petId - nillableDictionary["quantity"] = self.quantity + nillableDictionary["id"] = self.id?.encodeToJSON() + nillableDictionary["petId"] = self.petId?.encodeToJSON() + nillableDictionary["quantity"] = self.quantity?.encodeToJSON() nillableDictionary["shipDate"] = self.shipDate?.encodeToJSON() nillableDictionary["status"] = self.status?.rawValue nillableDictionary["complete"] = self.complete diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift index b1491df2516..5df44cfca96 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Pet.swift @@ -16,7 +16,7 @@ public class Pet: JSONEncodable { case Sold = "sold" } - public var id: Int? + public var id: Int64? public var category: Category? public var name: String? public var photoUrls: [String]? @@ -30,7 +30,7 @@ public class Pet: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id?.encodeToJSON() nillableDictionary["category"] = self.category?.encodeToJSON() nillableDictionary["name"] = self.name nillableDictionary["photoUrls"] = self.photoUrls?.encodeToJSON() diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift index d151c129965..907be7f934a 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/SpecialModelName.swift @@ -10,7 +10,7 @@ import Foundation public class SpecialModelName: JSONEncodable { - public var specialPropertyName: Int? + public var specialPropertyName: Int64? public init() {} @@ -18,7 +18,7 @@ public class SpecialModelName: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["$special[property.name]"] = self.specialPropertyName + nillableDictionary["$special[property.name]"] = self.specialPropertyName?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift index edcd73a7a0c..ecff268828f 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/Tag.swift @@ -10,7 +10,7 @@ import Foundation public class Tag: JSONEncodable { - public var id: Int? + public var id: Int64? public var name: String? @@ -19,7 +19,7 @@ public class Tag: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id?.encodeToJSON() nillableDictionary["name"] = self.name let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary diff --git a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift index fa0ad3f5019..70fee87f4d5 100644 --- a/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift +++ b/samples/client/petstore/swift/PetstoreClient/Classes/Swaggers/Models/User.swift @@ -10,7 +10,7 @@ import Foundation public class User: JSONEncodable { - public var id: Int? + public var id: Int64? public var username: String? public var firstName: String? public var lastName: String? @@ -18,7 +18,7 @@ public class User: JSONEncodable { public var password: String? public var phone: String? /** User Status */ - public var userStatus: Int? + public var userStatus: Int32? public init() {} @@ -26,14 +26,14 @@ public class User: JSONEncodable { // MARK: JSONEncodable func encodeToJSON() -> AnyObject { var nillableDictionary = [String:AnyObject?]() - nillableDictionary["id"] = self.id + nillableDictionary["id"] = self.id?.encodeToJSON() nillableDictionary["username"] = self.username nillableDictionary["firstName"] = self.firstName nillableDictionary["lastName"] = self.lastName nillableDictionary["email"] = self.email nillableDictionary["password"] = self.password nillableDictionary["phone"] = self.phone - nillableDictionary["userStatus"] = self.userStatus + nillableDictionary["userStatus"] = self.userStatus?.encodeToJSON() let dictionary: [String:AnyObject] = APIHelper.rejectNil(nillableDictionary) ?? [:] return dictionary } diff --git a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Assets.xcassets/AppIcon.appiconset/Contents.json b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Assets.xcassets/AppIcon.appiconset/Contents.json index 36d2c80d889..eeea76c2db5 100644 --- a/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/samples/client/petstore/swift/SwaggerClientTests/SwaggerClient/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -59,6 +59,11 @@ "idiom" : "ipad", "size" : "76x76", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : { diff --git a/samples/server/petstore/nodejs/api/swagger.yaml b/samples/server/petstore/nodejs/api/swagger.yaml index 3cbdf63c594..7f6eada7d8c 100644 --- a/samples/server/petstore/nodejs/api/swagger.yaml +++ b/samples/server/petstore/nodejs/api/swagger.yaml @@ -1,53 +1,40 @@ --- swagger: "2.0" info: - description: "This is a sample server Petstore server. You can find out more about\n\ - Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\n\ - For this sample, you can use the api key `special-key` to test the authorization\ - \ filters.\n" + description: "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io)\ + \ or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample,\ + \ you can use the api key `special-key` to test the authorization filters\n" version: "1.0.0" title: "Swagger Petstore" termsOfService: "http://swagger.io/terms/" contact: - email: "apiteam@swagger.io" + name: "apiteam@swagger.io" license: name: "Apache 2.0" url: "http://www.apache.org/licenses/LICENSE-2.0.html" host: "petstore.swagger.io" basePath: "/v2" -tags: -- name: "pet" - description: "Everything about your Pets" - externalDocs: - description: "Find out more" - url: "http://swagger.io" -- name: "store" - description: "Access to Petstore orders" -- name: "user" - description: "Operations about user" - externalDocs: - description: "Find out more about our store" - url: "http://swagger.io" schemes: - "http" paths: - /pet: + /pets: post: tags: - "pet" summary: "Add a new pet to the store" + description: "" operationId: "addPet" consumes: - "application/json" - "application/xml" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" - required: true + required: false schema: $ref: "#/definitions/Pet" responses: @@ -55,25 +42,26 @@ paths: description: "Invalid input" security: - petstore_auth: - - "write:pets" - - "read:pets" + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" put: tags: - "pet" summary: "Update an existing pet" + description: "" operationId: "updatePet" consumes: - "application/json" - "application/xml" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" - required: true + required: false schema: $ref: "#/definitions/Pet" responses: @@ -85,32 +73,27 @@ paths: description: "Validation exception" security: - petstore_auth: - - "write:pets" - - "read:pets" + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" - /pet/findByStatus: + /pets/findByStatus: get: tags: - "pet" summary: "Finds Pets by status" - description: "Multiple status values can be provided with comma separated strings" + description: "Multiple status values can be provided with comma seperated strings" operationId: "findPetsByStatus" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "status" in: "query" description: "Status values that need to be considered for filter" - required: true + required: false type: "array" items: type: "string" - default: "available" - enum: - - "available" - - "pending" - - "sold" collectionFormat: "multi" responses: 200: @@ -123,25 +106,25 @@ paths: description: "Invalid status value" security: - petstore_auth: - - "write:pets" - - "read:pets" + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" - /pet/findByTags: + /pets/findByTags: get: tags: - "pet" summary: "Finds Pets by tags" - description: "Muliple tags can be provided with comma separated strings. Use\n\ - tag1, tag2, tag3 for testing.\n" + description: "Muliple tags can be provided with comma seperated strings. Use\ + \ tag1, tag2, tag3 for testing." operationId: "findPetsByTags" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "tags" in: "query" description: "Tags to filter by" - required: true + required: false type: "array" items: type: "string" @@ -157,24 +140,24 @@ paths: description: "Invalid tag value" security: - petstore_auth: - - "write:pets" - - "read:pets" - deprecated: true + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" - /pet/{petId}: + /pets/{petId}: get: tags: - "pet" summary: "Find pet by ID" - description: "Returns a single pet" + description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\ + \ API error conditions" operationId: "getPetById" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "petId" in: "path" - description: "ID of pet to return" + description: "ID of pet that needs to be fetched" required: true type: "integer" format: "int64" @@ -189,55 +172,59 @@ paths: description: "Pet not found" security: - api_key: [] + - petstore_auth: + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" post: tags: - "pet" summary: "Updates a pet in the store with form data" - description: "null" + description: "" operationId: "updatePetWithForm" consumes: - "application/x-www-form-urlencoded" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "petId" in: "path" description: "ID of pet that needs to be updated" required: true - type: "integer" - format: "int64" + type: "string" - name: "name" in: "formData" description: "Updated name of the pet" - required: false + required: true type: "string" - name: "status" in: "formData" description: "Updated status of the pet" - required: false + required: true type: "string" responses: 405: description: "Invalid input" security: - petstore_auth: - - "write:pets" - - "read:pets" + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" delete: tags: - "pet" summary: "Deletes a pet" + description: "" operationId: "deletePet" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "api_key" in: "header" - required: false + description: "" + required: true type: "string" - name: "petId" in: "path" @@ -247,86 +234,27 @@ paths: format: "int64" responses: 400: - description: "Invalid ID supplied" - 404: - description: "Pet not found" + description: "Invalid pet value" security: - petstore_auth: - - "write:pets" - - "read:pets" + - "write_pets" + - "read_pets" x-swagger-router-controller: "Pet" - /pet/{petId}/uploadImage: - post: - tags: - - "pet" - summary: "uploads an image" - operationId: "uploadFile" - consumes: - - "multipart/form-data" - produces: - - "application/json" - parameters: - - name: "petId" - in: "path" - description: "ID of pet to update" - required: true - type: "integer" - format: "int64" - - name: "additionalMetadata" - in: "formData" - description: "Additional data to pass to server" - required: false - type: "string" - - name: "file" - in: "formData" - description: "file to upload" - required: false - type: "file" - responses: - 200: - description: "successful operation" - schema: - $ref: "#/definitions/ApiResponse" - security: - - petstore_auth: - - "write:pets" - - "read:pets" - x-swagger-router-controller: "Pet" - /store/inventory: - get: - tags: - - "store" - summary: "Returns pet inventories by status" - description: "Returns a map of status codes to quantities" - operationId: "getInventory" - produces: - - "application/json" - parameters: [] - responses: - 200: - description: "successful operation" - schema: - type: "object" - additionalProperties: - type: "integer" - format: "int32" - security: - - api_key: [] - x-swagger-router-controller: "Store" - /store/order: + /stores/order: post: tags: - "store" summary: "Place an order for a pet" + description: "" operationId: "placeOrder" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - in: "body" name: "body" description: "order placed for purchasing the pet" - required: true + required: false schema: $ref: "#/definitions/Order" responses: @@ -337,26 +265,23 @@ paths: 400: description: "Invalid Order" x-swagger-router-controller: "Store" - /store/order/{orderId}: + /stores/order/{orderId}: get: tags: - "store" summary: "Find purchase order by ID" - description: "For valid response try integer IDs with value >= 1 and <= 10.\n\ - Other values will generated exceptions\n" + description: "For valid response try integer IDs with value <= 5 or > 10. Other\ + \ values will generated exceptions" operationId: "getOrderById" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "orderId" in: "path" description: "ID of pet that needs to be fetched" required: true - type: "integer" - maximum: 10 - minimum: 1 - format: "int64" + type: "string" responses: 200: description: "successful operation" @@ -371,27 +296,25 @@ paths: tags: - "store" summary: "Delete purchase order by ID" - description: "For valid response try integer IDs with positive integer value.\\\ - \ \\ Negative or non-integer values will generate API errors" + description: "For valid response try integer IDs with value < 1000. Anything\ + \ above 1000 or nonintegers will generate API errors" operationId: "deleteOrder" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "orderId" in: "path" description: "ID of the order that needs to be deleted" required: true - type: "integer" - minimum: 1 - format: "int64" + type: "string" responses: 400: description: "Invalid ID supplied" 404: description: "Order not found" x-swagger-router-controller: "Store" - /user: + /users: post: tags: - "user" @@ -399,33 +322,34 @@ paths: description: "This can only be done by the logged in user." operationId: "createUser" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - in: "body" name: "body" description: "Created user object" - required: true + required: false schema: $ref: "#/definitions/User" responses: default: description: "successful operation" x-swagger-router-controller: "User" - /user/createWithArray: + /users/createWithArray: post: tags: - "user" summary: "Creates list of users with given input array" + description: "" operationId: "createUsersWithArrayInput" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - in: "body" name: "body" description: "List of user object" - required: true + required: false schema: type: "array" items: @@ -434,20 +358,21 @@ paths: default: description: "successful operation" x-swagger-router-controller: "User" - /user/createWithList: + /users/createWithList: post: tags: - "user" summary: "Creates list of users with given input array" + description: "" operationId: "createUsersWithListInput" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - in: "body" name: "body" description: "List of user object" - required: true + required: false schema: type: "array" items: @@ -456,67 +381,60 @@ paths: default: description: "successful operation" x-swagger-router-controller: "User" - /user/login: + /users/login: get: tags: - "user" summary: "Logs user into the system" + description: "" operationId: "loginUser" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "username" in: "query" description: "The user name for login" - required: true + required: false type: "string" - name: "password" in: "query" description: "The password for login in clear text" - required: true + required: false type: "string" responses: 200: description: "successful operation" schema: type: "string" - headers: - X-Rate-Limit: - type: "integer" - format: "int32" - description: "calls per hour allowed by the user" - X-Expires-After: - type: "string" - format: "date-time" - description: "date in UTC when token expires" 400: description: "Invalid username/password supplied" x-swagger-router-controller: "User" - /user/logout: + /users/logout: get: tags: - "user" summary: "Logs out current logged in user session" - description: "null" + description: "" operationId: "logoutUser" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: [] responses: default: description: "successful operation" x-swagger-router-controller: "User" - /user/{username}: + /users/{username}: get: tags: - "user" summary: "Get user by user name" + description: "" operationId: "getUserByName" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "username" in: "path" @@ -540,18 +458,18 @@ paths: description: "This can only be done by the logged in user." operationId: "updateUser" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "username" in: "path" - description: "name that need to be updated" + description: "name that need to be deleted" required: true type: "string" - in: "body" name: "body" description: "Updated user object" - required: true + required: false schema: $ref: "#/definitions/User" responses: @@ -567,8 +485,8 @@ paths: description: "This can only be done by the logged in user." operationId: "deleteUser" produces: - - "application/xml" - "application/json" + - "application/xml" parameters: - name: "username" in: "path" @@ -588,39 +506,12 @@ securityDefinitions: in: "header" petstore_auth: type: "oauth2" - authorizationUrl: "http://petstore.swagger.io/oauth/dialog" + authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog" flow: "implicit" scopes: - write:pets: "modify pets in your account" - read:pets: "read your pets" + write_pets: "modify pets in your account" + read_pets: "read your pets" definitions: - Order: - type: "object" - properties: - id: - type: "integer" - format: "int64" - petId: - type: "integer" - format: "int64" - quantity: - type: "integer" - format: "int32" - shipDate: - type: "string" - format: "date-time" - status: - type: "string" - description: "Order Status" - enum: - - "placed" - - "approved" - - "delivered" - complete: - type: "boolean" - default: false - xml: - name: "Order" User: type: "object" properties: @@ -643,8 +534,6 @@ definitions: type: "integer" format: "int32" description: "User Status" - xml: - name: "User" Category: type: "object" properties: @@ -653,18 +542,6 @@ definitions: format: "int64" name: type: "string" - xml: - name: "Category" - Tag: - type: "object" - properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - xml: - name: "Tag" Pet: type: "object" required: @@ -681,37 +558,40 @@ definitions: example: "doggie" photoUrls: type: "array" - xml: - name: "photoUrl" - wrapped: true items: type: "string" tags: type: "array" - xml: - name: "tag" - wrapped: true items: $ref: "#/definitions/Tag" status: type: "string" description: "pet status in the store" - enum: - - "available" - - "pending" - - "sold" - xml: - name: "Pet" - ApiResponse: + Tag: type: "object" properties: - code: + id: + type: "integer" + format: "int64" + name: + type: "string" + Order: + type: "object" + properties: + id: + type: "integer" + format: "int64" + petId: + type: "integer" + format: "int64" + quantity: type: "integer" format: "int32" - type: + shipDate: type: "string" - message: + format: "date-time" + status: type: "string" -externalDocs: - description: "Find out more about Swagger" - url: "http://swagger.io" + description: "Order Status" + complete: + type: "boolean" diff --git a/samples/server/petstore/nodejs/controllers/Pet.js b/samples/server/petstore/nodejs/controllers/Pet.js index 3748305bfbe..a7d196faa7c 100644 --- a/samples/server/petstore/nodejs/controllers/Pet.js +++ b/samples/server/petstore/nodejs/controllers/Pet.js @@ -33,7 +33,3 @@ module.exports.updatePet = function updatePet (req, res, next) { module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) { Pet.updatePetWithForm(req.swagger.params, res, next); }; - -module.exports.uploadFile = function uploadFile (req, res, next) { - Pet.uploadFile(req.swagger.params, res, next); -}; diff --git a/samples/server/petstore/nodejs/controllers/PetService.js b/samples/server/petstore/nodejs/controllers/PetService.js index 212f5f41313..29a51e31a2b 100644 --- a/samples/server/petstore/nodejs/controllers/PetService.js +++ b/samples/server/petstore/nodejs/controllers/PetService.js @@ -6,20 +6,16 @@ exports.addPet = function(args, res, next) { * body (Pet) **/ // no response value expected for this operation - - res.end(); } exports.deletePet = function(args, res, next) { /** * parameters expected in the args: - * petId (Long) * apiKey (String) + * petId (Long) **/ // no response value expected for this operation - - res.end(); } @@ -28,9 +24,7 @@ exports.findPetsByStatus = function(args, res, next) { * parameters expected in the args: * status (List) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = [ { "tags" : [ { "id" : 123456789, @@ -45,7 +39,6 @@ exports.findPetsByStatus = function(args, res, next) { "name" : "doggie", "photoUrls" : [ "aeiou" ] } ]; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -54,7 +47,6 @@ exports.findPetsByStatus = function(args, res, next) { res.end(); } - } exports.findPetsByTags = function(args, res, next) { @@ -62,9 +54,7 @@ exports.findPetsByTags = function(args, res, next) { * parameters expected in the args: * tags (List) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = [ { "tags" : [ { "id" : 123456789, @@ -79,7 +69,6 @@ exports.findPetsByTags = function(args, res, next) { "name" : "doggie", "photoUrls" : [ "aeiou" ] } ]; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -88,7 +77,6 @@ exports.findPetsByTags = function(args, res, next) { res.end(); } - } exports.getPetById = function(args, res, next) { @@ -96,9 +84,7 @@ exports.getPetById = function(args, res, next) { * parameters expected in the args: * petId (Long) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = { "tags" : [ { "id" : 123456789, @@ -113,7 +99,6 @@ exports.getPetById = function(args, res, next) { "name" : "doggie", "photoUrls" : [ "aeiou" ] }; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -122,7 +107,6 @@ exports.getPetById = function(args, res, next) { res.end(); } - } exports.updatePet = function(args, res, next) { @@ -131,48 +115,17 @@ exports.updatePet = function(args, res, next) { * body (Pet) **/ // no response value expected for this operation - - res.end(); } exports.updatePetWithForm = function(args, res, next) { /** * parameters expected in the args: - * petId (Long) + * petId (String) * name (String) * status (String) **/ // no response value expected for this operation - - res.end(); } -exports.uploadFile = function(args, res, next) { - /** - * parameters expected in the args: - * petId (Long) - * additionalMetadata (String) - * file (file) - **/ - - - var examples = {}; - examples['application/json'] = { - "message" : "aeiou", - "code" : 123, - "type" : "aeiou" -}; - - if(Object.keys(examples).length > 0) { - res.setHeader('Content-Type', 'application/json'); - res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); - } - else { - res.end(); - } - - -} - diff --git a/samples/server/petstore/nodejs/controllers/Store.js b/samples/server/petstore/nodejs/controllers/Store.js index ac67c740d29..95fcb02711e 100644 --- a/samples/server/petstore/nodejs/controllers/Store.js +++ b/samples/server/petstore/nodejs/controllers/Store.js @@ -10,10 +10,6 @@ module.exports.deleteOrder = function deleteOrder (req, res, next) { Store.deleteOrder(req.swagger.params, res, next); }; -module.exports.getInventory = function getInventory (req, res, next) { - Store.getInventory(req.swagger.params, res, next); -}; - module.exports.getOrderById = function getOrderById (req, res, next) { Store.getOrderById(req.swagger.params, res, next); }; diff --git a/samples/server/petstore/nodejs/controllers/StoreService.js b/samples/server/petstore/nodejs/controllers/StoreService.js index de42d786581..6ee8ff36f94 100644 --- a/samples/server/petstore/nodejs/controllers/StoreService.js +++ b/samples/server/petstore/nodejs/controllers/StoreService.js @@ -3,44 +3,18 @@ exports.deleteOrder = function(args, res, next) { /** * parameters expected in the args: - * orderId (Long) + * orderId (String) **/ // no response value expected for this operation - - res.end(); } -exports.getInventory = function(args, res, next) { - /** - * parameters expected in the args: - **/ - - - var examples = {}; - examples['application/json'] = { - "key" : 123 -}; - - if(Object.keys(examples).length > 0) { - res.setHeader('Content-Type', 'application/json'); - res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); - } - else { - res.end(); - } - - -} - exports.getOrderById = function(args, res, next) { /** * parameters expected in the args: - * orderId (Long) + * orderId (String) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = { "id" : 123456789, "petId" : 123456789, @@ -49,7 +23,6 @@ exports.getOrderById = function(args, res, next) { "quantity" : 123, "shipDate" : "2000-01-23T04:56:07.000+0000" }; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -58,7 +31,6 @@ exports.getOrderById = function(args, res, next) { res.end(); } - } exports.placeOrder = function(args, res, next) { @@ -66,9 +38,7 @@ exports.placeOrder = function(args, res, next) { * parameters expected in the args: * body (Order) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = { "id" : 123456789, "petId" : 123456789, @@ -77,7 +47,6 @@ exports.placeOrder = function(args, res, next) { "quantity" : 123, "shipDate" : "2000-01-23T04:56:07.000+0000" }; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -86,6 +55,5 @@ exports.placeOrder = function(args, res, next) { res.end(); } - } diff --git a/samples/server/petstore/nodejs/controllers/UserService.js b/samples/server/petstore/nodejs/controllers/UserService.js index 13ddbee03fc..69fc1a81391 100644 --- a/samples/server/petstore/nodejs/controllers/UserService.js +++ b/samples/server/petstore/nodejs/controllers/UserService.js @@ -6,8 +6,6 @@ exports.createUser = function(args, res, next) { * body (User) **/ // no response value expected for this operation - - res.end(); } @@ -17,8 +15,6 @@ exports.createUsersWithArrayInput = function(args, res, next) { * body (List) **/ // no response value expected for this operation - - res.end(); } @@ -28,8 +24,6 @@ exports.createUsersWithListInput = function(args, res, next) { * body (List) **/ // no response value expected for this operation - - res.end(); } @@ -39,8 +33,6 @@ exports.deleteUser = function(args, res, next) { * username (String) **/ // no response value expected for this operation - - res.end(); } @@ -49,9 +41,7 @@ exports.getUserByName = function(args, res, next) { * parameters expected in the args: * username (String) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = { "id" : 123456789, "lastName" : "aeiou", @@ -62,7 +52,6 @@ exports.getUserByName = function(args, res, next) { "firstName" : "aeiou", "password" : "aeiou" }; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -71,7 +60,6 @@ exports.getUserByName = function(args, res, next) { res.end(); } - } exports.loginUser = function(args, res, next) { @@ -80,11 +68,8 @@ exports.loginUser = function(args, res, next) { * username (String) * password (String) **/ - - - var examples = {}; + var examples = {}; examples['application/json'] = "aeiou"; - if(Object.keys(examples).length > 0) { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); @@ -93,7 +78,6 @@ exports.loginUser = function(args, res, next) { res.end(); } - } exports.logoutUser = function(args, res, next) { @@ -101,8 +85,6 @@ exports.logoutUser = function(args, res, next) { * parameters expected in the args: **/ // no response value expected for this operation - - res.end(); } @@ -113,8 +95,6 @@ exports.updateUser = function(args, res, next) { * body (User) **/ // no response value expected for this operation - - res.end(); } diff --git a/samples/server/petstore/nodejs/package.json b/samples/server/petstore/nodejs/package.json index fbc49f2a725..2ebddec5e2e 100644 --- a/samples/server/petstore/nodejs/package.json +++ b/samples/server/petstore/nodejs/package.json @@ -1,7 +1,7 @@ { "name": "swagger-petstore", "version": "1.0.0", - "description": "This is a sample server Petstore server. You can find out more about\nSwagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n", + "description": "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n", "main": "index.js", "keywords": [ "swagger"