diff --git a/README.md b/README.md index 0eeb2a3065e..ef321e4bb59 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additi - [To build a server stub](#to-build-a-server-stub) - [Node.js](#nodejs) - [PHP Silex](#php-silex) + - [Python Flask (Connexion)](#python-flask-connexion) - [Ruby Sinatra](#ruby-sinatra) - [Scala Scalatra](#scala-scalatra) - [Java JAX-RS](#java-jax-rs) @@ -268,9 +269,11 @@ AkkaScalaClientCodegen.java AndroidClientCodegen.java AsyncScalaClientCodegen.java CSharpClientCodegen.java +ClojureClientCodegen.java CsharpDotNet2ClientCodegen.java DartClientCodegen.java FlashClientCodegen.java +FlaskConnexionCodegen.java JavaClientCodegen.java JavaInflectorServerCodegen.java JaxRSServerCodegen.java @@ -441,6 +444,15 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -o samples/server/petstore/silex ``` +### Python Flask (Connexion) + +``` +java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ + -i http://petstore.swagger.io/v2/swagger.json \ + -l flaskConnexion \ + -o samples/server/petstore/flaskConnexion +``` + ### Ruby Sinatra ``` diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java index c75181c51cd..ca06652b942 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java @@ -1,6 +1,7 @@ package io.swagger.codegen.cmd; import ch.lambdaj.function.convert.Converter; +import com.google.common.base.CaseFormat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.samskivert.mustache.Mustache; @@ -9,7 +10,6 @@ import io.airlift.airline.Option; import io.swagger.codegen.DefaultGenerator; import io.swagger.codegen.SupportingFile; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +55,7 @@ public class Meta implements Runnable { final File targetDir = new File(outputFolder); LOG.info("writing to folder [{}]", targetDir.getAbsolutePath()); - String mainClass = StringUtils.capitalize(name) + "Generator"; + String mainClass = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name) + "Generator"; List supportingFiles = ImmutableList.of( new SupportingFile("pom.mustache", "", "pom.xml"), @@ -68,11 +68,18 @@ public class Meta implements Runnable { "src/main/resources/META-INF/services", "io.swagger.codegen.CodegenConfig") ); + String swaggerVersion = this.getClass().getPackage().getImplementationVersion(); + // if the code is running outside of the jar (i.e. from the IDE), it will not have the version available. + // let's default it with something. + if (swaggerVersion==null) { + swaggerVersion = "2.1.3"; + } Map data = new ImmutableMap.Builder() .put("generatorPackage", targetPackage) .put("generatorClass", mainClass) .put("name", name) - .put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass).build(); + .put("fullyQualifiedGeneratorClass", targetPackage + "." + mainClass) + .put("swaggerCodegenVersion", swaggerVersion).build(); with(supportingFiles).convert(processFiles(targetDir, data)); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java index 0277c2d9077..a358cc05b51 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ClojureClientCodegen.java @@ -1,5 +1,6 @@ package io.swagger.codegen.languages; +import io.swagger.codegen.CliOption; import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenOperation; @@ -13,8 +14,6 @@ import io.swagger.models.Swagger; import org.apache.commons.lang.StringUtils; import java.io.File; -import java.util.Arrays; -import java.util.HashSet; import java.util.Map; import java.util.List; @@ -23,13 +22,15 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi private static final String PROJECT_DESCRIPTION = "projectDescription"; private static final String PROJECT_VERSION = "projectVersion"; private static final String PROJECT_URL = "projectUrl"; - private static final String LICENSE_NAME = "licenseName"; - private static final String LICENSE_URL = "licenseUrl"; + private static final String PROJECT_LICENSE_NAME = "projectLicenseName"; + private static final String PROJECT_LICENSE_URL = "projectLicenseUrl"; private static final String BASE_NAMESPACE = "baseNamespace"; protected String projectName = null; protected String projectDescription = null; protected String projectVersion = null; + protected String baseNamespace = null; + protected String sourceFolder = "src"; public ClojureClientCodegen() { @@ -37,6 +38,21 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi outputFolder = "generated-code" + File.separator + "clojure"; apiTemplateFiles.put("api.mustache", ".clj"); embeddedTemplateDir = templateDir = "clojure"; + + cliOptions.add(new CliOption(PROJECT_NAME, + "name of the project (Default: generated from info.title or \"swagger-clj-client\")")); + cliOptions.add(new CliOption(PROJECT_DESCRIPTION, + "description of the project (Default: using info.description or \"Client library of \")")); + cliOptions.add(new CliOption(PROJECT_VERSION, + "version of the project (Default: using info.version or \"1.0.0\")")); + cliOptions.add(new CliOption(PROJECT_URL, + "URL of the project (Default: using info.contact.url or not included in project.clj)")); + cliOptions.add(new CliOption(PROJECT_LICENSE_NAME, + "name of the license the project uses (Default: using info.license.name or not included in project.clj)")); + cliOptions.add(new CliOption(PROJECT_LICENSE_URL, + "URL of the license the project uses (Default: using info.license.url or not included in project.clj)")); + cliOptions.add(new CliOption(BASE_NAMESPACE, + "the base/top namespace (Default: generated from projectName)")); } @Override @@ -67,6 +83,9 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi if (additionalProperties.containsKey(PROJECT_VERSION)) { projectVersion = ((String) additionalProperties.get(PROJECT_VERSION)); } + if (additionalProperties.containsKey(BASE_NAMESPACE)) { + baseNamespace = ((String) additionalProperties.get(BASE_NAMESPACE)); + } if (swagger.getInfo() != null) { Info info = swagger.getInfo(); @@ -91,11 +110,11 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi } if (info.getLicense() != null) { License license = info.getLicense(); - if (additionalProperties.get(LICENSE_NAME) == null) { - additionalProperties.put(LICENSE_NAME, license.getName()); + if (additionalProperties.get(PROJECT_LICENSE_NAME) == null) { + additionalProperties.put(PROJECT_LICENSE_NAME, license.getName()); } - if (additionalProperties.get(LICENSE_URL) == null) { - additionalProperties.put(LICENSE_URL, license.getUrl()); + if (additionalProperties.get(PROJECT_LICENSE_URL) == null) { + additionalProperties.put(PROJECT_LICENSE_URL, license.getUrl()); } } } @@ -110,8 +129,9 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi if (projectDescription == null) { projectDescription = "Client library of " + projectName; } - - final String baseNamespace = dashize(projectName); + if (baseNamespace == null) { + baseNamespace = dashize(projectName); + } apiPackage = baseNamespace + ".api"; additionalProperties.put(PROJECT_NAME, projectName); diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache index 04be4812292..931d17b0d04 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/ApiKeyAuth.mustache @@ -44,6 +44,9 @@ public class ApiKeyAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (apiKey == null) { + return; + } String value; if (apiKeyPrefix != null) { value = apiKeyPrefix + " " + apiKey; diff --git a/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache index 63813e2504e..febabe33d64 100644 --- a/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/auth/HttpBasicAuth.mustache @@ -2,11 +2,12 @@ package {{invokerPackage}}.auth; import {{invokerPackage}}.Pair; +import com.migcomponents.migbase64.Base64; + import java.util.Map; import java.util.List; import java.io.UnsupportedEncodingException; -import javax.xml.bind.DatatypeConverter; {{>generatedAnnotation}} public class HttpBasicAuth implements Authentication { @@ -31,9 +32,12 @@ public class HttpBasicAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (username == null && password == null) { + return; + } String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); try { - headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8"))); + headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache index c8d2145bc6e..dbe0138aa54 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/jersey2/pom.mustache @@ -152,6 +152,13 @@ ${jodatime-version} + + + com.brsanthu + migbase64 + 2.2 + + junit diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache index f238c37fb47..8ce2407cbe3 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/ApiClient.mustache @@ -64,6 +64,38 @@ import {{invokerPackage}}.auth.ApiKeyAuth; import {{invokerPackage}}.auth.OAuth; public class ApiClient { + public static final double JAVA_VERSION; + public static final boolean IS_ANDROID; + public static final int ANDROID_SDK_VERSION; + + static { + JAVA_VERSION = Double.parseDouble(System.getProperty("java.specification.version")); + boolean isAndroid; + try { + Class.forName("android.app.Activity"); + isAndroid = true; + } catch (ClassNotFoundException e) { + isAndroid = false; + } + IS_ANDROID = isAndroid; + int sdkVersion = 0; + if (IS_ANDROID) { + try { + sdkVersion = Class.forName("android.os.Build$VERSION").getField("SDK_INT").getInt(null); + } catch (Exception e) { + try { + sdkVersion = Integer.parseInt((String) Class.forName("android.os.Build$VERSION").getField("SDK").get(null)); + } catch (Exception e2) { } + } + } + ANDROID_SDK_VERSION = sdkVersion; + } + + /** + * The datetime format to be used when lenientDatetimeFormat is enabled. + */ + public static final String LENIENT_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; + private String basePath = "{{basePath}}"; private boolean lenientOnJson = false; private boolean debugging = false; @@ -100,8 +132,7 @@ public class ApiClient { this.dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // Always use UTC as the default time zone when dealing with date (without time). this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - // Use the system's default time zone when dealing with datetime (mainly formatting). - this.datetimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + initDatetimeFormat(); // Be lenient on datetime formats when parsing datetime from string. // See parseDatetime. @@ -263,25 +294,30 @@ public class ApiClient { if (str == null) return null; + DateFormat format; if (lenientDatetimeFormat) { /* - * When lenientDatetimeFormat is enabled, process the given string - * to support various formats defined by ISO 8601. + * When lenientDatetimeFormat is enabled, normalize the date string + * into LENIENT_DATETIME_FORMAT to support various formats + * defined by ISO 8601. */ // normalize time zone - // trailing "Z": 2015-08-16T08:20:05Z => 2015-08-16T08:20:05+00:00 - str = str.replaceAll("[zZ]\\z", "+00:00"); - // add colon: 2015-08-16T08:20:05+0000 => 2015-08-16T08:20:05+00:00 - str = str.replaceAll("([+-]\\d{2})(\\d{2})\\z", "$1:$2"); - // expand time zone: 2015-08-16T08:20:05+00 => 2015-08-16T08:20:05+00:00 - str = str.replaceAll("([+-]\\d{2})\\z", "$1:00"); + // trailing "Z": 2015-08-16T08:20:05Z => 2015-08-16T08:20:05+0000 + str = str.replaceAll("[zZ]\\z", "+0000"); + // remove colon in time zone: 2015-08-16T08:20:05+00:00 => 2015-08-16T08:20:05+0000 + str = str.replaceAll("([+-]\\d{2}):(\\d{2})\\z", "$1$2"); + // expand time zone: 2015-08-16T08:20:05+00 => 2015-08-16T08:20:05+0000 + str = str.replaceAll("([+-]\\d{2})\\z", "$100"); // add milliseconds when missing - // 2015-08-16T08:20:05+00:00 => 2015-08-16T08:20:05.000+00:00 - str = str.replaceAll("(:\\d{1,2})([+-]\\d{2}:\\d{2})\\z", "$1.000$2"); + // 2015-08-16T08:20:05+0000 => 2015-08-16T08:20:05.000+0000 + str = str.replaceAll("(:\\d{1,2})([+-]\\d{4})\\z", "$1.000$2"); + format = new SimpleDateFormat(LENIENT_DATETIME_FORMAT); + } else { + format = this.datetimeFormat; } try { - return datetimeFormat.parse(str); + return format.parse(str); } catch (ParseException e) { throw new RuntimeException(e); } @@ -916,6 +952,31 @@ public class ApiClient { } } + /** + * Initialize datetime format according to the current environment, e.g. Java 1.7 and Android. + */ + private void initDatetimeFormat() { + String formatWithTimeZone = null; + if (IS_ANDROID) { + if (ANDROID_SDK_VERSION >= 18) { + // The time zone format "ZZZZZ" is available since Android 4.3 (SDK version 18) + formatWithTimeZone = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"; + } + } else if (JAVA_VERSION >= 1.7) { + // The time zone format "XXX" is available since Java 1.7 + formatWithTimeZone = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; + } + if (formatWithTimeZone != null) { + this.datetimeFormat = new SimpleDateFormat(formatWithTimeZone); + // NOTE: Use the system's default time zone (mainly for datetime formatting). + } else { + // Use a common format that works across all systems. + this.datetimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + // Always use the UTC time zone as we are using a constant trailing "Z" here. + this.datetimeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } + } + /** * Apply SSL related settings to httpClient according to the current values of * verifyingSsl and sslCaCert. diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/auth/HttpBasicAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/auth/HttpBasicAuth.mustache index 5b4070fcafb..f3ed85d980b 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/auth/HttpBasicAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/auth/HttpBasicAuth.mustache @@ -2,7 +2,7 @@ package {{invokerPackage}}.auth; import {{invokerPackage}}.Pair; -import com.migcomponents.migbase64.Base64; +import com.squareup.okhttp.Credentials; import java.util.Map; import java.util.List; @@ -31,11 +31,11 @@ public class HttpBasicAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { - String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - try { - headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false)); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); + if (username == null && password == null) { + return; } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); } } diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache index 67fc10e8323..0d7e9015101 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/pom.mustache @@ -122,11 +122,6 @@ gson ${gson-version} - - com.brsanthu - migbase64 - 2.2 - diff --git a/modules/swagger-codegen/src/main/resources/Java/pom.mustache b/modules/swagger-codegen/src/main/resources/Java/pom.mustache index 3f4d9d9a55b..c5bfbc65b74 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pom.mustache @@ -148,6 +148,13 @@ ${jodatime-version} + + + com.brsanthu + migbase64 + 2.2 + + junit diff --git a/modules/swagger-codegen/src/main/resources/clojure/api.mustache b/modules/swagger-codegen/src/main/resources/clojure/api.mustache index a4425280f1b..1acdf94d764 100644 --- a/modules/swagger-codegen/src/main/resources/clojure/api.mustache +++ b/modules/swagger-codegen/src/main/resources/clojure/api.mustache @@ -1,5 +1,5 @@ {{=< >=}}(ns . - (:require [.core :refer [call-api check-required-params]]) + (:require [.core :refer [call-api check-required-params]]) (:import (java.io File))) <#operations><#operation> (defn diff --git a/modules/swagger-codegen/src/main/resources/clojure/project.mustache b/modules/swagger-codegen/src/main/resources/clojure/project.mustache index c403c9c43c6..df83142e428 100644 --- a/modules/swagger-codegen/src/main/resources/clojure/project.mustache +++ b/modules/swagger-codegen/src/main/resources/clojure/project.mustache @@ -1,8 +1,8 @@ {{=< >=}}(defproject <&projectName> "<&projectVersion>" :description "<&projectDescription>"<#projectUrl> - :url "<&projectUrl>"<#licenseName> - :license {:name "<&licenseName>"<#licenseUrl> - :url "<&licenseUrl>"} + :url "<&projectUrl>"<#projectLicenseName> + :license {:name "<&projectLicenseName>"<#projectLicenseUrl> + :url "<&projectLicenseUrl>"} :dependencies [[org.clojure/clojure "1.7.0"] [clj-http "2.0.0"] [cheshire "5.5.0"]]) diff --git a/modules/swagger-codegen/src/main/resources/codegen/pom.mustache b/modules/swagger-codegen/src/main/resources/codegen/pom.mustache index 29a980a5091..30f1b14872c 100644 --- a/modules/swagger-codegen/src/main/resources/codegen/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/codegen/pom.mustache @@ -95,8 +95,8 @@ - 2.1.3 + {{swaggerCodegenVersion}} 1.0.0 4.8.1 - \ No newline at end of file + diff --git a/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache b/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache index 1a3291eeebd..38b67c3c40d 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/enumClass.mustache @@ -1,6 +1,6 @@ -public enum {{name}} { - {{#allowableValues}}{{#enumVars}} - [EnumMember("{{jsonname}}")] - {{name}}{{^-last}}, - {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}{{/allowableValues}} - } \ No newline at end of file +public enum {{datatypeWithEnum}} { + {{#allowableValues}}{{#enumVars}} + [EnumMember(Value = "{{jsonname}}")] + {{name}}{{^-last}}, + {{/-last}}{{#-last}}{{/-last}}{{/enumVars}}{{/allowableValues}} + } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/csharp/model.mustache b/modules/swagger-codegen/src/main/resources/csharp/model.mustache index 4c4c10be8a8..b4663b09452 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/model.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/model.mustache @@ -1,69 +1,119 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; {{#models}} {{#model}} -namespace {{packageName}}.Model { - - /// - /// {{description}} - /// - [DataContract] - public class {{classname}}{{#parent}} : {{{parent}}}{{/parent}} { +namespace {{packageName}}.Model +{ + /// + /// {{description}} + /// + [DataContract] + public class {{classname}} : IEquatable<{{classname}}>{{#parent}}, {{{parent}}}{{/parent}} + { {{#vars}}{{#isEnum}} + [JsonConverter(typeof(StringEnumConverter))] + {{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} + {{>enumClass}}{{/items}}{{/items.isEnum}}{{/vars}} {{#vars}}{{#isEnum}} - [JsonConverter(typeof(StringEnumConverter))] - {{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}} - - {{>enumClass}}{{/items}}{{/items.isEnum}} - - private {{{name}}} {{name}}; - - /// - /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} - /// {{#description}} - /// {{{description}}}{{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue=false)] - public {{{name}}} {{name}} { get; set; } - {{/vars}} - - {{#vars}}{{^isEnum}} - /// - /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} - /// {{#description}} - /// {{{description}}}{{/description}} - [DataMember(Name="{{baseName}}", EmitDefaultValue=false)] - public {{{datatype}}} {{name}} { get; set; } - + /// + /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + /// {{#description}} + /// {{{description}}}{{/description}} + [DataMember(Name="{{baseName}}", EmitDefaultValue=false)] + public {{{datatypeWithEnum}}} {{name}} { get; set; } + {{/isEnum}}{{/vars}}{{#vars}}{{^isEnum}} + /// + /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} + /// {{#description}} + /// {{{description}}}{{/description}} + [DataMember(Name="{{baseName}}", EmitDefaultValue=false)] + public {{{datatype}}} {{name}} { get; set; } {{/isEnum}}{{/vars}} + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class {{classname}} {\n"); + {{#vars}}sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); + {{/vars}} + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public {{#parent}} new {{/parent}}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 {{classname}}); + } + + /// + /// Returns true if {{classname}} instances are equal + /// + /// Instance of {{classname}} to be compared + /// Boolean + public bool Equals({{classname}} other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return {{#vars}}{{#isNotContainer}} + ( + this.{{name}} == other.{{name}} || + this.{{name}} != null && + this.{{name}}.Equals(other.{{name}}) + ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{^isNotContainer}} + ( + this.{{name}} == other.{{name}} || + this.{{name}} != null && + this.{{name}}.SequenceEqual(other.{{name}}) + ){{#hasMore}} && {{/hasMore}}{{/isNotContainer}}{{/vars}}; + } + + /// + /// 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 :) + {{#vars}} + if (this.{{name}} != null) + hash = hash * 57 + this.{{name}}.GetHashCode(); + {{/vars}} + return hash; + } + } - /// - /// Get the string presentation of the object - /// - /// String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class {{classname}} {\n"); - {{#vars}} - sb.Append(" {{name}}: ").Append({{name}}).Append("\n"); - {{/vars}} - sb.Append("}\n"); - return sb.ToString(); } - - /// - /// Get the JSON string presentation of the object - /// - /// JSON string presentation of the object - public {{#parent}} new {{/parent}}string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - -} {{/model}} {{/models}} } diff --git a/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache index bf1220912d2..1623721cc70 100644 --- a/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/perl/ApiClient.mustache @@ -317,14 +317,28 @@ sub update_params_for_auth { foreach my $auth (@$auth_settings) { # determine which one to use if (!defined($auth)) { + # TODO show warning about auth setting not defined } {{#authMethods}}elsif ($auth eq '{{name}}') { - {{#isApiKey}}{{#isKeyInHeader}}$header_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInHeader}}{{#isKeyInQuery}}$query_params->{'{{keyParamName}}'} = $self->get_api_key_with_prefix('{{keyParamName}}');{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}$header_params->{'Authorization'} = 'Basic '.encode_base64($WWW::{{moduleName}}::Configuration::username.":".$WWW::{{moduleName}}::Configuration::password);{{/isBasic}} - {{#isOAuth}}$header_params->{'Authorization'} = 'Bearer ' . $WWW::{{moduleName}}::Configuration::access_token;{{/isOAuth}} + {{#isApiKey}}{{#isKeyInHeader}} + my $api_key = $self->get_api_key_with_prefix('{{keyParamName}}'); + if ($api_key) { + $header_params->{'{{keyParamName}}'} = $api_key; + }{{/isKeyInHeader}}{{#isKeyInQuery}} + my $api_key = $self->get_api_key_with_prefix('{{keyParamName}}'); + if ($api_key) { + $query_params->{'{{keyParamName}}'} = $api_key; + }{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}} + if ($WWW::{{moduleName}}::Configuration::username || $WWW::{{moduleName}}::Configuration::password) { + $header_params->{'Authorization'} = 'Basic ' . encode_base64($WWW::{{moduleName}}::Configuration::username . ":" . $WWW::{{moduleName}}::Configuration::password); + }{{/isBasic}}{{#isOAuth}} + if ($WWW::{{moduleName}}::Configuration::access_token) { + $header_params->{'Authorization'} = 'Bearer ' . $WWW::{{moduleName}}::Configuration::access_token; + }{{/isOAuth}} } {{/authMethods}} else { - # TODO show warning about security definition not found + # TODO show warning about security definition not found } } } diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index e3a9749c423..53a81030813 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -166,12 +166,18 @@ use \{{invokerPackage}}\ObjectSerializer; $httpBody = $formParams; // for HTTP post (form) } {{#authMethods}}{{#isApiKey}} + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('{{keyParamName}}'); - if (isset($apiKey)) { + if ($apiKey !== null) { {{#isKeyInHeader}}$headerParams['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}} }{{/isApiKey}} - {{#isBasic}}$headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword());{{/isBasic}} - {{#isOAuth}}$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();{{/isOAuth}} + {{#isBasic}}// this endpoint requires HTTP basic authentication + if ($this->apiClient->getConfig()->getUsername() !== null or $this->apiClient->getConfig()->getPassword() !== null) { + $headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword()); + }{{/isBasic}}{{#isOAuth}}// this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + }{{/isOAuth}} {{/authMethods}} // make the API Call try 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 969eb4e7992..d097ec4536d 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -453,7 +453,9 @@ class ApiClient(object): for auth in auth_settings: auth_setting = config.auth_settings().get(auth) if auth_setting: - if auth_setting['in'] == 'header': + if not auth_setting['value']: + continue + elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys[auth_setting['key']] = auth_setting['value'] diff --git a/pom.xml b/pom.xml index e6d319c42d7..ada3dc0dc4a 100644 --- a/pom.xml +++ b/pom.xml @@ -305,6 +305,18 @@ samples/client/petstore/android-java + + clojure-client + + + env + clojure + + + + samples/client/petstore/clojure + + java-client @@ -435,6 +447,7 @@ samples/client/petstore/android-java + samples/client/petstore/clojure samples/client/petstore/java/default samples/client/petstore/java/jersey2 samples/client/petstore/java/okhttp-gson diff --git a/samples/client/petstore/clojure/.gitignore b/samples/client/petstore/clojure/.gitignore index c53038ec0e3..055b6ac4772 100644 --- a/samples/client/petstore/clojure/.gitignore +++ b/samples/client/petstore/clojure/.gitignore @@ -1,7 +1,6 @@ /target /classes /checkouts -pom.xml pom.xml.asc *.jar *.class diff --git a/samples/client/petstore/clojure/pom.xml b/samples/client/petstore/clojure/pom.xml new file mode 100644 index 00000000000..a36506d1b90 --- /dev/null +++ b/samples/client/petstore/clojure/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + io.swagger + swagger-petstore-clojure + pom + 1.0-SNAPSHOT + Swagger Petstore - Clojure Client + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + lein-test + integration-test + + exec + + + lein + + test + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs index 0a952d64b20..3813bde45f0 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs @@ -1,77 +1,114 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; -namespace IO.Swagger.Model { - - /// - /// - /// - [DataContract] - public class Category { +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public class Category : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { 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 Category {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } - private Id Id; + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public Id Id { get; set; } - - - private Name Name; + /// + /// 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 Category); + } - /// - /// Gets or Sets Name - /// - [DataMember(Name="name", EmitDefaultValue=false)] - public Name Name { get; set; } - + /// + /// Returns true if Category instances are equal + /// + /// Instance of Category to be compared + /// Boolean + public bool Equals(Category other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; - - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } + return + ( + this.Id == other.Id || + this.Id != null && + this.Id.Equals(other.Id) + ) && + ( + this.Name == other.Name || + this.Name != null && + this.Name.Equals(other.Name) + ); + } - - /// - /// Gets or Sets Name - /// - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } + /// + /// 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.Id != null) + hash = hash * 57 + this.Id.GetHashCode(); + + if (this.Name != null) + hash = hash * 57 + this.Name.GetHashCode(); + + return hash; + } + } - - - /// - /// Get the string presentation of the object - /// - /// String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Category {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Name: ").Append(Name).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); } - - /// - /// Get the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - -} } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs index bb81552664e..54ce43ab83f 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs @@ -1,163 +1,187 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; -namespace IO.Swagger.Model { - - /// - /// - /// - [DataContract] - public class Order { - - - private Id Id; - +namespace IO.Swagger.Model +{ /// - /// Gets or Sets Id + /// /// - [DataMember(Name="id", EmitDefaultValue=false)] - public Id Id { get; set; } + [DataContract] + public class Order : IEquatable + { + [JsonConverter(typeof(StringEnumConverter))] + public enum StatusEnum { + + [EnumMember(Value = "placed")] + Placed, + + [EnumMember(Value = "approved")] + Approved, + + [EnumMember(Value = "delivered")] + Delivered + } + /// + /// Order Status + /// + /// Order Status + [DataMember(Name="status", EmitDefaultValue=false)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets PetId + /// + [DataMember(Name="petId", EmitDefaultValue=false)] + public long? PetId { get; set; } + + /// + /// Gets or Sets Quantity + /// + [DataMember(Name="quantity", EmitDefaultValue=false)] + public int? Quantity { get; set; } + + /// + /// Gets or Sets ShipDate + /// + [DataMember(Name="shipDate", EmitDefaultValue=false)] + public DateTime? ShipDate { get; set; } + + /// + /// Gets or Sets Complete + /// + [DataMember(Name="complete", EmitDefaultValue=false)] + public bool? Complete { 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 Order {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" PetId: ").Append(PetId).Append("\n"); + sb.Append(" Quantity: ").Append(Quantity).Append("\n"); + sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + sb.Append(" Complete: ").Append(Complete).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } - private PetId PetId; + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } - /// - /// Gets or Sets PetId - /// - [DataMember(Name="petId", EmitDefaultValue=false)] - public PetId PetId { get; set; } - - - private Quantity Quantity; + /// + /// 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 Order); + } - /// - /// Gets or Sets Quantity - /// - [DataMember(Name="quantity", EmitDefaultValue=false)] - public Quantity Quantity { get; set; } - - - private ShipDate ShipDate; + /// + /// Returns true if Order instances are equal + /// + /// Instance of Order to be compared + /// Boolean + public bool Equals(Order other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.Id == other.Id || + this.Id != null && + this.Id.Equals(other.Id) + ) && + ( + this.PetId == other.PetId || + this.PetId != null && + this.PetId.Equals(other.PetId) + ) && + ( + this.Quantity == other.Quantity || + this.Quantity != null && + this.Quantity.Equals(other.Quantity) + ) && + ( + this.ShipDate == other.ShipDate || + this.ShipDate != null && + this.ShipDate.Equals(other.ShipDate) + ) && + ( + this.Status == other.Status || + this.Status != null && + this.Status.Equals(other.Status) + ) && + ( + this.Complete == other.Complete || + this.Complete != null && + this.Complete.Equals(other.Complete) + ); + } + + /// + /// 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.Id != null) + hash = hash * 57 + this.Id.GetHashCode(); + + if (this.PetId != null) + hash = hash * 57 + this.PetId.GetHashCode(); + + if (this.Quantity != null) + hash = hash * 57 + this.Quantity.GetHashCode(); + + if (this.ShipDate != null) + hash = hash * 57 + this.ShipDate.GetHashCode(); + + if (this.Status != null) + hash = hash * 57 + this.Status.GetHashCode(); + + if (this.Complete != null) + hash = hash * 57 + this.Complete.GetHashCode(); + + return hash; + } + } - /// - /// Gets or Sets ShipDate - /// - [DataMember(Name="shipDate", EmitDefaultValue=false)] - public ShipDate ShipDate { get; set; } - - [JsonConverter(typeof(StringEnumConverter))] - public enum Status { - - [EnumMember("placed")] - Placed, - - [EnumMember("approved")] - Approved, - - [EnumMember("delivered")] - Delivered } - - private Status Status; - - /// - /// Order Status - /// - /// Order Status - [DataMember(Name="status", EmitDefaultValue=false)] - public Status Status { get; set; } - - - private Complete Complete; - - /// - /// Gets or Sets Complete - /// - [DataMember(Name="complete", EmitDefaultValue=false)] - public Complete Complete { get; set; } - - - - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - /// - /// Gets or Sets PetId - /// - [DataMember(Name="petId", EmitDefaultValue=false)] - public long? PetId { get; set; } - - - /// - /// Gets or Sets Quantity - /// - [DataMember(Name="quantity", EmitDefaultValue=false)] - public int? Quantity { get; set; } - - - /// - /// Gets or Sets ShipDate - /// - [DataMember(Name="shipDate", EmitDefaultValue=false)] - public DateTime? ShipDate { get; set; } - - - /// - /// Order Status - /// - /// Order Status - [DataMember(Name="status", EmitDefaultValue=false)] - public string Status { get; set; } - - - /// - /// Gets or Sets Complete - /// - [DataMember(Name="complete", EmitDefaultValue=false)] - public bool? Complete { get; set; } - - - - /// - /// Get the string presentation of the object - /// - /// String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Order {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" PetId: ").Append(PetId).Append("\n"); - - sb.Append(" Quantity: ").Append(Quantity).Append("\n"); - - sb.Append(" ShipDate: ").Append(ShipDate).Append("\n"); - - sb.Append(" Status: ").Append(Status).Append("\n"); - - sb.Append(" Complete: ").Append(Complete).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Get the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - -} } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs index ca5ddc5bb51..f3987aa5286 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs @@ -1,163 +1,187 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; -namespace IO.Swagger.Model { - - /// - /// - /// - [DataContract] - public class Pet { - - - private Id Id; - +namespace IO.Swagger.Model +{ /// - /// Gets or Sets Id + /// /// - [DataMember(Name="id", EmitDefaultValue=false)] - public Id Id { get; set; } + [DataContract] + public class Pet : IEquatable + { + [JsonConverter(typeof(StringEnumConverter))] + public enum StatusEnum { + + [EnumMember(Value = "available")] + Available, + + [EnumMember(Value = "pending")] + Pending, + + [EnumMember(Value = "sold")] + Sold + } + /// + /// pet status in the store + /// + /// pet status in the store + [DataMember(Name="status", EmitDefaultValue=false)] + public StatusEnum Status { get; set; } + + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Category + /// + [DataMember(Name="category", EmitDefaultValue=false)] + public Category Category { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { get; set; } + + /// + /// Gets or Sets PhotoUrls + /// + [DataMember(Name="photoUrls", EmitDefaultValue=false)] + public List PhotoUrls { get; set; } + + /// + /// Gets or Sets Tags + /// + [DataMember(Name="tags", EmitDefaultValue=false)] + public List Tags { 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 Pet {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Category: ").Append(Category).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); + sb.Append(" Tags: ").Append(Tags).Append("\n"); + sb.Append(" Status: ").Append(Status).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } - private Category Category; + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } - /// - /// Gets or Sets Category - /// - [DataMember(Name="category", EmitDefaultValue=false)] - public Category Category { get; set; } - - - private Name Name; + /// + /// 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 Pet); + } - /// - /// Gets or Sets Name - /// - [DataMember(Name="name", EmitDefaultValue=false)] - public Name Name { get; set; } - - - private PhotoUrls PhotoUrls; + /// + /// Returns true if Pet instances are equal + /// + /// Instance of Pet to be compared + /// Boolean + public bool Equals(Pet other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; - /// - /// Gets or Sets PhotoUrls - /// - [DataMember(Name="photoUrls", EmitDefaultValue=false)] - public PhotoUrls PhotoUrls { get; set; } - - - private Tags Tags; + return + ( + this.Id == other.Id || + this.Id != null && + this.Id.Equals(other.Id) + ) && + ( + this.Category == other.Category || + this.Category != null && + this.Category.Equals(other.Category) + ) && + ( + this.Name == other.Name || + this.Name != null && + this.Name.Equals(other.Name) + ) && + ( + this.PhotoUrls == other.PhotoUrls || + this.PhotoUrls != null && + this.PhotoUrls.SequenceEqual(other.PhotoUrls) + ) && + ( + this.Tags == other.Tags || + this.Tags != null && + this.Tags.SequenceEqual(other.Tags) + ) && + ( + this.Status == other.Status || + this.Status != null && + this.Status.Equals(other.Status) + ); + } + + /// + /// 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.Id != null) + hash = hash * 57 + this.Id.GetHashCode(); + + if (this.Category != null) + hash = hash * 57 + this.Category.GetHashCode(); + + if (this.Name != null) + hash = hash * 57 + this.Name.GetHashCode(); + + if (this.PhotoUrls != null) + hash = hash * 57 + this.PhotoUrls.GetHashCode(); + + if (this.Tags != null) + hash = hash * 57 + this.Tags.GetHashCode(); + + if (this.Status != null) + hash = hash * 57 + this.Status.GetHashCode(); + + return hash; + } + } - /// - /// Gets or Sets Tags - /// - [DataMember(Name="tags", EmitDefaultValue=false)] - public Tags Tags { get; set; } - - [JsonConverter(typeof(StringEnumConverter))] - public enum Status { - - [EnumMember("available")] - Available, - - [EnumMember("pending")] - Pending, - - [EnumMember("sold")] - Sold } - - private Status Status; - - /// - /// pet status in the store - /// - /// pet status in the store - [DataMember(Name="status", EmitDefaultValue=false)] - public Status Status { get; set; } - - - - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - /// - /// Gets or Sets Category - /// - [DataMember(Name="category", EmitDefaultValue=false)] - public Category Category { get; set; } - - - /// - /// Gets or Sets Name - /// - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } - - - /// - /// Gets or Sets PhotoUrls - /// - [DataMember(Name="photoUrls", EmitDefaultValue=false)] - public List PhotoUrls { get; set; } - - - /// - /// Gets or Sets Tags - /// - [DataMember(Name="tags", EmitDefaultValue=false)] - public List Tags { get; set; } - - - /// - /// pet status in the store - /// - /// pet status in the store - [DataMember(Name="status", EmitDefaultValue=false)] - public string Status { get; set; } - - - - /// - /// Get the string presentation of the object - /// - /// String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Pet {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Category: ").Append(Category).Append("\n"); - - sb.Append(" Name: ").Append(Name).Append("\n"); - - sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n"); - - sb.Append(" Tags: ").Append(Tags).Append("\n"); - - sb.Append(" Status: ").Append(Status).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Get the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - -} } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs index 0bef44dfb89..3553578a083 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs @@ -1,77 +1,114 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; -namespace IO.Swagger.Model { - - /// - /// - /// - [DataContract] - public class Tag { +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public class Tag : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Name + /// + [DataMember(Name="name", EmitDefaultValue=false)] + public string Name { 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 Tag {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Name: ").Append(Name).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } - private Id Id; + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public Id Id { get; set; } - - - private Name Name; + /// + /// 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 Tag); + } - /// - /// Gets or Sets Name - /// - [DataMember(Name="name", EmitDefaultValue=false)] - public Name Name { get; set; } - + /// + /// Returns true if Tag instances are equal + /// + /// Instance of Tag to be compared + /// Boolean + public bool Equals(Tag other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; - - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } + return + ( + this.Id == other.Id || + this.Id != null && + this.Id.Equals(other.Id) + ) && + ( + this.Name == other.Name || + this.Name != null && + this.Name.Equals(other.Name) + ); + } - - /// - /// Gets or Sets Name - /// - [DataMember(Name="name", EmitDefaultValue=false)] - public string Name { get; set; } + /// + /// 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.Id != null) + hash = hash * 57 + this.Id.GetHashCode(); + + if (this.Name != null) + hash = hash * 57 + this.Name.GetHashCode(); + + return hash; + } + } - - - /// - /// Get the string presentation of the object - /// - /// String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class Tag {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Name: ").Append(Name).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); } - - /// - /// Get the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - -} } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs index d2bbf071d9c..bfd2ffc411e 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs @@ -1,187 +1,205 @@ using System; +using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; -namespace IO.Swagger.Model { - - /// - /// - /// - [DataContract] - public class User { +namespace IO.Swagger.Model +{ + /// + /// + /// + [DataContract] + public class User : IEquatable + { + /// + /// Gets or Sets Id + /// + [DataMember(Name="id", EmitDefaultValue=false)] + public long? Id { get; set; } + + /// + /// Gets or Sets Username + /// + [DataMember(Name="username", EmitDefaultValue=false)] + public string Username { get; set; } + + /// + /// Gets or Sets FirstName + /// + [DataMember(Name="firstName", EmitDefaultValue=false)] + public string FirstName { get; set; } + + /// + /// Gets or Sets LastName + /// + [DataMember(Name="lastName", EmitDefaultValue=false)] + public string LastName { get; set; } + + /// + /// Gets or Sets Email + /// + [DataMember(Name="email", EmitDefaultValue=false)] + public string Email { get; set; } + + /// + /// Gets or Sets Password + /// + [DataMember(Name="password", EmitDefaultValue=false)] + public string Password { get; set; } + + /// + /// Gets or Sets Phone + /// + [DataMember(Name="phone", EmitDefaultValue=false)] + public string Phone { get; set; } + + /// + /// User Status + /// + /// User Status + [DataMember(Name="userStatus", EmitDefaultValue=false)] + public int? UserStatus { 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 User {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" Username: ").Append(Username).Append("\n"); + sb.Append(" FirstName: ").Append(FirstName).Append("\n"); + sb.Append(" LastName: ").Append(LastName).Append("\n"); + sb.Append(" Email: ").Append(Email).Append("\n"); + sb.Append(" Password: ").Append(Password).Append("\n"); + sb.Append(" Phone: ").Append(Phone).Append("\n"); + sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); + + sb.Append("}\n"); + return sb.ToString(); + } - private Id Id; + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public Id Id { get; set; } - - - private Username Username; + /// + /// 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 User); + } - /// - /// Gets or Sets Username - /// - [DataMember(Name="username", EmitDefaultValue=false)] - public Username Username { get; set; } - - - private FirstName FirstName; + /// + /// Returns true if User instances are equal + /// + /// Instance of User to be compared + /// Boolean + public bool Equals(User other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; - /// - /// Gets or Sets FirstName - /// - [DataMember(Name="firstName", EmitDefaultValue=false)] - public FirstName FirstName { get; set; } - - - private LastName LastName; + return + ( + this.Id == other.Id || + this.Id != null && + this.Id.Equals(other.Id) + ) && + ( + this.Username == other.Username || + this.Username != null && + this.Username.Equals(other.Username) + ) && + ( + this.FirstName == other.FirstName || + this.FirstName != null && + this.FirstName.Equals(other.FirstName) + ) && + ( + this.LastName == other.LastName || + this.LastName != null && + this.LastName.Equals(other.LastName) + ) && + ( + this.Email == other.Email || + this.Email != null && + this.Email.Equals(other.Email) + ) && + ( + this.Password == other.Password || + this.Password != null && + this.Password.Equals(other.Password) + ) && + ( + this.Phone == other.Phone || + this.Phone != null && + this.Phone.Equals(other.Phone) + ) && + ( + this.UserStatus == other.UserStatus || + this.UserStatus != null && + this.UserStatus.Equals(other.UserStatus) + ); + } - /// - /// Gets or Sets LastName - /// - [DataMember(Name="lastName", EmitDefaultValue=false)] - public LastName LastName { get; set; } - - - private Email Email; + /// + /// 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.Id != null) + hash = hash * 57 + this.Id.GetHashCode(); + + if (this.Username != null) + hash = hash * 57 + this.Username.GetHashCode(); + + if (this.FirstName != null) + hash = hash * 57 + this.FirstName.GetHashCode(); + + if (this.LastName != null) + hash = hash * 57 + this.LastName.GetHashCode(); + + if (this.Email != null) + hash = hash * 57 + this.Email.GetHashCode(); + + if (this.Password != null) + hash = hash * 57 + this.Password.GetHashCode(); + + if (this.Phone != null) + hash = hash * 57 + this.Phone.GetHashCode(); + + if (this.UserStatus != null) + hash = hash * 57 + this.UserStatus.GetHashCode(); + + return hash; + } + } - /// - /// Gets or Sets Email - /// - [DataMember(Name="email", EmitDefaultValue=false)] - public Email Email { get; set; } - - - private Password Password; - - /// - /// Gets or Sets Password - /// - [DataMember(Name="password", EmitDefaultValue=false)] - public Password Password { get; set; } - - - private Phone Phone; - - /// - /// Gets or Sets Phone - /// - [DataMember(Name="phone", EmitDefaultValue=false)] - public Phone Phone { get; set; } - - - private UserStatus UserStatus; - - /// - /// User Status - /// - /// User Status - [DataMember(Name="userStatus", EmitDefaultValue=false)] - public UserStatus UserStatus { get; set; } - - - - /// - /// Gets or Sets Id - /// - [DataMember(Name="id", EmitDefaultValue=false)] - public long? Id { get; set; } - - - /// - /// Gets or Sets Username - /// - [DataMember(Name="username", EmitDefaultValue=false)] - public string Username { get; set; } - - - /// - /// Gets or Sets FirstName - /// - [DataMember(Name="firstName", EmitDefaultValue=false)] - public string FirstName { get; set; } - - - /// - /// Gets or Sets LastName - /// - [DataMember(Name="lastName", EmitDefaultValue=false)] - public string LastName { get; set; } - - - /// - /// Gets or Sets Email - /// - [DataMember(Name="email", EmitDefaultValue=false)] - public string Email { get; set; } - - - /// - /// Gets or Sets Password - /// - [DataMember(Name="password", EmitDefaultValue=false)] - public string Password { get; set; } - - - /// - /// Gets or Sets Phone - /// - [DataMember(Name="phone", EmitDefaultValue=false)] - public string Phone { get; set; } - - - /// - /// User Status - /// - /// User Status - [DataMember(Name="userStatus", EmitDefaultValue=false)] - public int? UserStatus { get; set; } - - - - /// - /// Get the string presentation of the object - /// - /// String presentation of the object - public override string ToString() { - var sb = new StringBuilder(); - sb.Append("class User {\n"); - - sb.Append(" Id: ").Append(Id).Append("\n"); - - sb.Append(" Username: ").Append(Username).Append("\n"); - - sb.Append(" FirstName: ").Append(FirstName).Append("\n"); - - sb.Append(" LastName: ").Append(LastName).Append("\n"); - - sb.Append(" Email: ").Append(Email).Append("\n"); - - sb.Append(" Password: ").Append(Password).Append("\n"); - - sb.Append(" Phone: ").Append(Phone).Append("\n"); - - sb.Append(" UserStatus: ").Append(UserStatus).Append("\n"); - - sb.Append("}\n"); - return sb.ToString(); } - - /// - /// Get the JSON string presentation of the object - /// - /// JSON string presentation of the object - public string ToJson() { - return JsonConvert.SerializeObject(this, Formatting.Indented); - } - -} } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index 31e5cba141b..05585bff932 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,8 +2,25 @@ - + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index 5a42b8703c2..0227a2d9113 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -1,5 +1,6 @@ using NUnit.Framework; using System; +using System.Linq; using System.IO; using System.Collections.Generic; using IO.Swagger.Api; @@ -144,6 +145,68 @@ namespace SwaggerClient.TestPet } + [Test ()] + public void TestEqual() + { + // create pet + Pet p1 = new Pet(); + p1.Id = petId; + p1.Name = "Csharp test"; + p1.Status = "available"; + // create Category object + Category category1 = new Category(); + category1.Id = 56; + category1.Name = "sample category name2"; + List photoUrls1 = new List(new String[] {"sample photoUrls"}); + // create Tag object + Tag tag1 = new Tag(); + tag1.Id = petId; + tag1.Name = "sample tag name1"; + List tags1 = new List(new Tag[] {tag1}); + p1.Tags = tags1; + p1.Category = category1; + p1.PhotoUrls = photoUrls1; + + // create pet 2 + Pet p2 = new Pet(); + p2.Id = petId; + p2.Name = "Csharp test"; + p2.Status = "available"; + // create Category object + Category category2 = new Category(); + category2.Id = 56; + category2.Name = "sample category name2"; + List photoUrls2 = new List(new String[] {"sample photoUrls"}); + // create Tag object + Tag tag2 = new Tag(); + tag2.Id = petId; + tag2.Name = "sample tag name1"; + List tags2 = new List(new Tag[] {tag2}); + p2.Tags = tags2; + p2.Category = category2; + p2.PhotoUrls = photoUrls2; + + // p1 and p2 should be equal (both object and attribute level) + Assert.IsTrue (category1.Equals (category2)); + Assert.IsTrue (tags1.SequenceEqual (tags2)); + Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls)); + + Assert.IsTrue (p1.Equals (p2)); + + // update attribute to that p1 and p2 are not equal + category2.Name = "new category name"; + Assert.IsFalse(category1.Equals (category2)); + + tags2 = new List (); + Assert.IsFalse (tags1.SequenceEqual (tags2)); + + // photoUrls has not changed so it should be equal + Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls)); + + Assert.IsFalse (p1.Equals (p2)); + + } + } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index c975e54d4be..924934c4623 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb index 5c1092d07fc..d0d7f1b3ccf 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt index 3ed0e98c4f7..b46eed9f9d6 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt +++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt @@ -1,8 +1,8 @@ -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index c975e54d4be..924934c4623 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb index 5c1092d07fc..d0d7f1b3ccf 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb differ diff --git a/samples/client/petstore/java/default/pom.xml b/samples/client/petstore/java/default/pom.xml index 894e318b5f3..8a939b9dc34 100644 --- a/samples/client/petstore/java/default/pom.xml +++ b/samples/client/petstore/java/default/pom.xml @@ -148,6 +148,13 @@ ${jodatime-version} + + + com.brsanthu + migbase64 + 2.2 + + junit diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index 194935b09e7..0011210c8cc 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-19T13:52:16.052+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-20T17:28:23.285+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; @@ -44,6 +44,9 @@ public class ApiKeyAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (apiKey == null) { + return; + } String value; if (apiKeyPrefix != null) { value = apiKeyPrefix + " " + apiKey; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index f731e1ac79d..8c2aa444678 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -2,13 +2,14 @@ package io.swagger.client.auth; import io.swagger.client.Pair; +import com.migcomponents.migbase64.Base64; + import java.util.Map; import java.util.List; import java.io.UnsupportedEncodingException; -import javax.xml.bind.DatatypeConverter; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-19T13:52:16.052+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-22T13:15:32.345+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; @@ -31,9 +32,12 @@ public class HttpBasicAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (username == null && password == null) { + return; + } String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); try { - headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8"))); + headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } diff --git a/samples/client/petstore/java/jersey2/pom.xml b/samples/client/petstore/java/jersey2/pom.xml index e5353a66ea5..0881cc29374 100644 --- a/samples/client/petstore/java/jersey2/pom.xml +++ b/samples/client/petstore/java/jersey2/pom.xml @@ -152,6 +152,13 @@ ${jodatime-version} + + + com.brsanthu + migbase64 + 2.2 + + junit diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index d7d3d3e63b0..bc3bdaefc44 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-20T17:28:47.318+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; @@ -44,6 +44,9 @@ public class ApiKeyAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (apiKey == null) { + return; + } String value; if (apiKeyPrefix != null) { value = apiKeyPrefix + " " + apiKey; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index 390502ab9e5..071139d656a 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -2,13 +2,14 @@ package io.swagger.client.auth; import io.swagger.client.Pair; +import com.migcomponents.migbase64.Base64; + import java.util.Map; import java.util.List; import java.io.UnsupportedEncodingException; -import javax.xml.bind.DatatypeConverter; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-17T11:17:50.535-05:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-22T13:15:27.225+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; @@ -31,9 +32,12 @@ public class HttpBasicAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (username == null && password == null) { + return; + } String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); try { - headerParams.put("Authorization", "Basic " + DatatypeConverter.printBase64Binary(str.getBytes("UTF-8"))); + headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false)); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } diff --git a/samples/client/petstore/java/okhttp-gson/pom.xml b/samples/client/petstore/java/okhttp-gson/pom.xml index 2442e1c318e..9fa057be939 100644 --- a/samples/client/petstore/java/okhttp-gson/pom.xml +++ b/samples/client/petstore/java/okhttp-gson/pom.xml @@ -122,11 +122,6 @@ gson ${gson-version} - - com.brsanthu - migbase64 - 2.2 - diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 51c3d5464f2..6e4e299ad3a 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -64,6 +64,38 @@ import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; public class ApiClient { + public static final double JAVA_VERSION; + public static final boolean IS_ANDROID; + public static final int ANDROID_SDK_VERSION; + + static { + JAVA_VERSION = Double.parseDouble(System.getProperty("java.specification.version")); + boolean isAndroid; + try { + Class.forName("android.app.Activity"); + isAndroid = true; + } catch (ClassNotFoundException e) { + isAndroid = false; + } + IS_ANDROID = isAndroid; + int sdkVersion = 0; + if (IS_ANDROID) { + try { + sdkVersion = Class.forName("android.os.Build$VERSION").getField("SDK_INT").getInt(null); + } catch (Exception e) { + try { + sdkVersion = Integer.parseInt((String) Class.forName("android.os.Build$VERSION").getField("SDK").get(null)); + } catch (Exception e2) { } + } + } + ANDROID_SDK_VERSION = sdkVersion; + } + + /** + * The datetime format to be used when lenientDatetimeFormat is enabled. + */ + public static final String LENIENT_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; + private String basePath = "http://petstore.swagger.io/v2"; private boolean lenientOnJson = false; private boolean debugging = false; @@ -100,8 +132,7 @@ public class ApiClient { this.dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // Always use UTC as the default time zone when dealing with date (without time). this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - // Use the system's default time zone when dealing with datetime (mainly formatting). - this.datetimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); + initDatetimeFormat(); // Be lenient on datetime formats when parsing datetime from string. // See parseDatetime. @@ -262,25 +293,30 @@ public class ApiClient { if (str == null) return null; + DateFormat format; if (lenientDatetimeFormat) { /* - * When lenientDatetimeFormat is enabled, process the given string - * to support various formats defined by ISO 8601. + * When lenientDatetimeFormat is enabled, normalize the date string + * into LENIENT_DATETIME_FORMAT to support various formats + * defined by ISO 8601. */ // normalize time zone - // trailing "Z": 2015-08-16T08:20:05Z => 2015-08-16T08:20:05+00:00 - str = str.replaceAll("[zZ]\\z", "+00:00"); - // add colon: 2015-08-16T08:20:05+0000 => 2015-08-16T08:20:05+00:00 - str = str.replaceAll("([+-]\\d{2})(\\d{2})\\z", "$1:$2"); - // expand time zone: 2015-08-16T08:20:05+00 => 2015-08-16T08:20:05+00:00 - str = str.replaceAll("([+-]\\d{2})\\z", "$1:00"); + // trailing "Z": 2015-08-16T08:20:05Z => 2015-08-16T08:20:05+0000 + str = str.replaceAll("[zZ]\\z", "+0000"); + // remove colon in time zone: 2015-08-16T08:20:05+00:00 => 2015-08-16T08:20:05+0000 + str = str.replaceAll("([+-]\\d{2}):(\\d{2})\\z", "$1$2"); + // expand time zone: 2015-08-16T08:20:05+00 => 2015-08-16T08:20:05+0000 + str = str.replaceAll("([+-]\\d{2})\\z", "$100"); // add milliseconds when missing - // 2015-08-16T08:20:05+00:00 => 2015-08-16T08:20:05.000+00:00 - str = str.replaceAll("(:\\d{1,2})([+-]\\d{2}:\\d{2})\\z", "$1.000$2"); + // 2015-08-16T08:20:05+0000 => 2015-08-16T08:20:05.000+0000 + str = str.replaceAll("(:\\d{1,2})([+-]\\d{4})\\z", "$1.000$2"); + format = new SimpleDateFormat(LENIENT_DATETIME_FORMAT); + } else { + format = this.datetimeFormat; } try { - return datetimeFormat.parse(str); + return format.parse(str); } catch (ParseException e) { throw new RuntimeException(e); } @@ -915,6 +951,31 @@ public class ApiClient { } } + /** + * Initialize datetime format according to the current environment, e.g. Java 1.7 and Android. + */ + private void initDatetimeFormat() { + String formatWithTimeZone = null; + if (IS_ANDROID) { + if (ANDROID_SDK_VERSION >= 18) { + // The time zone format "ZZZZZ" is available since Android 4.3 (SDK version 18) + formatWithTimeZone = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"; + } + } else if (JAVA_VERSION >= 1.7) { + // The time zone format "XXX" is available since Java 1.7 + formatWithTimeZone = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX"; + } + if (formatWithTimeZone != null) { + this.datetimeFormat = new SimpleDateFormat(formatWithTimeZone); + // NOTE: Use the system's default time zone (mainly for datetime formatting). + } else { + // Use a common format that works across all systems. + this.datetimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + // Always use the UTC time zone as we are using a constant trailing "Z" here. + this.datetimeFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + } + } + /** * Apply SSL related settings to httpClient according to the current values of * verifyingSsl and sslCaCert. diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java index c072321f457..fbfda66f881 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/ApiKeyAuth.java @@ -5,7 +5,7 @@ import io.swagger.client.Pair; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T11:42:25.339-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-20T17:28:54.086+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; @@ -44,6 +44,9 @@ public class ApiKeyAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { + if (apiKey == null) { + return; + } String value; if (apiKeyPrefix != null) { value = apiKeyPrefix + " " + apiKey; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/HttpBasicAuth.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/HttpBasicAuth.java index d2b56433169..6ed16d1db30 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/HttpBasicAuth.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/auth/HttpBasicAuth.java @@ -2,7 +2,7 @@ package io.swagger.client.auth; import io.swagger.client.Pair; -import com.migcomponents.migbase64.Base64; +import com.squareup.okhttp.Credentials; import java.util.Map; import java.util.List; @@ -31,11 +31,11 @@ public class HttpBasicAuth implements Authentication { @Override public void applyToParams(List queryParams, Map headerParams) { - String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - try { - headerParams.put("Authorization", "Basic " + Base64.encodeToString(str.getBytes("UTF-8"), false)); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); + if (username == null && password == null) { + return; } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); } } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java index 5bdb4fb78fb..3715e9724e6 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/ApiKeyAuthTest.java @@ -29,9 +29,23 @@ public class ApiKeyAuthTest { assertEquals(0, headerParams.size()); } + @Test + public void testApplyToParamsInQueryWithNullValue() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("query", "api_key"); + auth.setApiKey(null); + auth.applyToParams(queryParams, headerParams); + + // no changes to parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); + } + @Test public void testApplyToParamsInHeaderWithPrefix() { - List queryParams = new ArrayList(); + List queryParams = new ArrayList(); Map headerParams = new HashMap(); ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); @@ -44,4 +58,19 @@ public class ApiKeyAuthTest { assertEquals(1, headerParams.size()); assertEquals("Token my-api-token", headerParams.get("X-API-TOKEN")); } + + @Test + public void testApplyToParamsInHeaderWithNullValue() { + List queryParams = new ArrayList(); + Map headerParams = new HashMap(); + + ApiKeyAuth auth = new ApiKeyAuth("header", "X-API-TOKEN"); + auth.setApiKey(null); + auth.setApiKeyPrefix("Token"); + auth.applyToParams(queryParams, headerParams); + + // no changes to parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); + } } diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java index 52c5497ba83..ddee04f57fc 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/auth/HttpBasicAuthTest.java @@ -48,5 +48,15 @@ public class HttpBasicAuthTest { // the string below is base64-encoded result of "my-username:" with the "Basic " prefix expected = "Basic bXktdXNlcm5hbWU6"; assertEquals(expected, headerParams.get("Authorization")); + + // null username and password should be ignored + queryParams = new ArrayList(); + headerParams = new HashMap(); + auth.setUsername(null); + auth.setPassword(null); + auth.applyToParams(queryParams, headerParams); + // no changes to parameters + assertEquals(0, queryParams.size()); + assertEquals(0, headerParams.size()); } } diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm index dbd822cc1d4..11f2ab3f236 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/ApiClient.pm @@ -317,18 +317,24 @@ sub update_params_for_auth { foreach my $auth (@$auth_settings) { # determine which one to use if (!defined($auth)) { + # TODO show warning about auth setting not defined } elsif ($auth eq 'api_key') { - $header_params->{'api_key'} = $self->get_api_key_with_prefix('api_key'); + my $api_key = $self->get_api_key_with_prefix('api_key'); + if ($api_key) { + $header_params->{'api_key'} = $api_key; + } } elsif ($auth eq 'petstore_auth') { - $header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token; + if ($WWW::SwaggerClient::Configuration::access_token) { + $header_params->{'Authorization'} = 'Bearer ' . $WWW::SwaggerClient::Configuration::access_token; + } } else { - # TODO show warning about security definition not found + # TODO show warning about security definition not found } } } diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index feb5228cb61..941d9e0ce24 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2015-11-13T20:46:43.271Z', + generated_date => '2015-11-20T17:35:18.902+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2015-11-13T20:46:43.271Z +=item Build date: 2015-11-20T17:35:18.902+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen 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 a418ac90b43..bc03a7974d3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -135,8 +135,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try @@ -200,8 +202,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try @@ -264,8 +268,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try @@ -340,8 +346,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try @@ -424,13 +432,13 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); - if (isset($apiKey)) { + if ($apiKey !== null) { $headerParams['api_key'] = $apiKey; } - // make the API Call try { @@ -526,8 +534,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try @@ -602,8 +612,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try @@ -694,8 +706,10 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + // this endpoint requires OAuth (access token) + if ($this->apiClient->getConfig()->getAccessToken() !== null) { + $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken(); + } // make the API Call try 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 b64b52d2225..d709330b056 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -130,13 +130,13 @@ class StoreApi $httpBody = $formParams; // for HTTP post (form) } + // this endpoint requires API key authentication $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); - if (isset($apiKey)) { + if ($apiKey !== null) { $headerParams['api_key'] = $apiKey; } - // make the API Call try { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php index 982b8955a15..a0bb07273e4 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ApiClient.php @@ -69,7 +69,7 @@ class ApiClient * Constructor of the class * @param Configuration $config config for this ApiClient */ - function __construct(Configuration $config = null) + public function __construct(Configuration $config = null) { if ($config == null) { $config = Configuration::getDefaultConfiguration(); diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index efdc1c896ab..0d281b9d1fa 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -193,7 +193,7 @@ class ObjectSerializer $deserialized = $values; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); - } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/python/.coverage b/samples/client/petstore/python/.coverage index 03f8b2a2d03..ddd00f77a03 100644 --- a/samples/client/petstore/python/.coverage +++ b/samples/client/petstore/python/.coverage @@ -1 +1 @@ -!coverage.py: This is a private format, don't read it directly!{"runs": [{"brief_sys": "CPython 3.4.3 Darwin"}], "lines": {"/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/user.py": [70, 136, 202, 272, 81, 147, 213, 22, 25, 92, 29, 158, 224, 103, 169, 235, 114, 19, 180, 30, 246, 266, 191, 125, 21], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/rest.py": [20, 21, 23, 24, 25, 26, 27, 28, 31, 33, 35, 36, 40, 42, 48, 51, 53, 54, 55, 56, 57, 59, 63, 65, 72, 74, 82, 83, 88, 92, 95, 98, 101, 102, 103, 104, 105, 106, 109, 110, 121, 122, 124, 129, 130, 132, 135, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 152, 153, 154, 155, 156, 159, 160, 161, 166, 170, 171, 174, 176, 177, 179, 181, 182, 183, 184, 186, 191, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 210, 211, 212, 213, 214, 215, 217, 225, 227, 228, 229, 230, 231, 232, 239, 243, 244, 245, 246, 248, 249, 251], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/__init__.py": [1, 4, 5, 6, 7, 8], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/__init__.py": [1, 4, 5, 6], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/tag.py": [72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/pet.py": [128, 130, 150, 172, 139, 141, 19, 215, 21, 22, 152, 25, 29, 30, 161, 163, 39, 40, 41, 42, 43, 44, 45, 174, 48, 49, 50, 51, 52, 53, 54, 183, 57, 58, 59, 60, 61, 62, 64, 194, 195, 200, 73, 202, 75, 206, 208, 209, 210, 211, 84, 213, 86, 185, 216, 218, 220, 222, 95, 97, 226, 228, 106, 108, 117, 119, 212], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/pet_api.py": [469, 18, 20, 22, 23, 536, 26, 539, 28, 29, 69, 32, 545, 546, 548, 37, 39, 40, 41, 42, 555, 44, 557, 558, 559, 48, 561, 562, 564, 567, 568, 569, 70, 573, 574, 577, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 591, 80, 82, 83, 85, 87, 89, 91, 92, 94, 95, 96, 99, 100, 101, 614, 617, 618, 620, 621, 622, 111, 157, 113, 114, 627, 628, 106, 630, 631, 120, 633, 634, 635, 637, 639, 641, 642, 643, 644, 645, 646, 449, 648, 651, 652, 653, 109, 144, 657, 658, 147, 148, 661, 73, 663, 664, 665, 666, 155, 668, 538, 670, 671, 160, 112, 162, 164, 166, 167, 169, 170, 171, 174, 175, 176, 115, 180, 181, 184, 116, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 118, 198, 535, 119, 121, 219, 220, 222, 549, 224, 123, 229, 230, 232, 233, 551, 237, 238, 239, 552, 243, 244, 246, 553, 249, 250, 383, 255, 256, 259, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 673, 273, 46, 294, 295, 297, 298, 299, 304, 305, 307, 308, 310, 312, 313, 314, 223, 316, 318, 319, 321, 324, 325, 326, 330, 331, 45, 334, 336, 337, 338, 339, 340, 667, 342, 343, 344, 345, 346, 348, 540, 145, 483, 369, 372, 373, 375, 376, 377, 382, 149, 385, 386, 235, 388, 389, 390, 392, 394, 396, 397, 399, 402, 403, 404, 408, 409, 412, 154, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 426, 669, 72, 105, 158, 241, 74, 117, 672, 452, 453, 455, 456, 457, 462, 463, 465, 466, 468, 532, 470, 472, 474, 79, 476, 477, 478, 479, 480, 481, 251, 486, 487, 488, 492, 493, 496, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 341], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/__init__.py": [1, 4, 5, 6, 7, 8, 11, 12, 13, 16, 18, 20], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/store_api.py": [273, 18, 20, 22, 23, 26, 28, 29, 32, 37, 39, 40, 41, 44, 46, 48, 195, 68, 69, 71, 72, 79, 81, 82, 84, 86, 88, 90, 91, 93, 96, 97, 98, 102, 103, 106, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 120], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/category.py": [72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/order.py": [130, 44, 141, 45, 19, 21, 22, 152, 25, 29, 30, 52, 161, 163, 39, 40, 41, 42, 43, 172, 173, 174, 175, 48, 49, 50, 51, 180, 53, 54, 57, 58, 59, 60, 61, 62, 191, 64, 202, 75, 86, 176, 222, 97, 228, 178, 108, 119], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/api_client.py": [516, 523, 524, 525, 19, 21, 22, 535, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 40, 42, 44, 49, 52, 566, 567, 568, 569, 570, 571, 573, 68, 69, 70, 75, 76, 77, 79, 80, 82, 84, 91, 96, 98, 102, 103, 104, 107, 108, 109, 111, 112, 115, 116, 117, 118, 119, 120, 123, 124, 125, 126, 129, 130, 131, 134, 137, 138, 23, 141, 144, 145, 146, 147, 149, 152, 153, 155, 157, 158, 160, 162, 171, 172, 174, 176, 191, 192, 544, 194, 195, 196, 197, 198, 199, 200, 201, 202, 204, 205, 212, 213, 214, 216, 217, 219, 231, 235, 236, 240, 242, 251, 252, 254, 255, 256, 257, 258, 260, 261, 262, 263, 556, 267, 268, 269, 272, 274, 275, 276, 278, 279, 280, 281, 283, 286, 287, 288, 564, 316, 317, 318, 319, 320, 322, 323, 324, 325, 326, 327, 328, 329, 330, 332, 333, 337, 338, 339, 340, 341, 345, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 369, 370, 371, 372, 379, 387, 389, 390, 392, 393, 394, 395, 397, 398, 399, 400, 401, 402, 404, 406, 413, 414, 416, 418, 419, 421, 423, 430, 431, 433, 435, 436, 438, 440, 501, 448, 450, 453, 454, 455, 456, 457, 465, 546, 491, 500, 545, 506, 508], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/configuration.py": [135, 136, 137, 138, 139, 142, 19, 149, 22, 23, 25, 26, 27, 29, 158, 31, 32, 34, 36, 37, 39, 40, 41, 170, 43, 172, 46, 47, 189, 179, 52, 54, 59, 61, 190, 63, 192, 224, 67, 69, 71, 200, 73, 204, 80, 81, 82, 84, 213, 86, 199, 88, 90, 219, 92, 221, 222, 223, 96, 225, 98, 100, 102, 230, 104, 167, 111, 76, 168, 157, 122, 123, 42, 21], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/user_api.py": [32, 37, 198, 39, 423, 582, 48, 273, 18, 20, 501, 22, 23, 26, 123, 28, 29, 351]}} \ No newline at end of file +!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/apis/pet_api.py": [512, 513, 514, 516, 86, 18, 20, 22, 23, 26, 539, 28, 29, 542, 543, 32, 548, 37, 39, 40, 41, 42, 555, 556, 45, 558, 559, 560, 562, 564, 565, 566, 568, 569, 571, 574, 575, 576, 580, 581, 70, 584, 73, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 598, 88, 90, 92, 93, 95, 96, 97, 100, 101, 102, 106, 107, 621, 622, 624, 625, 626, 79, 116, 117, 118, 631, 632, 121, 122, 635, 124, 638, 639, 641, 642, 643, 645, 647, 649, 650, 651, 652, 653, 654, 656, 145, 146, 659, 148, 661, 150, 665, 666, 155, 156, 538, 159, 160, 673, 162, 675, 164, 677, 166, 679, 168, 169, 171, 172, 173, 541, 176, 177, 178, 115, 182, 183, 186, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 552, 200, 119, 120, 377, 221, 222, 549, 224, 225, 226, 231, 232, 431, 235, 236, 110, 238, 240, 241, 242, 244, 246, 247, 249, 383, 252, 253, 254, 258, 259, 262, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 276, 46, 48, 297, 298, 300, 301, 302, 44, 307, 308, 311, 312, 314, 316, 317, 318, 320, 322, 323, 325, 113, 328, 329, 330, 334, 335, 338, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 485, 352, 84, 114, 373, 374, 376, 660, 378, 149, 384, 387, 390, 391, 393, 394, 395, 397, 399, 401, 402, 404, 407, 408, 409, 413, 414, 69, 417, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 669, 72, 671, 74, 672, 83, 454, 455, 457, 458, 459, 674, 112, 464, 465, 468, 471, 472, 676, 474, 475, 476, 478, 480, 80, 482, 483, 484, 678, 486, 487, 489, 492, 493, 494, 680, 498, 499, 502, 681, 504, 505, 506, 507, 508, 509, 510, 511], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/apis/user_api.py": [32, 355, 37, 39, 200, 124, 428, 589, 48, 18, 20, 22, 23, 276, 26, 507, 28, 29], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/api_client.py": [518, 525, 526, 527, 19, 21, 22, 23, 24, 537, 26, 27, 28, 29, 30, 31, 32, 33, 34, 547, 36, 37, 40, 42, 44, 558, 49, 52, 566, 568, 569, 570, 571, 572, 573, 575, 68, 69, 70, 75, 76, 77, 79, 80, 82, 84, 91, 96, 98, 102, 103, 104, 107, 108, 109, 111, 112, 115, 116, 117, 118, 119, 120, 123, 124, 125, 126, 129, 130, 131, 134, 137, 138, 141, 144, 145, 146, 147, 149, 152, 153, 155, 157, 158, 160, 162, 171, 172, 174, 176, 191, 192, 194, 195, 196, 197, 198, 199, 200, 201, 202, 204, 205, 212, 213, 214, 216, 217, 219, 231, 235, 236, 240, 242, 251, 252, 254, 255, 256, 257, 258, 260, 261, 262, 263, 267, 268, 269, 272, 274, 275, 276, 278, 279, 280, 281, 283, 286, 287, 288, 316, 317, 318, 319, 320, 322, 323, 324, 325, 326, 327, 328, 329, 330, 332, 333, 337, 338, 339, 340, 341, 345, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 369, 370, 371, 372, 379, 387, 389, 390, 392, 393, 394, 395, 548, 397, 398, 399, 400, 401, 402, 404, 406, 413, 414, 416, 418, 419, 421, 423, 430, 431, 433, 435, 436, 438, 440, 448, 450, 453, 454, 455, 456, 458, 459, 467, 546, 493, 502, 503, 508, 510], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/models/category.py": [72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/rest.py": [20, 21, 23, 24, 25, 26, 27, 28, 31, 33, 35, 36, 40, 42, 48, 51, 53, 54, 55, 56, 57, 59, 63, 65, 72, 74, 82, 83, 88, 92, 95, 98, 101, 102, 103, 104, 105, 106, 109, 110, 121, 122, 124, 129, 130, 132, 135, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 152, 153, 154, 155, 156, 159, 160, 161, 166, 170, 171, 174, 176, 177, 179, 181, 182, 183, 184, 186, 191, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 210, 211, 212, 213, 214, 215, 217, 225, 227, 228, 229, 230, 231, 232, 239, 243, 244, 245, 246, 248, 249, 251], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/models/__init__.py": [1, 4, 5, 6, 7, 8], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/apis/store_api.py": [18, 276, 22, 23, 26, 28, 29, 197, 32, 37, 39, 40, 41, 44, 46, 48, 20, 68, 69, 71, 72, 79, 82, 83, 85, 87, 89, 91, 92, 94, 97, 98, 99, 103, 104, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 121], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/configuration.py": [135, 136, 137, 138, 139, 142, 19, 149, 22, 23, 25, 26, 27, 29, 158, 31, 32, 34, 36, 37, 39, 40, 41, 170, 43, 172, 46, 47, 189, 179, 52, 54, 59, 61, 190, 63, 192, 224, 67, 69, 71, 200, 73, 204, 80, 81, 82, 84, 213, 86, 199, 88, 90, 219, 92, 221, 222, 223, 96, 225, 98, 100, 102, 230, 104, 167, 111, 76, 168, 157, 122, 123, 42, 21], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/__init__.py": [1, 4, 5, 6, 7, 8, 11, 12, 13, 16, 18, 20], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/models/pet.py": [128, 130, 150, 172, 139, 141, 19, 215, 21, 22, 152, 25, 29, 30, 161, 163, 39, 40, 41, 42, 43, 44, 45, 174, 48, 49, 50, 51, 52, 53, 54, 183, 57, 58, 59, 60, 61, 62, 64, 194, 195, 200, 73, 202, 75, 206, 208, 209, 210, 211, 84, 213, 86, 185, 216, 218, 220, 222, 95, 97, 226, 228, 106, 108, 117, 119, 212], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/models/user.py": [70, 136, 202, 272, 81, 147, 213, 22, 25, 92, 29, 158, 224, 103, 169, 235, 114, 19, 180, 30, 246, 266, 191, 125, 21], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/apis/__init__.py": [1, 4, 5, 6], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/models/order.py": [130, 44, 141, 45, 19, 21, 22, 152, 25, 29, 30, 52, 161, 163, 39, 40, 41, 42, 43, 172, 173, 174, 175, 48, 49, 50, 51, 180, 53, 54, 57, 58, 59, 60, 61, 62, 191, 64, 202, 75, 86, 176, 222, 97, 228, 178, 108, 119], "/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/python/swagger_client/models/tag.py": [72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63]}} \ No newline at end of file diff --git a/samples/client/petstore/python/dev-requirements.txt.log b/samples/client/petstore/python/dev-requirements.txt.log index 0d8dcbb5831..316a9394b50 100644 --- a/samples/client/petstore/python/dev-requirements.txt.log +++ b/samples/client/petstore/python/dev-requirements.txt.log @@ -20,3 +20,17 @@ Requirement already satisfied (use --upgrade to upgrade): randomize in ./.venv/l Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11.2 in ./.venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) Requirement already satisfied (use --upgrade to upgrade): py>=1.4.17 in ./.venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) Requirement already satisfied (use --upgrade to upgrade): pluggy<0.4.0,>=0.3.0 in ./.venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): nose in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 1)) +Requirement already satisfied (use --upgrade to upgrade): tox in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): coverage in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 3)) +Requirement already satisfied (use --upgrade to upgrade): randomize in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 4)) +Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11.2 in ./venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): py>=1.4.17 in ./venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): pluggy<0.4.0,>=0.3.0 in ./venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): nose in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 1)) +Requirement already satisfied (use --upgrade to upgrade): tox in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): coverage in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 3)) +Requirement already satisfied (use --upgrade to upgrade): randomize in ./venv/lib/python2.7/site-packages (from -r dev-requirements.txt (line 4)) +Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11.2 in ./venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): py>=1.4.17 in ./venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Requirement already satisfied (use --upgrade to upgrade): pluggy<0.4.0,>=0.3.0 in ./venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) diff --git a/samples/client/petstore/python/swagger_client/api_client.py b/samples/client/petstore/python/swagger_client/api_client.py index fdc92cae77f..f3c66bd3706 100644 --- a/samples/client/petstore/python/swagger_client/api_client.py +++ b/samples/client/petstore/python/swagger_client/api_client.py @@ -453,7 +453,9 @@ class ApiClient(object): for auth in auth_settings: auth_setting = config.auth_settings().get(auth) if auth_setting: - if auth_setting['in'] == 'header': + if not auth_setting['value']: + continue + elif auth_setting['in'] == 'header': headers[auth_setting['key']] = auth_setting['value'] elif auth_setting['in'] == 'query': querys[auth_setting['key']] = auth_setting['value'] diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index d68d34e6774..d7bc11daaaf 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -79,6 +79,7 @@ class PetApi(object): params[key] = val del params['kwargs'] + resource_path = '/pet'.replace('{format}', 'json') method = 'PUT' @@ -154,6 +155,7 @@ class PetApi(object): params[key] = val del params['kwargs'] + resource_path = '/pet'.replace('{format}', 'json') method = 'POST' @@ -229,6 +231,7 @@ class PetApi(object): params[key] = val del params['kwargs'] + resource_path = '/pet/findByStatus'.replace('{format}', 'json') method = 'GET' @@ -304,6 +307,7 @@ class PetApi(object): params[key] = val del params['kwargs'] + resource_path = '/pet/findByTags'.replace('{format}', 'json') method = 'GET' @@ -365,9 +369,6 @@ class PetApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'pet_id' is set - if pet_id is None: - raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") all_params = ['pet_id'] all_params.append('callback') @@ -382,6 +383,10 @@ class PetApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`") + resource_path = '/pet/{petId}'.replace('{format}', 'json') method = 'GET' @@ -445,9 +450,6 @@ class PetApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'pet_id' is set - if pet_id is None: - raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") all_params = ['pet_id', 'name', 'status'] all_params.append('callback') @@ -462,6 +464,10 @@ class PetApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") + resource_path = '/pet/{petId}'.replace('{format}', 'json') method = 'POST' @@ -528,9 +534,6 @@ class PetApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'pet_id' is set - if pet_id is None: - raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") all_params = ['pet_id', 'api_key'] all_params.append('callback') @@ -545,6 +548,10 @@ class PetApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") + resource_path = '/pet/{petId}'.replace('{format}', 'json') method = 'DELETE' @@ -610,9 +617,6 @@ class PetApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'pet_id' is set - if pet_id is None: - raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") all_params = ['pet_id', 'additional_metadata', 'file'] all_params.append('callback') @@ -627,6 +631,10 @@ class PetApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") + resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') method = 'POST' diff --git a/samples/client/petstore/python/swagger_client/apis/store_api.py b/samples/client/petstore/python/swagger_client/apis/store_api.py index 9e08a0b2f47..e3835990a30 100644 --- a/samples/client/petstore/python/swagger_client/apis/store_api.py +++ b/samples/client/petstore/python/swagger_client/apis/store_api.py @@ -78,6 +78,7 @@ class StoreApi(object): params[key] = val del params['kwargs'] + resource_path = '/store/inventory'.replace('{format}', 'json') method = 'GET' @@ -151,6 +152,7 @@ class StoreApi(object): params[key] = val del params['kwargs'] + resource_path = '/store/order'.replace('{format}', 'json') method = 'POST' @@ -212,9 +214,6 @@ class StoreApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'order_id' is set - if order_id is None: - raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") all_params = ['order_id'] all_params.append('callback') @@ -229,6 +228,10 @@ class StoreApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'order_id' is set + if ('order_id' not in params) or (params['order_id'] is None): + raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") + resource_path = '/store/order/{orderId}'.replace('{format}', 'json') method = 'GET' @@ -290,9 +293,6 @@ class StoreApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'order_id' is set - if order_id is None: - raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") all_params = ['order_id'] all_params.append('callback') @@ -307,6 +307,10 @@ class StoreApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'order_id' is set + if ('order_id' not in params) or (params['order_id'] is None): + raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") + resource_path = '/store/order/{orderId}'.replace('{format}', 'json') method = 'DELETE' diff --git a/samples/client/petstore/python/swagger_client/apis/user_api.py b/samples/client/petstore/python/swagger_client/apis/user_api.py index aa35e6db53a..4394941b1d5 100644 --- a/samples/client/petstore/python/swagger_client/apis/user_api.py +++ b/samples/client/petstore/python/swagger_client/apis/user_api.py @@ -79,6 +79,7 @@ class UserApi(object): params[key] = val del params['kwargs'] + resource_path = '/user'.replace('{format}', 'json') method = 'POST' @@ -154,6 +155,7 @@ class UserApi(object): params[key] = val del params['kwargs'] + resource_path = '/user/createWithArray'.replace('{format}', 'json') method = 'POST' @@ -229,6 +231,7 @@ class UserApi(object): params[key] = val del params['kwargs'] + resource_path = '/user/createWithList'.replace('{format}', 'json') method = 'POST' @@ -305,6 +308,7 @@ class UserApi(object): params[key] = val del params['kwargs'] + resource_path = '/user/login'.replace('{format}', 'json') method = 'GET' @@ -381,6 +385,7 @@ class UserApi(object): params[key] = val del params['kwargs'] + resource_path = '/user/logout'.replace('{format}', 'json') method = 'GET' @@ -440,9 +445,6 @@ class UserApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'username' is set - if username is None: - raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") all_params = ['username'] all_params.append('callback') @@ -457,6 +459,10 @@ class UserApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'username' is set + if ('username' not in params) or (params['username'] is None): + raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") + resource_path = '/user/{username}'.replace('{format}', 'json') method = 'GET' @@ -519,9 +525,6 @@ class UserApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'username' is set - if username is None: - raise ValueError("Missing the required parameter `username` when calling `update_user`") all_params = ['username', 'body'] all_params.append('callback') @@ -536,6 +539,10 @@ class UserApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'username' is set + if ('username' not in params) or (params['username'] is None): + raise ValueError("Missing the required parameter `username` when calling `update_user`") + resource_path = '/user/{username}'.replace('{format}', 'json') method = 'PUT' @@ -599,9 +606,6 @@ class UserApi(object): If the method is called asynchronously, returns the request thread. """ - # verify the required parameter 'username' is set - if username is None: - raise ValueError("Missing the required parameter `username` when calling `delete_user`") all_params = ['username'] all_params.append('callback') @@ -616,6 +620,10 @@ class UserApi(object): params[key] = val del params['kwargs'] + # verify the required parameter 'username' is set + if ('username' not in params) or (params['username'] is None): + raise ValueError("Missing the required parameter `username` when calling `delete_user`") + resource_path = '/user/{username}'.replace('{format}', 'json') method = 'DELETE'