From 42e10fbb14ed979dc68936577f867883171ca89c Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 30 Oct 2015 16:33:07 +0800 Subject: [PATCH 1/2] better error handling for invalid array/map type --- .../src/main/java/io/swagger/codegen/DefaultCodegen.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index e86d4c9cd78..e61864b1e81 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -814,6 +814,7 @@ public class DefaultCodegen { LOGGER.error("unexpected missing property for name " + name); return null; } + CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY); property.name = toVarName(name); @@ -1907,6 +1908,12 @@ public class DefaultCodegen { // character with _ or empty character. Below aims to spell out different cases we've // encountered so far and hopefully make it easier for others to add more special // cases in the future. + + // better error handling when map/array type is invalid + if (name == null) { + LOGGER.error("String to be sanitized is null. Default to ERROR_UNKNOWN"); + return "ERROR_UNKNOWN"; + } // input[] => input name = name.replaceAll("\\[\\]", ""); From c8ce84f65029931ad4ef1a76c3b9e6f38508abbb Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 30 Oct 2015 16:37:23 +0800 Subject: [PATCH 2/2] replace tab with space, update samples --- .../io/swagger/codegen/DefaultCodegen.java | 4 +- samples/client/petstore/java/default/pom.xml | 6 +- .../java/io/swagger/client/ApiException.java | 2 +- .../java/io/swagger/client/Configuration.java | 2 +- .../src/main/java/io/swagger/client/JSON.java | 2 +- .../src/main/java/io/swagger/client/Pair.java | 2 +- .../java/io/swagger/client/StringUtil.java | 2 +- .../main/java/io/swagger/client/TypeRef.java | 2 +- .../java/io/swagger/client/api/PetApi.java | 2 +- .../java/io/swagger/client/api/StoreApi.java | 2 +- .../java/io/swagger/client/api/UserApi.java | 2 +- .../io/swagger/client/auth/ApiKeyAuth.java | 2 +- .../swagger/client/auth/Authentication.java | 2 +- .../io/swagger/client/auth/HttpBasicAuth.java | 2 +- .../io/swagger/client/model/Category.java | 2 +- .../java/io/swagger/client/model/Order.java | 2 +- .../java/io/swagger/client/model/Pet.java | 2 +- .../java/io/swagger/client/model/Tag.java | 2 +- .../java/io/swagger/client/model/User.java | 2 +- .../dynamic-html/docs/assets/css/style.css | 4 + .../dynamic-html/docs/models/Category.html | 6 +- samples/dynamic-html/docs/models/Order.html | 30 +- samples/dynamic-html/docs/models/Pet.html | 30 +- samples/dynamic-html/docs/models/Tag.html | 6 +- samples/dynamic-html/docs/models/User.html | 24 +- samples/html/index.html | 2256 ++++++++++++----- 26 files changed, 1669 insertions(+), 731 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index e61864b1e81..275bf9f10ee 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -1911,8 +1911,8 @@ public class DefaultCodegen { // better error handling when map/array type is invalid if (name == null) { - LOGGER.error("String to be sanitized is null. Default to ERROR_UNKNOWN"); - return "ERROR_UNKNOWN"; + LOGGER.error("String to be sanitized is null. Default to ERROR_UNKNOWN"); + return "ERROR_UNKNOWN"; } // input[] => input diff --git a/samples/client/petstore/java/default/pom.xml b/samples/client/petstore/java/default/pom.xml index da49f3b2fb0..894e318b5f3 100644 --- a/samples/client/petstore/java/default/pom.xml +++ b/samples/client/petstore/java/default/pom.xml @@ -6,11 +6,7 @@ jar swagger-java-client 1.0.0 - - scm:git:git@github.com:swagger-api/swagger-mustache.git - scm:git:git@github.com:swagger-api/swagger-codegen.git - https://github.com/swagger-api/swagger-codegen - + 2.2.0 diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java index c09e4939e94..4ed22daabcd 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiException.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.util.Map; import java.util.List; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class ApiException extends Exception { private int code = 0; private Map> responseHeaders = null; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java index 692018a52d3..8d0b098e28d 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Configuration.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class Configuration { private static ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java index 1986a6badbf..60872714a37 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/JSON.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.datatype.joda.*; import java.io.IOException; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class JSON { private ObjectMapper mapper; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java index bc45efb5ce0..58afaafb158 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/Pair.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class Pair { private String name = ""; private String value = ""; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java index c2f943c731f..e1536c68473 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/StringUtil.java @@ -1,6 +1,6 @@ package io.swagger.client; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class StringUtil { /** * Check if the given array contains the given value (with case-insensitive comparison). diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java index c30d70add6b..b1ba48408db 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/TypeRef.java @@ -3,7 +3,7 @@ package io.swagger.client; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class TypeRef { private final Type type; 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 23782e03e72..34e29bdc521 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 @@ -11,7 +11,7 @@ import java.io.File; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class PetApi { private ApiClient apiClient; 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 f8c0fc58682..a2f2900dd40 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 @@ -11,7 +11,7 @@ import io.swagger.client.model.Order; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class StoreApi { private ApiClient apiClient; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java index f6ab0ae0814..9be6bbfa67f 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/api/UserApi.java @@ -11,7 +11,7 @@ import java.util.*; import java.util.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-21T11:55:29.717+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class UserApi { private ApiClient apiClient; 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 bc6e2f87def..14891e3504f 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-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class ApiKeyAuth implements Authentication { private final String location; private final String paramName; diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java index 45a92c1323c..d74fd356989 100644 --- a/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.java +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/auth/Authentication.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-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public interface Authentication { /** Apply authentication settings to header and query params. */ void applyToParams(List queryParams, Map headerParams); 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 bb14cab5a2c..99ff90e4c6f 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 @@ -8,7 +8,7 @@ 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-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class HttpBasicAuth implements Authentication { private String username; private String password; 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 b12b44dd1c8..1d1d9e1d1b5 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class Category { private Long id = null; 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 7e4e43420c9..9c6094aefbf 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 @@ -10,7 +10,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class Order { private Long id = null; 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 ba497232881..b842a7800de 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 @@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class Pet { private Long id = null; 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 68918590789..d52ef12d01c 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class Tag { private Long id = null; 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 271bf3b19d7..8aa9e34283f 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 @@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; @ApiModel(description = "") -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-20T10:56:59.550-07:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-10-30T16:36:47.681+08:00") public class User { private Long id = null; diff --git a/samples/dynamic-html/docs/assets/css/style.css b/samples/dynamic-html/docs/assets/css/style.css index f14f6bdb62c..b596c11a535 100644 --- a/samples/dynamic-html/docs/assets/css/style.css +++ b/samples/dynamic-html/docs/assets/css/style.css @@ -100,6 +100,10 @@ float: left; } +.param-enum { + margin-left: 20px; +} + .section-header { border-bottom: 2px; font-weight: bold; diff --git a/samples/dynamic-html/docs/models/Category.html b/samples/dynamic-html/docs/models/Category.html index 15c6820eead..99ec473bcc7 100644 --- a/samples/dynamic-html/docs/models/Category.html +++ b/samples/dynamic-html/docs/models/Category.html @@ -3,13 +3,15 @@
  • id : Long -
    +
    +
  • name : String -
    +
    +
diff --git a/samples/dynamic-html/docs/models/Order.html b/samples/dynamic-html/docs/models/Order.html index 82278a470c2..a45f7d6cd65 100644 --- a/samples/dynamic-html/docs/models/Order.html +++ b/samples/dynamic-html/docs/models/Order.html @@ -3,37 +3,55 @@
  • id : Long -
    +
    +
  • petId : Long -
    +
    +
  • quantity : Integer -
    +
    +
  • shipDate : Date -
    +
    +
  • status : String -
    Order Status +
    Order Status + +
    +
    Enum: + +
    placed
    + +
    approved
    + +
    delivered
    + + +
    +
  • complete : Boolean -
    +
    +
diff --git a/samples/dynamic-html/docs/models/Pet.html b/samples/dynamic-html/docs/models/Pet.html index 17468477704..2578f97e660 100644 --- a/samples/dynamic-html/docs/models/Pet.html +++ b/samples/dynamic-html/docs/models/Pet.html @@ -3,37 +3,55 @@
  • id : Long -
    +
    +
  • category : Category -
    +
    +
  • name : String -
    +
    +
  • photoUrls : List -
    +
    +
  • tags : List -
    +
    +
  • status : String -
    pet status in the store +
    pet status in the store + +
    +
    Enum: + +
    available
    + +
    pending
    + +
    sold
    + + +
    +
diff --git a/samples/dynamic-html/docs/models/Tag.html b/samples/dynamic-html/docs/models/Tag.html index e84b50d73d6..bf1ef9eadaf 100644 --- a/samples/dynamic-html/docs/models/Tag.html +++ b/samples/dynamic-html/docs/models/Tag.html @@ -3,13 +3,15 @@
  • id : Long -
    +
    +
  • name : String -
    +
    +
diff --git a/samples/dynamic-html/docs/models/User.html b/samples/dynamic-html/docs/models/User.html index c71cf6649d7..d742aa7cfde 100644 --- a/samples/dynamic-html/docs/models/User.html +++ b/samples/dynamic-html/docs/models/User.html @@ -3,49 +3,57 @@
  • id : Long -
    +
    +
  • username : String -
    +
    +
  • firstName : String -
    +
    +
  • lastName : String -
    +
    +
  • email : String -
    +
    +
  • password : String -
    +
    +
  • phone : String -
    +
    +
  • userStatus : Integer -
    User Status +
    User Status +
diff --git a/samples/html/index.html b/samples/html/index.html index 67d651d9307..cae7e02c9e0 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -1,685 +1,11 @@ - + + + - - API Reference - - -

Swagger Petstore

-
This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters for
- -
Contact Info: apiteam@swagger.io
-
Version: 1.0.0
-
Apache 2.0
-
http://www.apache.org/licenses/LICENSE-2.0.html
-

Access

-
Customize this message as you see fit!
-

Methods

- - - -
-
put: /pet
-
Pet
-
updatePet Update an existing pet
-
- -

Parameters

-
-
body (optional)
- -
Body Parameter — Pet object that needs to be added to the store
- -
-

Return type

- -
- - -
-
- -
-
post: /pet
-
Pet
-
addPet Add a new pet to the store
-
- -

Parameters

-
-
body (optional)
- -
Body Parameter — Pet object that needs to be added to the store
- -
-

Return type

- -
- - -
-
- -
-
get: /pet/findByStatus
-
Pet
-
findPetsByStatus Finds Pets by status
-
Multiple status values can be provided with comma seperated strings
- -

Parameters

-
-
status (optional)
- -
Query Parameter — Status values that need to be considered for filter default: available
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
[ {
-  "photoUrls" : [ "aeiou" ],
-  "name" : "doggie",
-  "id" : 123456789,
-  "category" : {
-    "name" : "aeiou",
-    "id" : 123456789
-  },
-  "tags" : [ {
-    "name" : "aeiou",
-    "id" : 123456789
-  } ],
-  "status" : "aeiou"
-} ]
- -

Example data

-
Content-Type: application/xml
-
<Pet>
-  <id>123456</id>
-  <name>doggie</name>
-  <photoUrls>string</photoUrls>
-  <status>string</status>
-</Pet>
- -
-
- -
-
get: /pet/findByTags
-
Pet
-
findPetsByTags Finds Pets by tags
-
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
- -

Parameters

-
-
tags (optional)
- -
Query Parameter — Tags to filter by
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
[ {
-  "photoUrls" : [ "aeiou" ],
-  "name" : "doggie",
-  "id" : 123456789,
-  "category" : {
-    "name" : "aeiou",
-    "id" : 123456789
-  },
-  "tags" : [ {
-    "name" : "aeiou",
-    "id" : 123456789
-  } ],
-  "status" : "aeiou"
-} ]
- -

Example data

-
Content-Type: application/xml
-
<Pet>
-  <id>123456</id>
-  <name>doggie</name>
-  <photoUrls>string</photoUrls>
-  <status>string</status>
-</Pet>
- -
-
- -
-
get: /pet/{petId}
-
Pet
-
getPetById Find pet by ID
-
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- -

Parameters

-
-
petId (required)
- -
Path Parameter — ID of pet that needs to be fetched
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
{
-  "photoUrls" : [ "aeiou" ],
-  "name" : "doggie",
-  "id" : 123456789,
-  "category" : {
-    "name" : "aeiou",
-    "id" : 123456789
-  },
-  "tags" : [ {
-    "name" : "aeiou",
-    "id" : 123456789
-  } ],
-  "status" : "aeiou"
-}
- -

Example data

-
Content-Type: application/xml
-
<Pet>
-  <id>123456</id>
-  <name>doggie</name>
-  <photoUrls>string</photoUrls>
-  <status>string</status>
-</Pet>
- -
-
- -
-
post: /pet/{petId}
-
Pet
-
updatePetWithForm Updates a pet in the store with form data
-
- -

Parameters

-
-
petId (required)
- -
Path Parameter — ID of pet that needs to be updated
-
name (optional)
- -
Form Parameter — Updated name of the pet
-
status (optional)
- -
Form Parameter — Updated status of the pet
- -
-

Return type

- -
- - -
-
- -
-
delete: /pet/{petId}
-
Pet
-
deletePet Deletes a pet
-
- -

Parameters

-
-
apiKey (optional)
- -
Header Parameter
-
petId (required)
- -
Path Parameter — Pet id to delete
- -
-

Return type

- -
- - -
-
- -
-
post: /pet/{petId}/uploadImage
-
Pet
-
uploadFile uploads an image
-
- -

Parameters

-
-
petId (required)
- -
Path Parameter — ID of pet to update
-
additionalMetadata (optional)
- -
Form Parameter — Additional data to pass to server
-
file (optional)
- -
Form Parameter — file to upload
- -
-

Return type

- -
- - -
-
- -
-
get: /store/inventory
-
Store
-
getInventory Returns pet inventories by status
-
Returns a map of status codes to quantities
- -

Parameters

-
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
{
-  "key" : 123
-}
- -

Example data

-
Content-Type: application/xml
-
not implemented io.swagger.models.properties.MapProperty@3e
- -
-
- -
-
post: /store/order
-
Store
-
placeOrder Place an order for a pet
-
- -

Parameters

-
-
body (optional)
- -
Body Parameter — order placed for purchasing the pet
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
{
-  "petId" : 123456789,
-  "quantity" : 123,
-  "id" : 123456789,
-  "shipDate" : "2015-06-09T07:23:55.625+0000",
-  "complete" : true,
-  "status" : "aeiou"
-}
- -

Example data

-
Content-Type: application/xml
-
<Order>
-  <id>123456</id>
-  <petId>123456</petId>
-  <quantity>0</quantity>
-  <shipDate>2015-06-09T00:23:55.631Z</shipDate>
-  <status>string</status>
-  <complete>true</complete>
-</Order>
- -
-
- -
-
get: /store/order/{orderId}
-
Store
-
getOrderById Find purchase order by ID
-
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- -

Parameters

-
-
orderId (required)
- -
Path Parameter — ID of pet that needs to be fetched
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
{
-  "petId" : 123456789,
-  "quantity" : 123,
-  "id" : 123456789,
-  "shipDate" : "2015-06-09T07:23:55.632+0000",
-  "complete" : true,
-  "status" : "aeiou"
-}
- -

Example data

-
Content-Type: application/xml
-
<Order>
-  <id>123456</id>
-  <petId>123456</petId>
-  <quantity>0</quantity>
-  <shipDate>2015-06-09T00:23:55.633Z</shipDate>
-  <status>string</status>
-  <complete>true</complete>
-</Order>
- -
-
- -
-
delete: /store/order/{orderId}
-
Store
-
deleteOrder Delete purchase order by ID
-
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
- -

Parameters

-
-
orderId (required)
- -
Path Parameter — ID of the order that needs to be deleted
- -
-

Return type

- -
- - -
-
- -
-
post: /user
-
User
-
createUser Create user
-
This can only be done by the logged in user.
- -

Parameters

-
-
body (optional)
- -
Body Parameter — Created user object
- -
-

Return type

- -
- - -
-
- -
-
post: /user/createWithArray
-
User
-
createUsersWithArrayInput Creates list of users with given input array
-
- -

Parameters

-
-
body (optional)
- -
Body Parameter — List of user object
- -
-

Return type

- -
- - -
-
- -
-
post: /user/createWithList
-
User
-
createUsersWithListInput Creates list of users with given input array
-
- -

Parameters

-
-
body (optional)
- -
Body Parameter — List of user object
- -
-

Return type

- -
- - -
-
- -
-
get: /user/login
-
User
-
loginUser Logs user into the system
-
- -

Parameters

-
-
username (optional)
- -
Query Parameter — The user name for login
-
password (optional)
- -
Query Parameter — The password for login in clear text
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
"aeiou"
- -

Example data

-
Content-Type: application/xml
-
string
- -
-
- -
-
get: /user/logout
-
User
-
logoutUser Logs out current logged in user session
-
- -

Parameters

-
- -
-

Return type

- -
- - -
-
- -
-
get: /user/{username}
-
User
-
getUserByName Get user by user name
-
- -

Parameters

-
-
username (required)
- -
Path Parameter — The name that needs to be fetched. Use user1 for testing.
- -
-

Return type

- - - - -

Example data

-
Content-Type: application/json
-
{
-  "id" : 1,
-  "username" : "johnp",
-  "firstName" : "John",
-  "lastName" : "Public",
-  "email" : "johnp@swagger.io",
-  "password" : "-secret-",
-  "phone" : "0123456789",
-  "userStatus" : 0
-}
- -
-
- -
-
put: /user/{username}
-
User
-
updateUser Updated user
-
This can only be done by the logged in user.
- -

Parameters

-
-
username (required)
- -
Path Parameter — name that need to be deleted
-
body (optional)
- -
Body Parameter — Updated user object
- -
-

Return type

- -
- - -
-
- -
-
delete: /user/{username}
-
User
-
deleteUser Delete user
-
This can only be done by the logged in user.
- -

Parameters

-
-
username (required)
- -
Path Parameter — The name that needs to be deleted
- -
-

Return type

- -
- - -
-
- - - -

Models

- - -
-

User

-
-
id
Long
-
username
String
-
firstName
String
-
lastName
String
-
email
String
-
password
String
-
phone
String
-
userStatus
Integer User Status
- -
-
- - - -
-

Category

-
-
id
Long
-
name
String
- -
-
- - - -
-

Pet

-
-
id
Long
-
category
Category
-
name
String
-
photoUrls
array[String]
-
tags
array[Tag]
-
status
String pet status in the store
- -
-
- - - -
-

Tag

-
-
id
Long
-
name
String
- -
-
- - - -
-

Order

-
-
id
Long
-
petId
Long
-
quantity
Integer
-
shipDate
Date
-
status
String Order Status
-
complete
Boolean
- -
-
- - - + + + +

Swagger Petstore

+
This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
+ +
Contact Info: apiteam@swagger.io
+
Version: 1.0.0
+
Apache 2.0
+
http://www.apache.org/licenses/LICENSE-2.0.html
+

Access

+ + +

Methods

+ [ Jump to Models ] + + +

Table of Contents

+
+ +
    + + + +
  1. put /pet
  2. + +
  3. post /pet
  4. + +
  5. get /pet/findByStatus
  6. + +
  7. get /pet/findByTags
  8. + +
  9. get /pet/{petId}
  10. + +
  11. post /pet/{petId}
  12. + +
  13. delete /pet/{petId}
  14. + +
  15. post /pet/{petId}/uploadImage
  16. + +
  17. get /store/inventory
  18. + +
  19. post /store/order
  20. + +
  21. get /store/order/{orderId}
  22. + +
  23. delete /store/order/{orderId}
  24. + +
  25. post /user
  26. + +
  27. post /user/createWithArray
  28. + +
  29. post /user/createWithList
  30. + +
  31. get /user/login
  32. + +
  33. get /user/logout
  34. + +
  35. get /user/{username}
  36. + +
  37. put /user/{username}
  38. + +
  39. delete /user/{username}
  40. + + + +
+ + + + + + +
+
+ Up +
put /pet
+
Update an existing pet (updatePet)
+ +
+ + + + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + + +

Request body

+
+
body (optional)
+ +
Body Parameter — Pet object that needs to be added to the store
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

400

+ Invalid ID supplied + + +

404

+ Pet not found + + +

405

+ Validation exception + + +
+
+ +
+
+ Up +
post /pet
+
Add a new pet to the store (addPet)
+ +
+ + + + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + + +

Request body

+
+
body (optional)
+ +
Body Parameter — Pet object that needs to be added to the store
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

405

+ Invalid input + + +
+
+ +
+
+ Up +
get /pet/findByStatus
+
Finds Pets by status (findPetsByStatus)
+ +
Multiple status values can be provided with comma seperated strings
+ + + + + + + + + + +

Query parameters

+
+
status (optional)
+ +
Query Parameter — Status values that need to be considered for filter default: available
+
+ + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +

400

+ Invalid status value + + +
+
+ +
+
+ Up +
get /pet/findByTags
+
Finds Pets by tags (findPetsByTags)
+ +
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
+ + + + + + + + + + +

Query parameters

+
+
tags (optional)
+ +
Query Parameter — Tags to filter by
+
+ + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +

400

+ Invalid tag value + + +
+
+ +
+
+ Up +
get /pet/{petId}
+
Find pet by ID (getPetById)
+ +
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ + +

Path parameters

+
+
petId (required)
+ +
Path Parameter — ID of pet that needs to be fetched
+
+ + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +

400

+ Invalid ID supplied + + +

404

+ Pet not found + + +
+
+ +
+
+ Up +
post /pet/{petId}
+
Updates a pet in the store with form data (updatePetWithForm)
+ +
+ + +

Path parameters

+
+
petId (required)
+ +
Path Parameter — ID of pet that needs to be updated
+
+ + + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + +
  • application/x-www-form-urlencoded
  • + +
+ + + + + + + + + +

Form parameters

+
+
name (optional)
+ +
Form Parameter — Updated name of the pet
status (optional)
+ +
Form Parameter — Updated status of the pet
+
+ + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

405

+ Invalid input + + +
+
+ +
+
+ Up +
delete /pet/{petId}
+
Deletes a pet (deletePet)
+ +
+ + +

Path parameters

+
+
petId (required)
+ +
Path Parameter — Pet id to delete
+
+ + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

400

+ Invalid pet value + + +
+
+ +
+
+ Up +
post /pet/{petId}/uploadImage
+
uploads an image (uploadFile)
+ +
+ + +

Path parameters

+
+
petId (required)
+ +
Path Parameter — ID of pet to update
+
+ + + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + +
  • multipart/form-data
  • + +
+ + + + + + + + + +

Form parameters

+
+
additionalMetadata (optional)
+ +
Form Parameter — Additional data to pass to server
file (optional)
+ +
Form Parameter — file to upload
+
+ + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

0

+ successful operation + + +
+
+ +
+
+ Up +
get /store/inventory
+
Returns pet inventories by status (getInventory)
+ +
Returns a map of status codes to quantities
+ + + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +
+
+ +
+
+ Up +
post /store/order
+
Place an order for a pet (placeOrder)
+ +
+ + + + + + +

Request body

+
+
body (optional)
+ +
Body Parameter — order placed for purchasing the pet
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +

400

+ Invalid Order + + +
+
+ +
+
+ Up +
get /store/order/{orderId}
+
Find purchase order by ID (getOrderById)
+ +
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ + +

Path parameters

+
+
orderId (required)
+ +
Path Parameter — ID of pet that needs to be fetched
+
+ + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +

400

+ Invalid ID supplied + + +

404

+ Order not found + + +
+
+ +
+
+ Up +
delete /store/order/{orderId}
+
Delete purchase order by ID (deleteOrder)
+ +
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ + +

Path parameters

+
+
orderId (required)
+ +
Path Parameter — ID of the order that needs to be deleted
+
+ + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

400

+ Invalid ID supplied + + +

404

+ Order not found + + +
+
+ +
+
+ Up +
post /user
+
Create user (createUser)
+ +
This can only be done by the logged in user.
+ + + + + + +

Request body

+
+
body (optional)
+ +
Body Parameter — Created user object
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

0

+ successful operation + + +
+
+ +
+
+ Up +
post /user/createWithArray
+
Creates list of users with given input array (createUsersWithArrayInput)
+ +
+ + + + + + +

Request body

+
+
body (optional)
+ +
Body Parameter — List of user object
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

0

+ successful operation + + +
+
+ +
+
+ Up +
post /user/createWithList
+
Creates list of users with given input array (createUsersWithListInput)
+ +
+ + + + + + +

Request body

+
+
body (optional)
+ +
Body Parameter — List of user object
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

0

+ successful operation + + +
+
+ +
+
+ Up +
get /user/login
+
Logs user into the system (loginUser)
+ +
+ + + + + + + + + + +

Query parameters

+
+
username (optional)
+ +
Query Parameter — The user name for login
password (optional)
+ +
Query Parameter — The password for login in clear text
+
+ + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + + +

400

+ Invalid username/password supplied + + +
+
+ +
+
+ Up +
get /user/logout
+
Logs out current logged in user session (logoutUser)
+ +
+ + + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

0

+ successful operation + + +
+
+ +
+
+ Up +
get /user/{username}
+
Get user by user name (getUserByName)
+ +
+ + +

Path parameters

+
+
username (required)
+ +
Path Parameter — The name that needs to be fetched. Use user1 for testing.
+
+ + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

200

+ successful operation + +

Example data

+
Content-Type: application/json
+
{id=1, username=johnp, firstName=John, lastName=Public, email=johnp@swagger.io, password=-secret-, phone=0123456789, userStatus=0}
+ + +

400

+ Invalid username supplied + + +

404

+ User not found + + +
+
+ +
+
+ Up +
put /user/{username}
+
Updated user (updateUser)
+ +
This can only be done by the logged in user.
+ + +

Path parameters

+
+
username (required)
+ +
Path Parameter — name that need to be deleted
+
+ + + + + +

Request body

+
+
body (optional)
+ +
Body Parameter — Updated user object
+
+ + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

400

+ Invalid user supplied + + +

404

+ User not found + + +
+
+ +
+
+ Up +
delete /user/{username}
+
Delete user (deleteUser)
+ +
This can only be done by the logged in user.
+ + +

Path parameters

+
+
username (required)
+ +
Path Parameter — The name that needs to be deleted
+
+ + + + + + + + + + + + + + + + + +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + +
  • application/json
  • + +
  • application/xml
  • + +
+ + +

Responses

+ +

400

+ Invalid username supplied + + +

404

+ User not found + + +
+
+ + + + + + +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    + + +
  1. User
  2. + + + +
  3. Category
  4. + + + +
  5. Pet
  6. + + + +
  7. Tag
  8. + + + +
  9. Order
  10. + + +
+ + + +
+

User Up

+
+
id
Long
+ +
username
String
+ +
firstName
String
+ +
lastName
String
+ +
email
String
+ +
password
String
+ +
phone
String
+ +
userStatus
Integer User Status
+ + +
+
+ + + +
+

Category Up

+
+
id
Long
+ +
name
String
+ + +
+
+ + + +
+

Pet Up

+
+
id
Long
+ +
category
Category
+ +
name
String
+ +
photoUrls
array[String]
+ +
tags
array[Tag]
+ +
status
String pet status in the store
+ +
Enum:
+
available
pending
sold
+ + +
+
+ + + +
+

Tag Up

+
+
id
Long
+ +
name
String
+ + +
+
+ + + +
+

Order Up

+
+
id
Long
+ +
petId
Long
+ +
quantity
Integer
+ +
shipDate
Date
+ +
status
String Order Status
+ +
Enum:
+
placed
approved
delivered
+ +
complete
Boolean
+ + +
+
+ + - \ No newline at end of file +