From b2ed17e63e1972fc4898df4d7bb7ba9679fd0269 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 17 Feb 2016 18:03:27 +0800 Subject: [PATCH 1/4] Remove unused jackson imports from Java models by fixing the logic of enum Boolean checking. Other changes: * Remove the `true &&` prefix from the `equals` method in models. * Apply some changes of Java-default to Java-okhttp-gson, i.e. adding `this` and parent model handling. * Some improvements on spaces and blank lines. --- .../codegen/languages/JavaClientCodegen.java | 9 ++- .../Java/libraries/okhttp-gson/model.mustache | 11 +-- .../src/main/resources/Java/pojo.mustache | 12 +-- .../client/petstore/java/default/README.md | 2 +- .../client/petstore/java/default/build.gradle | 3 + .../java/io/swagger/client/ApiClient.java | 8 +- .../java/io/swagger/client/api/PetApi.java | 6 +- .../java/io/swagger/client/api/StoreApi.java | 6 +- .../io/swagger/client/model/Category.java | 9 +-- .../java/io/swagger/client/model/Order.java | 16 ++-- .../java/io/swagger/client/model/Pet.java | 16 ++-- .../java/io/swagger/client/model/Tag.java | 9 +-- .../java/io/swagger/client/model/User.java | 21 +++-- .../client/petstore/java/feign/build.gradle | 3 + .../java/io/swagger/client/ApiClient.java | 10 ++- .../java/io/swagger/client/api/PetApi.java | 28 ++++++- .../io/swagger/client/model/Category.java | 27 ++++--- .../java/io/swagger/client/model/Order.java | 62 ++++++++++---- .../java/io/swagger/client/model/Pet.java | 62 ++++++++++---- .../java/io/swagger/client/model/Tag.java | 27 ++++--- .../java/io/swagger/client/model/User.java | 81 ++++++++++++++----- .../client/petstore/java/jersey2/build.gradle | 3 + .../java/io/swagger/client/ApiClient.java | 6 +- .../java/io/swagger/client/api/PetApi.java | 6 +- .../java/io/swagger/client/api/StoreApi.java | 6 +- .../io/swagger/client/model/Category.java | 23 ++++-- .../java/io/swagger/client/model/Order.java | 58 +++++++++---- .../java/io/swagger/client/model/Pet.java | 58 +++++++++---- .../java/io/swagger/client/model/Tag.java | 23 ++++-- .../java/io/swagger/client/model/User.java | 77 +++++++++++++----- .../petstore/java/okhttp-gson/README.md | 2 +- .../java/io/swagger/client/ApiClient.java | 6 +- .../java/io/swagger/client/api/PetApi.java | 4 +- .../java/io/swagger/client/api/StoreApi.java | 4 +- .../io/swagger/client/model/Category.java | 4 +- .../java/io/swagger/client/model/Order.java | 12 +-- .../java/io/swagger/client/model/Pet.java | 12 +-- .../java/io/swagger/client/model/Tag.java | 4 +- .../java/io/swagger/client/model/User.java | 16 ++-- 39 files changed, 505 insertions(+), 247 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java index 67750ea790cc..53bcab9d533e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java @@ -9,6 +9,7 @@ import io.swagger.models.Swagger; import io.swagger.models.parameters.FormParameter; import io.swagger.models.parameters.Parameter; import io.swagger.models.properties.*; +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -531,18 +532,18 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } } - if(model.isEnum == null || model.isEnum) { + if(!BooleanUtils.toBoolean(model.isEnum)) { // needed by all pojos, but not enums model.imports.add("ApiModelProperty"); model.imports.add("ApiModel"); - // comment out below as it's in the model template + // comment out below as it's in the model template //model.imports.add("Objects"); final String lib = getLibrary(); if(StringUtils.isEmpty(lib) || "feign".equals(lib) || "jersey2".equals(lib)) { model.imports.add("JsonProperty"); - if(model.hasEnums != null || model.hasEnums == true) { + if(BooleanUtils.toBoolean(model.hasEnums)) { model.imports.add("JsonValue"); } } @@ -747,7 +748,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig { } } } - + if(removedChildEnum) { // If we removed an entry from this model's vars, we need to ensure hasMore is updated int count = 0, numVars = codegenProperties.size(); diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache index ef4a001dd05e..e8e74cc815a2 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/okhttp-gson/model.mustache @@ -47,16 +47,17 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali } if (o == null || getClass() != o.getClass()) { return false; - } - {{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}} - return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}} + }{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{/vars}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} return true;{{/hasVars}} } @Override public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}); + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); } @Override diff --git a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache index 8bbb36a80142..4ca33302ee73 100644 --- a/modules/swagger-codegen/src/main/resources/Java/pojo.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/pojo.mustache @@ -38,17 +38,17 @@ public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#seriali } if (o == null || getClass() != o.getClass()) { return false; - } + }{{#hasVars}} {{classname}} {{classVarName}} = ({{classname}}) o; - - return true {{#hasVars}}&& {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && - {{/hasMore}}{{/vars}}{{/hasVars}} - {{#parent}}&& super.equals(o){{/parent}}; + return {{#vars}}Objects.equals(this.{{name}}, {{classVarName}}.{{name}}){{#hasMore}} && + {{/hasMore}}{{/vars}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} + return true;{{/hasVars}} } @Override public int hashCode() { - return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}},{{/hasVars}} super.hashCode(){{/parent}}); + return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); } @Override diff --git a/samples/client/petstore/java/default/README.md b/samples/client/petstore/java/default/README.md index 8afc37518fc7..cc9672eab41a 100644 --- a/samples/client/petstore/java/default/README.md +++ b/samples/client/petstore/java/default/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/default/build.gradle b/samples/client/petstore/java/default/build.gradle index b7ccd1df7743..7bebf9164bbb 100644 --- a/samples/client/petstore/java/default/build.gradle +++ b/samples/client/petstore/java/default/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + group = 'io.swagger' version = '1.0.0' diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java index 7a4ed1a63b01..d0ff5f3c5836 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java @@ -41,7 +41,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class ApiClient { private Map defaultHeaderMap = new HashMap(); private String basePath = "http://petstore.swagger.io/v2"; @@ -83,8 +83,12 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java index bc73e268ef28..06920b07e609 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/PetApi.java @@ -12,7 +12,7 @@ import java.io.File; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class PetApi { private ApiClient apiClient; @@ -238,7 +238,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; @@ -438,7 +438,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java index 6b727652f735..352f0069c859 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/StoreApi.java @@ -12,7 +12,7 @@ import io.swagger.client.model.Order; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class StoreApi { private ApiClient apiClient; @@ -106,7 +106,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_client_id", "test_api_client_secret" }; GenericType returnType = new GenericType() {}; @@ -153,7 +153,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_key_query", "test_api_key_header" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java index afe72de51aee..fd2d25a1bb53 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Category { private Long id = null; @@ -63,10 +62,8 @@ public class Category { return false; } Category category = (Category) o; - - return true && Objects.equals(id, category.id) && - Objects.equals(name, category.name) - ; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java index 4b8126387e67..959b5c037110 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Order { private Long id = null; @@ -161,14 +161,12 @@ public class Order { return false; } Order order = (Order) o; - - return true && Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete) - ; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java index c04f35adfada..42da67104357 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Pet.java @@ -13,7 +13,7 @@ import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Pet { private Long id = null; @@ -163,14 +163,12 @@ public class Pet { return false; } Pet pet = (Pet) o; - - return true && Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status) - ; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java index da7f31937c5c..47560e0133b8 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class Tag { private Long id = null; @@ -63,10 +62,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - - return true && Objects.equals(id, tag.id) && - Objects.equals(name, tag.name) - ; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java index edb5b50931fd..0af0d48a56d7 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/User.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-12T18:48:10.013-08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:20.498+08:00") public class User { private Long id = null; @@ -178,16 +177,14 @@ public class User { return false; } User user = (User) o; - - return true && Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus) - ; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override diff --git a/samples/client/petstore/java/feign/build.gradle b/samples/client/petstore/java/feign/build.gradle index 0bfcfbec71f2..ee920fbc7cab 100644 --- a/samples/client/petstore/java/feign/build.gradle +++ b/samples/client/petstore/java/feign/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + group = 'io.swagger' version = '1.0.0' diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java index 2e032a9d1d11..303927d064ee 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/ApiClient.java @@ -18,7 +18,7 @@ import feign.slf4j.Slf4jLogger; import io.swagger.client.auth.*; import io.swagger.client.auth.OAuth.AccessTokenListener; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class ApiClient { public interface Api {} @@ -42,8 +42,16 @@ public class ApiClient { RequestInterceptor auth; if (authName == "petstore_auth") { auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets"); + } else if (authName == "test_api_client_id") { + auth = new ApiKeyAuth("header", "x-test_api_client_id"); + } else if (authName == "test_api_client_secret") { + auth = new ApiKeyAuth("header", "x-test_api_client_secret"); } else if (authName == "api_key") { auth = new ApiKeyAuth("header", "api_key"); + } else if (authName == "test_api_key_query") { + auth = new ApiKeyAuth("query", "test_api_key_query"); + } else if (authName == "test_api_key_header") { + auth = new ApiKeyAuth("header", "test_api_key_header"); } else { throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names"); } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java index 02a44b271f06..d2755e6ac411 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/PetApi.java @@ -8,7 +8,7 @@ import java.io.File; import java.util.*; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public interface PetApi extends ApiClient.Api { @@ -122,4 +122,30 @@ public interface PetApi extends ApiClient.Api { }) void uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file); + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + * @param petId ID of pet that needs to be fetched + * @return byte[] + */ + @RequestLine("GET /pet/{petId}?testing_byte_array=true") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + byte[] getPetByIdWithByteArray(@Param("petId") Long petId); + + /** + * Fake endpoint to test byte array in body parameter for adding a new pet to the store + * + * @param body Pet object in the form of byte array + * @return void + */ + @RequestLine("POST /pet?testing_byte_array=true") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + void addPetUsingByteArray(byte[] body); + } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java index 92e69c4d4077..2060d4f6624f 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Category { private Long id = null; @@ -19,8 +18,13 @@ public class Category { /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -45,7 +54,7 @@ public class Category { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -53,10 +62,8 @@ public class Category { return false; } Category category = (Category) o; - - return true && Objects.equals(id, category.id) && - Objects.equals(name, category.name) - ; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override @@ -79,7 +86,7 @@ public class Category { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java index 3dc9168d9269..0086f0c61a76 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Order { private Long id = null; @@ -44,8 +44,13 @@ public class Order { /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -57,8 +62,13 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("petId") public Long getPetId() { return petId; @@ -70,8 +80,13 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("quantity") public Integer getQuantity() { return quantity; @@ -83,8 +98,13 @@ public class Order { /** **/ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("shipDate") public Date getShipDate() { return shipDate; @@ -97,8 +117,13 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "Order Status") + @ApiModelProperty(example = "null", value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -110,8 +135,13 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("complete") public Boolean getComplete() { return complete; @@ -123,7 +153,7 @@ public class Order { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -131,14 +161,12 @@ public class Order { return false; } Order order = (Order) o; - - return true && Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete) - ; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override @@ -165,7 +193,7 @@ public class Order { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java index 908d654679aa..c90aec64ea8c 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Pet.java @@ -13,7 +13,7 @@ import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Pet { private Long id = null; @@ -46,8 +46,13 @@ public class Pet { /** **/ + public Pet id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -59,8 +64,13 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("category") public Category getCategory() { return category; @@ -72,8 +82,13 @@ public class Pet { /** **/ + public Pet name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -85,8 +100,13 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { return photoUrls; @@ -98,8 +118,13 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("tags") public List getTags() { return tags; @@ -112,8 +137,13 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "pet status in the store") + @ApiModelProperty(example = "null", value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -125,7 +155,7 @@ public class Pet { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -133,14 +163,12 @@ public class Pet { return false; } Pet pet = (Pet) o; - - return true && Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status) - ; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override @@ -167,7 +195,7 @@ public class Pet { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java index 337c84211a46..2a3678bc8833 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class Tag { private Long id = null; @@ -19,8 +18,13 @@ public class Tag { /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -45,7 +54,7 @@ public class Tag { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -53,10 +62,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - - return true && Objects.equals(id, tag.id) && - Objects.equals(name, tag.name) - ; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override @@ -79,7 +86,7 @@ public class Tag { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java index b05d8a58a81e..1f8cf539938d 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/User.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-11T21:48:33.457Z") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00") public class User { private Long id = null; @@ -25,8 +24,13 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -38,8 +42,13 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("username") public String getUsername() { return username; @@ -51,8 +60,13 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("firstName") public String getFirstName() { return firstName; @@ -64,8 +78,13 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("lastName") public String getLastName() { return lastName; @@ -77,8 +96,13 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("email") public String getEmail() { return email; @@ -90,8 +114,13 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("password") public String getPassword() { return password; @@ -103,8 +132,13 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("phone") public String getPhone() { return phone; @@ -117,8 +151,13 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + - @ApiModelProperty(value = "User Status") + @ApiModelProperty(example = "null", value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { return userStatus; @@ -130,7 +169,7 @@ public class User { @Override - public boolean equals(Object o) { + public boolean equals(java.lang.Object o) { if (this == o) { return true; } @@ -138,16 +177,14 @@ public class User { return false; } User user = (User) o; - - return true && Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus) - ; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override @@ -176,7 +213,7 @@ public class User { * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ - private String toIndentedString(Object o) { + private String toIndentedString(java.lang.Object o) { if (o == null) { return "null"; } diff --git a/samples/client/petstore/java/jersey2/build.gradle b/samples/client/petstore/java/jersey2/build.gradle index 85ad4f048b9f..c3a9375c9e07 100644 --- a/samples/client/petstore/java/jersey2/build.gradle +++ b/samples/client/petstore/java/jersey2/build.gradle @@ -1,3 +1,6 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' + group = 'io.swagger' version = '1.0.0' diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java index 89fe7f60680a..77bcbef413cf 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java @@ -48,7 +48,7 @@ import io.swagger.client.auth.HttpBasicAuth; import io.swagger.client.auth.ApiKeyAuth; import io.swagger.client.auth.OAuth; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class ApiClient { private Map defaultHeaderMap = new HashMap(); private String basePath = "http://petstore.swagger.io/v2"; @@ -85,7 +85,11 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java index a4402076fa7f..4c9690ac4c11 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/PetApi.java @@ -12,7 +12,7 @@ import java.io.File; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class PetApi { private ApiClient apiClient; @@ -238,7 +238,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; @@ -438,7 +438,7 @@ public class PetApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java index f20b99b2ae7c..d5bbd658dbb5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/api/StoreApi.java @@ -12,7 +12,7 @@ import io.swagger.client.model.Order; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class StoreApi { private ApiClient apiClient; @@ -106,7 +106,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_client_id", "test_api_client_secret" }; GenericType returnType = new GenericType() {}; @@ -153,7 +153,7 @@ public class StoreApi { }; final String contentType = apiClient.selectHeaderContentType(contentTypes); - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_key_query", "test_api_key_header" }; GenericType returnType = new GenericType() {}; diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java index 8c409d96e1c7..fb8f0542c8d5 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Category.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Category { private Long id = null; @@ -19,8 +18,13 @@ public class Category { /** **/ + public Category id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Category { /** **/ + public Category name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -53,10 +62,8 @@ public class Category { return false; } Category category = (Category) o; - - return true && Objects.equals(id, category.id) && - Objects.equals(name, category.name) - ; + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java index 40d3765f1da8..478483ef7afc 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Order.java @@ -11,7 +11,7 @@ import java.util.Date; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Order { private Long id = null; @@ -44,8 +44,13 @@ public class Order { /** **/ + public Order id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -57,8 +62,13 @@ public class Order { /** **/ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("petId") public Long getPetId() { return petId; @@ -70,8 +80,13 @@ public class Order { /** **/ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("quantity") public Integer getQuantity() { return quantity; @@ -83,8 +98,13 @@ public class Order { /** **/ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("shipDate") public Date getShipDate() { return shipDate; @@ -97,8 +117,13 @@ public class Order { /** * Order Status **/ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "Order Status") + @ApiModelProperty(example = "null", value = "Order Status") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -110,8 +135,13 @@ public class Order { /** **/ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("complete") public Boolean getComplete() { return complete; @@ -131,14 +161,12 @@ public class Order { return false; } Order order = (Order) o; - - return true && Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete) - ; + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java index 68a0dd6e67b7..f23c7a720b69 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Pet.java @@ -13,7 +13,7 @@ import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Pet { private Long id = null; @@ -46,8 +46,13 @@ public class Pet { /** **/ + public Pet id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -59,8 +64,13 @@ public class Pet { /** **/ + public Pet category(Category category) { + this.category = category; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("category") public Category getCategory() { return category; @@ -72,8 +82,13 @@ public class Pet { /** **/ + public Pet name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "doggie", required = true, value = "") @JsonProperty("name") public String getName() { return name; @@ -85,8 +100,13 @@ public class Pet { /** **/ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + - @ApiModelProperty(required = true, value = "") + @ApiModelProperty(example = "null", required = true, value = "") @JsonProperty("photoUrls") public List getPhotoUrls() { return photoUrls; @@ -98,8 +118,13 @@ public class Pet { /** **/ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("tags") public List getTags() { return tags; @@ -112,8 +137,13 @@ public class Pet { /** * pet status in the store **/ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + - @ApiModelProperty(value = "pet status in the store") + @ApiModelProperty(example = "null", value = "pet status in the store") @JsonProperty("status") public StatusEnum getStatus() { return status; @@ -133,14 +163,12 @@ public class Pet { return false; } Pet pet = (Pet) o; - - return true && Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status) - ; + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java index 769e5829b458..62dc4226d30f 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/Tag.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class Tag { private Long id = null; @@ -19,8 +18,13 @@ public class Tag { /** **/ + public Tag id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -32,8 +36,13 @@ public class Tag { /** **/ + public Tag name(String name) { + this.name = name; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("name") public String getName() { return name; @@ -53,10 +62,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - - return true && Objects.equals(id, tag.id) && - Objects.equals(name, tag.name) - ; + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java index 73de26c5e7af..ba0365590690 100644 --- a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/User.java @@ -2,7 +2,6 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -10,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-01-28T16:23:25.238+01:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:21.885+08:00") public class User { private Long id = null; @@ -25,8 +24,13 @@ public class User { /** **/ + public User id(Long id) { + this.id = id; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("id") public Long getId() { return id; @@ -38,8 +42,13 @@ public class User { /** **/ + public User username(String username) { + this.username = username; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("username") public String getUsername() { return username; @@ -51,8 +60,13 @@ public class User { /** **/ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("firstName") public String getFirstName() { return firstName; @@ -64,8 +78,13 @@ public class User { /** **/ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("lastName") public String getLastName() { return lastName; @@ -77,8 +96,13 @@ public class User { /** **/ + public User email(String email) { + this.email = email; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("email") public String getEmail() { return email; @@ -90,8 +114,13 @@ public class User { /** **/ + public User password(String password) { + this.password = password; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("password") public String getPassword() { return password; @@ -103,8 +132,13 @@ public class User { /** **/ + public User phone(String phone) { + this.phone = phone; + return this; + } + - @ApiModelProperty(value = "") + @ApiModelProperty(example = "null", value = "") @JsonProperty("phone") public String getPhone() { return phone; @@ -117,8 +151,13 @@ public class User { /** * User Status **/ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + - @ApiModelProperty(value = "User Status") + @ApiModelProperty(example = "null", value = "User Status") @JsonProperty("userStatus") public Integer getUserStatus() { return userStatus; @@ -138,16 +177,14 @@ public class User { return false; } User user = (User) o; - - return true && Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus) - ; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/README.md b/samples/client/petstore/java/okhttp-gson/README.md index be7ff686b7ac..fd85a16cd076 100644 --- a/samples/client/petstore/java/okhttp-gson/README.md +++ b/samples/client/petstore/java/okhttp-gson/README.md @@ -20,7 +20,7 @@ mvn deploy Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. -After the client libarary is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: +After the client library is installed/deployed, you can use it in your Maven project by adding the following to your *pom.xml*: ```xml diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java index 73a9187e75ff..0f853388744d 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java @@ -145,8 +145,12 @@ public class ApiClient { // Setup authentications (key: authentication name, value: authentication). authentications = new HashMap(); - authentications.put("api_key", new ApiKeyAuth("header", "api_key")); authentications.put("petstore_auth", new OAuth()); + authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id")); + authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret")); + authentications.put("api_key", new ApiKeyAuth("header", "api_key")); + authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query")); + authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header")); // Prevent the authentications from being modified. authentications = Collections.unmodifiableMap(authentications); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java index 497e3ade6a85..a29ace374f87 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java @@ -491,7 +491,7 @@ public class PetApi { }); } - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } @@ -936,7 +936,7 @@ public class PetApi { }); } - String[] authNames = new String[] { "api_key" }; + String[] authNames = new String[] { "petstore_auth", "api_key" }; return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java index 5e6c7c48c6be..11d1eded300c 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/StoreApi.java @@ -180,7 +180,7 @@ public class StoreApi { }); } - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_client_id", "test_api_client_secret" }; return apiClient.buildCall(path, "POST", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } @@ -288,7 +288,7 @@ public class StoreApi { }); } - String[] authNames = new String[] { }; + String[] authNames = new String[] { "test_api_key_query", "test_api_key_header" }; return apiClient.buildCall(path, "GET", queryParams, postBody, headerParams, formParams, authNames, progressRequestListener); } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java index d0908afd9e19..e7052e471700 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Category.java @@ -52,8 +52,8 @@ public class Category { return false; } Category category = (Category) o; - return Objects.equals(id, category.id) && - Objects.equals(name, category.name); + return Objects.equals(this.id, category.id) && + Objects.equals(this.name, category.name); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java index 59c5238b626a..5b96b2a32b28 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Order.java @@ -133,12 +133,12 @@ public enum StatusEnum { return false; } Order order = (Order) o; - return Objects.equals(id, order.id) && - Objects.equals(petId, order.petId) && - Objects.equals(quantity, order.quantity) && - Objects.equals(shipDate, order.shipDate) && - Objects.equals(status, order.status) && - Objects.equals(complete, order.complete); + return Objects.equals(this.id, order.id) && + Objects.equals(this.petId, order.petId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.shipDate, order.shipDate) && + Objects.equals(this.status, order.status) && + Objects.equals(this.complete, order.complete); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java index 1f9462ddc3a7..02990adb3803 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Pet.java @@ -135,12 +135,12 @@ public enum StatusEnum { return false; } Pet pet = (Pet) o; - return Objects.equals(id, pet.id) && - Objects.equals(category, pet.category) && - Objects.equals(name, pet.name) && - Objects.equals(photoUrls, pet.photoUrls) && - Objects.equals(tags, pet.tags) && - Objects.equals(status, pet.status); + return Objects.equals(this.id, pet.id) && + Objects.equals(this.category, pet.category) && + Objects.equals(this.name, pet.name) && + Objects.equals(this.photoUrls, pet.photoUrls) && + Objects.equals(this.tags, pet.tags) && + Objects.equals(this.status, pet.status); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java index a4ca1074ca18..4f8217b76783 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/Tag.java @@ -52,8 +52,8 @@ public class Tag { return false; } Tag tag = (Tag) o; - return Objects.equals(id, tag.id) && - Objects.equals(name, tag.name); + return Objects.equals(this.id, tag.id) && + Objects.equals(this.name, tag.name); } @Override diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java index 072f510081a0..bcec1fc0a1cd 100644 --- a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/User.java @@ -137,14 +137,14 @@ public class User { return false; } User user = (User) o; - return Objects.equals(id, user.id) && - Objects.equals(username, user.username) && - Objects.equals(firstName, user.firstName) && - Objects.equals(lastName, user.lastName) && - Objects.equals(email, user.email) && - Objects.equals(password, user.password) && - Objects.equals(phone, user.phone) && - Objects.equals(userStatus, user.userStatus); + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); } @Override From cac8df949d221af29dcacdfef6486a7ea37f63b2 Mon Sep 17 00:00:00 2001 From: xhh Date: Wed, 17 Feb 2016 19:46:40 +0800 Subject: [PATCH 2/4] Fix tests --- .../src/test/java/io/swagger/client/ApiClientTest.java | 8 +++++++- .../src/test/java/io/swagger/client/ApiClientTest.java | 8 +++++++- .../src/test/java/io/swagger/client/ApiClientTest.java | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java index 29eae3d017ea..9fa51a06baa0 100644 --- a/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/default/src/test/java/io/swagger/client/ApiClientTest.java @@ -131,7 +131,13 @@ public class ApiClientTest { @Test public void testSetApiKeyAndPrefix() { - ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + ApiKeyAuth auth = null; + for (Authentication _auth : apiClient.getAuthentications().values()) { + if (_auth instanceof ApiKeyAuth) { + auth = (ApiKeyAuth) _auth; + break; + } + } auth.setApiKey(null); auth.setApiKeyPrefix(null); diff --git a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java index 29eae3d017ea..9fa51a06baa0 100644 --- a/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/jersey2/src/test/java/io/swagger/client/ApiClientTest.java @@ -131,7 +131,13 @@ public class ApiClientTest { @Test public void testSetApiKeyAndPrefix() { - ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + ApiKeyAuth auth = null; + for (Authentication _auth : apiClient.getAuthentications().values()) { + if (_auth instanceof ApiKeyAuth) { + auth = (ApiKeyAuth) _auth; + break; + } + } auth.setApiKey(null); auth.setApiKeyPrefix(null); diff --git a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java index c22da2acac65..9e6d5f426424 100644 --- a/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java +++ b/samples/client/petstore/java/okhttp-gson/src/test/java/io/swagger/client/ApiClientTest.java @@ -170,7 +170,13 @@ public class ApiClientTest { @Test public void testSetApiKeyAndPrefix() { - ApiKeyAuth auth = (ApiKeyAuth) apiClient.getAuthentications().get("api_key"); + ApiKeyAuth auth = null; + for (Authentication _auth : apiClient.getAuthentications().values()) { + if (_auth instanceof ApiKeyAuth) { + auth = (ApiKeyAuth) _auth; + break; + } + } auth.setApiKey(null); auth.setApiKeyPrefix(null); From fd9a62adbe41529f138c0aff489e524c9968f6a3 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 18 Feb 2016 16:40:13 +0800 Subject: [PATCH 3/4] update php test case with higher memory limit --- README.md | 654 +----------------- .../SwaggerClient-php/tests/PetApiTest.php | 4 + 2 files changed, 19 insertions(+), 639 deletions(-) diff --git a/README.md b/README.md index 3f5f11ea9f09..794a7c49b1ba 100644 --- a/README.md +++ b/README.md @@ -1,646 +1,22 @@ -# Swagger Code Generator +## Frameworks supported +- .NET 4.0 or later +- Windows Phone 7.1 (Mango) -[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.svg)](https://travis-ci.org/swagger-api/swagger-codegen) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project) -[![PR Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/pr)](http://issuestats.com/github/swagger-api/swagger-codegen) [![Issue Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/issue)](http://issuestats.com/github/swagger-api/swagger-codegen) +## Dependencies +- [RestSharp] (https://www.nuget.org/packages/RestSharp) - 105.1.0 or later +- [Json.NET] (https://www.nuget.org/packages/Newtonsoft.Json/) - 7.0.0 or later -:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star: - -## Overview -This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server. - -Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project, including additional libraries with support for other languages and more. - -# Table of contents - - - [Swagger Code Generator](#swagger-code-generator) - - [Overview](#overview) - - [Table of Contents](#table-of-contents) - - Installation - - [Compatibility](#compatibility) - - [Prerequisites](#prerequisites) - - [OS X Users](#os-x-users) - - [Building](#building) - - [Docker](#docker) - - [Build and run](#build-and-run-using-docker) - - [Run docker in Vagrant](#run-docker-in-vagrant) - - [Public Docker image](#public-docker-image) - - [Homebrew](#homebrew) - - Generators - - [To generate a sample client library](#to-generate-a-sample-client-library) - - [Generating libraries from your server](#generating-libraries-from-your-server) - - [Modifying the client library format](#modifying-the-client-library-format) - - [Making your own codegen modules](#making-your-own-codegen-modules) - - [Where is Javascript???](#where-is-javascript) - - [Generating a client from local files](#generating-a-client-from-local-files) - - [Customizing the generator](#customizing-the-generator) - - [Validating your OpenAPI Spec](#validating-your-openapi-spec) - - [Generating dynamic html api documentation](#generating-dynamic-html-api-documentation) - - [Generating static html api documentation](#generating-static-html-api-documentation) - - [To build a server stub](#to-build-a-server-stub) - - [Node.js](#nodejs) - - [PHP Slim](#php-slim) - - [PHP Silex](#php-silex) - - [Python Flask (Connexion)](#python-flask-connexion) - - [Ruby Sinatra](#ruby-sinatra) - - [Scala Scalatra](#scala-scalatra) - - [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118) - - [Java JAX-RS (Apache CXF 3)](#java-jax-rs-apache-cxf-3) - - [Java Spring MVC](#java-spring-mvc) - - [Haskell Servant](#haskell-servant) - - [To build the codegen library](#to-build-the-codegen-library) - - [Workflow Integration](#workflow-integration) - - [Online Generators](#online-generators) - - [Guidelines for Contribution](https://github.com/swagger-api/swagger-codegen/wiki/Guidelines-for-Contribution) - - [License](#license) - - -## Compatibility -The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the OpenAPI Specification: - -Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes --------------------------- | ------------ | -------------------------- | ----- -2.1.6-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) -2.1.5 (**current stable**) | 2015-01-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-codegen/tree/v2.1.5) -2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) -1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) - - -### Prerequisites -If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum): - -``` -wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.4/swagger-codegen-cli-2.1.4.jar swagger-codegen-cli.jar - -java -jar swagger-codegen-cli.jar help -``` - -On a mac, it's even easier with `brew`: -``` -brew install swagger-codegen +The DLLs included in the package may not be the latest version. We recommned using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages: ``` - -To build from source, you need the following installed and available in your $PATH: - -* [Java 7 or 8](http://java.oracle.com) - -* [Apache maven 3.0.3 or greater](http://maven.apache.org/) - -#### OS X Users -Don't forget to install Java 7 or 8. You probably have 1.6. - -Export JAVA_HOME in order to use the supported Java version: -``` -export JAVA_HOME=`/usr/libexec/java_home -v 1.8` -export PATH=${JAVA_HOME}/bin:$PATH +Install-Package RestSharp +Install-Package Newtonsoft.Json ``` -### Building - -After cloning the project, you can build it from source with this command: -``` -mvn package -``` - -### Docker -#### Build and run using docker - -``` -git clone https://github.com/swagger-api/swagger-codegen -cd swagger-codegen -./run-in-docker.sh mvn package - ``` - - - -#### Run Docker in Vagrant -Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads). - ``` -git clone http://github.com/swagger-api/swagger-codegen.git -cd swagger-codegen -vagrant up -vagrant ssh -cd /vagrant -./run-in-docker.sh mvn package - ``` - -#### Public Docker image - -https://hub.docker.com/r/swaggerapi/swagger-generator/ - -### Homebrew -To install, run `brew install swagger-codegen` - -Here is an example usage: -``` -swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l ruby -o /tmp/test/ -``` - - -### To generate a sample client library -You can build a client against the swagger sample [petstore](http://petstore.swagger.io) API as follows: - -``` -./bin/java-petstore.sh -``` - -(On Windows, run `./bin/windows/java-petstore.bat` instead) - -This will run the generator with this command: - -``` -java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l java \ - -o samples/client/petstore/java -``` - -with a number of options. You can get the options with the `help generate` command: - -``` -NAME - swagger generate - Generate code with chosen lang - -SYNOPSIS - swagger generate [(-a | --auth )] - [(-c | --config )] - [-D ] - (-i | --input-spec ) - (-l | --lang ) - [(-o | --output )] - [(-t