diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java index f3ea72ed5fd..2f8dc6e3575 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java @@ -48,12 +48,13 @@ public class InlineModelResolver { if(model instanceof ModelImpl) { ModelImpl obj = (ModelImpl) model; if (obj.getType() == null || "object".equals(obj.getType())) { - String modelName = uniqueName(bp.getName()); - flattenProperties(obj.getProperties(), pathname); - - bp.setSchema(new RefModel(modelName)); - addGenerated(modelName, model); - swagger.addDefinition(modelName, model); + if (obj.getProperties() != null && obj.getProperties().size() > 0) { + flattenProperties(obj.getProperties(), pathname); + String modelName = uniqueName(bp.getName()); + bp.setSchema(new RefModel(modelName)); + addGenerated(modelName, model); + swagger.addDefinition(modelName, model); + } } } else if (model instanceof ArrayModel) { @@ -61,18 +62,19 @@ public class InlineModelResolver { Property inner = am.getItems(); if(inner instanceof ObjectProperty) { - String modelName = uniqueName(bp.getName()); ObjectProperty op = (ObjectProperty) inner; - flattenProperties(op.getProperties(), pathname); - - Model innerModel = modelFromProperty(op, modelName); - String existing = matchGenerated(innerModel); - if (existing != null) { - am.setItems(new RefProperty(existing)); - } else { - am.setItems(new RefProperty(modelName)); - addGenerated(modelName, innerModel); - swagger.addDefinition(modelName, innerModel); + if (op.getProperties() != null && op.getProperties().size() > 0) { + flattenProperties(op.getProperties(), pathname); + String modelName = uniqueName(bp.getName()); + Model innerModel = modelFromProperty(op, modelName); + String existing = matchGenerated(innerModel); + if (existing != null) { + am.setItems(new RefProperty(existing)); + } else { + am.setItems(new RefProperty(modelName)); + addGenerated(modelName, innerModel); + swagger.addDefinition(modelName, innerModel); + } } } } @@ -87,34 +89,37 @@ public class InlineModelResolver { if (response.getSchema() != null) { Property property = response.getSchema(); if (property instanceof ObjectProperty) { - String modelName = uniqueName("inline_response_" + key); ObjectProperty op = (ObjectProperty) property; - Model model = modelFromProperty(op, modelName); - String existing = matchGenerated(model); - if (existing != null) { - response.setSchema(new RefProperty(existing)); - } else { - response.setSchema(new RefProperty(modelName)); - addGenerated(modelName, model); - swagger.addDefinition(modelName, model); + if (op.getProperties() != null && op.getProperties().size() > 0) { + String modelName = uniqueName("inline_response_" + key); + Model model = modelFromProperty(op, modelName); + String existing = matchGenerated(model); + if (existing != null) { + response.setSchema(new RefProperty(existing)); + } else { + response.setSchema(new RefProperty(modelName)); + addGenerated(modelName, model); + swagger.addDefinition(modelName, model); + } } } else if (property instanceof ArrayProperty) { ArrayProperty ap = (ArrayProperty) property; Property inner = ap.getItems(); if(inner instanceof ObjectProperty) { - String modelName = uniqueName("inline_response_" + key); ObjectProperty op = (ObjectProperty) inner; - flattenProperties(op.getProperties(), pathname); - - Model innerModel = modelFromProperty(op, modelName); - String existing = matchGenerated(innerModel); - if (existing != null) { - ap.setItems(new RefProperty(existing)); - } else { - ap.setItems(new RefProperty(modelName)); - addGenerated(modelName, innerModel); - swagger.addDefinition(modelName, innerModel); + if (op.getProperties() != null && op.getProperties().size() > 0) { + flattenProperties(op.getProperties(), pathname); + String modelName = uniqueName("inline_response_" + key); + Model innerModel = modelFromProperty(op, modelName); + String existing = matchGenerated(innerModel); + if (existing != null) { + ap.setItems(new RefProperty(existing)); + } else { + ap.setItems(new RefProperty(modelName)); + addGenerated(modelName, innerModel); + swagger.addDefinition(modelName, innerModel); + } } } } else if (property instanceof MapProperty) { @@ -122,18 +127,19 @@ public class InlineModelResolver { Property innerProperty = mp.getAdditionalProperties(); if(innerProperty instanceof ObjectProperty) { - String modelName = uniqueName("inline_response_" + key); ObjectProperty op = (ObjectProperty) innerProperty; - flattenProperties(op.getProperties(), pathname); - - Model innerModel = modelFromProperty(op, modelName); - String existing = matchGenerated(innerModel); - if (existing != null) { - mp.setAdditionalProperties(new RefProperty(existing)); - } else { - mp.setAdditionalProperties(new RefProperty(modelName)); - addGenerated(modelName, innerModel); - swagger.addDefinition(modelName, innerModel); + if (op.getProperties() != null && op.getProperties().size() > 0) { + flattenProperties(op.getProperties(), pathname); + String modelName = uniqueName("inline_response_" + key); + Model innerModel = modelFromProperty(op, modelName); + String existing = matchGenerated(innerModel); + if (existing != null) { + mp.setAdditionalProperties(new RefProperty(existing)); + } else { + mp.setAdditionalProperties(new RefProperty(modelName)); + addGenerated(modelName, innerModel); + swagger.addDefinition(modelName, innerModel); + } } } } @@ -159,19 +165,21 @@ public class InlineModelResolver { ArrayModel m = (ArrayModel) model; Property inner = m.getItems(); if (inner instanceof ObjectProperty) { - String innerModelName = uniqueName(modelName + "_inner"); - Model innerModel = modelFromProperty((ObjectProperty) inner, modelName); - - String existing = matchGenerated(innerModel); - if (existing == null) { - swagger.addDefinition(innerModelName, innerModel); - addGenerated(innerModelName, innerModel); - m.setItems(new RefProperty(innerModelName)); - } else { - m.setItems(new RefProperty(existing)); + ObjectProperty op = (ObjectProperty) inner; + if (op.getProperties() != null && op.getProperties().size() > 0) { + String innerModelName = uniqueName(modelName + "_inner"); + Model innerModel = modelFromProperty(op, innerModelName); + String existing = matchGenerated(innerModel); + if (existing == null) { + swagger.addDefinition(innerModelName, innerModel); + addGenerated(innerModelName, innerModel); + m.setItems(new RefProperty(innerModelName)); + } else { + m.setItems(new RefProperty(existing)); + } } } - } + } } } } @@ -218,12 +226,9 @@ public class InlineModelResolver { Map modelsToAdd = new HashMap(); for (String key : properties.keySet()) { Property property = properties.get(key); - if(property instanceof ObjectProperty && ((ObjectProperty)property).getProperties() == null) { - MapProperty mp = new MapProperty(); - mp.setAdditionalProperties(new StringProperty()); - properties.put(key, mp); - } - else if (property instanceof ObjectProperty && ((ObjectProperty)property).getProperties().size() > 0) { + if (property instanceof ObjectProperty && + ((ObjectProperty)property).getProperties() != null && + ((ObjectProperty)property).getProperties().size() > 0) { String modelName = uniqueName(path + "_" + key); ObjectProperty op = (ObjectProperty) property; @@ -244,20 +249,19 @@ public class InlineModelResolver { Property inner = ap.getItems(); if (inner instanceof ObjectProperty) { - String modelName = uniqueName(path + "_" + key); - ObjectProperty op = (ObjectProperty) inner; - flattenProperties(op.getProperties(), path); - - Model innerModel = modelFromProperty(op, modelName); - String existing = matchGenerated(innerModel); - - if (existing != null) { - ap.setItems(new RefProperty(existing)); - } else { - ap.setItems(new RefProperty(modelName)); - addGenerated(modelName, innerModel); - swagger.addDefinition(modelName, innerModel); + if (op.getProperties() != null && op.getProperties().size() > 0) { + flattenProperties(op.getProperties(), path); + String modelName = uniqueName(path + "_" + key); + Model innerModel = modelFromProperty(op, modelName); + String existing = matchGenerated(innerModel); + if (existing != null) { + ap.setItems(new RefProperty(existing)); + } else { + ap.setItems(new RefProperty(modelName)); + addGenerated(modelName, innerModel); + swagger.addDefinition(modelName, innerModel); + } } } } else if (property instanceof MapProperty) { @@ -265,20 +269,19 @@ public class InlineModelResolver { Property inner = mp.getAdditionalProperties(); if (inner instanceof ObjectProperty) { - String modelName = uniqueName(path + "_" + key); - ObjectProperty op = (ObjectProperty) inner; - flattenProperties(op.getProperties(), path); - - Model innerModel = modelFromProperty(op, modelName); - String existing = matchGenerated(innerModel); - - if (existing != null) { - mp.setAdditionalProperties(new RefProperty(existing)); - } else { - mp.setAdditionalProperties(new RefProperty(modelName)); - addGenerated(modelName, innerModel); - swagger.addDefinition(modelName, innerModel); + if (op.getProperties() != null && op.getProperties().size() > 0) { + flattenProperties(op.getProperties(), path); + String modelName = uniqueName(path + "_" + key); + Model innerModel = modelFromProperty(op, modelName); + String existing = matchGenerated(innerModel); + if (existing != null) { + mp.setAdditionalProperties(new RefProperty(existing)); + } else { + mp.setAdditionalProperties(new RefProperty(modelName)); + addGenerated(modelName, innerModel); + swagger.addDefinition(modelName, innerModel); + } } } } diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java index 9102f06908f..f82e40bb41c 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/InlineModelResolverTest.java @@ -179,7 +179,7 @@ public class InlineModelResolverTest { assertTrue(inner instanceof RefProperty); RefProperty rp = (RefProperty) inner; - + assertEquals(rp.getType(), "ref"); assertEquals(rp.get$ref(), "#/definitions/body"); assertEquals(rp.getSimpleRef(), "body"); @@ -349,4 +349,287 @@ public class InlineModelResolverTest { Json.prettyPrint(swagger); } + + @Test + public void testArbitraryObjectBodyParam() { + Swagger swagger = new Swagger(); + + swagger.path("/hello", new Path() + .get(new Operation() + .parameter(new BodyParameter() + .name("body") + .schema(new ModelImpl())))); + + new InlineModelResolver().flatten(swagger); + + Operation operation = swagger.getPaths().get("/hello").getGet(); + BodyParameter bp = (BodyParameter)operation.getParameters().get(0); + assertTrue(bp.getSchema() instanceof ModelImpl); + ModelImpl m = (ModelImpl) bp.getSchema(); + assertNull(m.getType()); + } + + @Test + public void testArbitraryObjectBodyParamInline() { + Swagger swagger = new Swagger(); + + swagger.path("/hello", new Path() + .get(new Operation() + .parameter(new BodyParameter() + .name("body") + .schema(new ModelImpl() + .property("arbitrary", new ObjectProperty()))))); + + new InlineModelResolver().flatten(swagger); + + Operation operation = swagger.getPaths().get("/hello").getGet(); + BodyParameter bp = (BodyParameter)operation.getParameters().get(0); + assertTrue(bp.getSchema() instanceof RefModel); + + Model body = swagger.getDefinitions().get("body"); + assertTrue(body instanceof ModelImpl); + + ModelImpl impl = (ModelImpl) body; + Property p = impl.getProperties().get("arbitrary"); + assertNotNull(p); + assertTrue(p instanceof ObjectProperty); + } + + @Test + public void testArbitraryObjectBodyParamWithArray() { + Swagger swagger = new Swagger(); + + swagger.path("/hello", new Path() + .get(new Operation() + .parameter(new BodyParameter() + .name("body") + .schema(new ArrayModel() + .items(new ObjectProperty()))))); + + new InlineModelResolver().flatten(swagger); + + Parameter param = swagger.getPaths().get("/hello").getGet().getParameters().get(0); + assertTrue(param instanceof BodyParameter); + + BodyParameter bp = (BodyParameter) param; + Model schema = bp.getSchema(); + + assertTrue(schema instanceof ArrayModel); + + ArrayModel am = (ArrayModel) schema; + Property inner = am.getItems(); + assertTrue(inner instanceof ObjectProperty); + + ObjectProperty op = (ObjectProperty) inner; + assertNotNull(op); + assertNull(op.getProperties()); + } + + @Test + public void testArbitraryObjectBodyParamArrayInline() { + Swagger swagger = new Swagger(); + + swagger.path("/hello", new Path() + .get(new Operation() + .parameter(new BodyParameter() + .name("body") + .schema(new ArrayModel() + .items(new ObjectProperty() + .property("arbitrary", new ObjectProperty())))))); + + new InlineModelResolver().flatten(swagger); + + Parameter param = swagger.getPaths().get("/hello").getGet().getParameters().get(0); + assertTrue(param instanceof BodyParameter); + + BodyParameter bp = (BodyParameter) param; + Model schema = bp.getSchema(); + + assertTrue(schema instanceof ArrayModel); + + ArrayModel am = (ArrayModel) schema; + Property inner = am.getItems(); + assertTrue(inner instanceof RefProperty); + + RefProperty rp = (RefProperty) inner; + + assertEquals(rp.getType(), "ref"); + assertEquals(rp.get$ref(), "#/definitions/body"); + assertEquals(rp.getSimpleRef(), "body"); + + Model inline = swagger.getDefinitions().get("body"); + assertNotNull(inline); + assertTrue(inline instanceof ModelImpl); + ModelImpl impl = (ModelImpl) inline; + Property p = impl.getProperties().get("arbitrary"); + assertNotNull(p); + assertTrue(p instanceof ObjectProperty); + } + + @Test + public void testArbitraryObjectResponse() { + Swagger swagger = new Swagger(); + + swagger.path("/foo/bar", new Path() + .get(new Operation() + .response(200, new Response() + .description("it works!") + .schema(new ObjectProperty())))); + new InlineModelResolver().flatten(swagger); + + Map responses = swagger.getPaths().get("/foo/bar").getGet().getResponses(); + + Response response = responses.get("200"); + assertNotNull(response); + assertTrue(response.getSchema() instanceof ObjectProperty); + ObjectProperty op = (ObjectProperty) response.getSchema(); + assertNull(op.getProperties()); + } + + @Test + public void testArbitraryObjectResponseArray() { + Swagger swagger = new Swagger(); + + swagger.path("/foo/baz", new Path() + .get(new Operation() + .response(200, new Response() + .description("it works!") + .schema(new ArrayProperty() + .items(new ObjectProperty()))))); + new InlineModelResolver().flatten(swagger); + + Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200"); + assertTrue(response.getSchema() instanceof ArrayProperty); + + ArrayProperty am = (ArrayProperty) response.getSchema(); + Property items = am.getItems(); + assertTrue(items instanceof ObjectProperty); + ObjectProperty op = (ObjectProperty) items; + assertNull(op.getProperties()); + } + + @Test + public void testArbitraryObjectResponseArrayInline() { + Swagger swagger = new Swagger(); + + swagger.path("/foo/baz", new Path() + .get(new Operation() + .response(200, new Response() + .vendorExtension("x-foo", "bar") + .description("it works!") + .schema(new ArrayProperty() + .items(new ObjectProperty() + .property("arbitrary", new ObjectProperty())))))); + + new InlineModelResolver().flatten(swagger); + + Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200"); + assertNotNull(response); + + assertNotNull(response.getSchema()); + Property responseProperty = response.getSchema(); + assertTrue(responseProperty instanceof ArrayProperty); + + ArrayProperty ap = (ArrayProperty) responseProperty; + Property p = ap.getItems(); + assertNotNull(p); + + RefProperty rp = (RefProperty) p; + assertEquals(rp.getType(), "ref"); + assertEquals(rp.get$ref(), "#/definitions/inline_response_200"); + assertEquals(rp.getSimpleRef(), "inline_response_200"); + + Model inline = swagger.getDefinitions().get("inline_response_200"); + assertNotNull(inline); + assertTrue(inline instanceof ModelImpl); + ModelImpl impl = (ModelImpl) inline; + Property inlineProp = impl.getProperties().get("arbitrary"); + assertNotNull(inlineProp); + assertTrue(inlineProp instanceof ObjectProperty); + ObjectProperty op = (ObjectProperty) inlineProp; + assertNull(op.getProperties()); + } + + @Test + public void testArbitraryObjectResponseMapInline() { + Swagger swagger = new Swagger(); + + MapProperty schema = new MapProperty(); + schema.setAdditionalProperties(new ObjectProperty()); + + swagger.path("/foo/baz", new Path() + .get(new Operation() + .response(200, new Response() + .description("it works!") + .schema(schema)))); + new InlineModelResolver().flatten(swagger); + + Response response = swagger.getPaths().get("/foo/baz").getGet().getResponses().get("200"); + + Property property = response.getSchema(); + assertTrue(property instanceof MapProperty); + assertTrue(swagger.getDefinitions().size() == 0); + Property inlineProp = ((MapProperty) property).getAdditionalProperties(); + assertTrue(inlineProp instanceof ObjectProperty); + ObjectProperty op = (ObjectProperty) inlineProp; + assertNull(op.getProperties()); + } + + @Test + public void testArbitraryObjectModelInline() { + Swagger swagger = new Swagger(); + + swagger.addDefinition("User", new ModelImpl() + .name("user") + .description("a common user") + .property("name", new StringProperty()) + .property("arbitrary", new ObjectProperty() + .title("title") + ._default("default") + .access("access") + .readOnly(false) + .required(true) + .description("description") + .name("name"))); + + new InlineModelResolver().flatten(swagger); + + ModelImpl user = (ModelImpl)swagger.getDefinitions().get("User"); + assertNotNull(user); + Property inlineProp = user.getProperties().get("arbitrary"); + assertTrue(inlineProp instanceof ObjectProperty); + ObjectProperty op = (ObjectProperty) inlineProp; + assertNull(op.getProperties()); + } + + @Test + public void testArbitraryObjectModelWithArrayInline() { + Swagger swagger = new Swagger(); + + swagger.addDefinition("User", new ArrayModel() + .items(new ObjectProperty() + .title("title") + ._default("default") + .access("access") + .readOnly(false) + .required(true) + .description("description") + .name("name") + .property("arbitrary", new ObjectProperty()))); + + new InlineModelResolver().flatten(swagger); + + Model model = swagger.getDefinitions().get("User"); + assertTrue(model instanceof ArrayModel); + ArrayModel am = (ArrayModel) model; + Property inner = am.getItems(); + assertTrue(inner instanceof RefProperty); + + ModelImpl userInner = (ModelImpl)swagger.getDefinitions().get("User_inner"); + assertNotNull(userInner); + Property inlineProp = userInner.getProperties().get("arbitrary"); + assertTrue(inlineProp instanceof ObjectProperty); + ObjectProperty op = (ObjectProperty) inlineProp; + assertNull(op.getProperties()); + } } diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json index e11ee16fd33..fc6f7a4e0aa 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json +++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json @@ -309,6 +309,55 @@ ] } }, + "/pet/{petId}?response=inline_arbitrary_object": { + "get": { + "tags": [ + "pet" + ], + "summary": "Fake endpoint to test byte array return by 'Find pet by ID'", + "description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", + "operationId": "getPetByIdWithObject", + "produces": [ + "application/json", + "application/xml" + ], + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "404": { + "description": "Pet not found" + }, + "200": { + "description": "successful operation", + "schema": { + "$ref": "#/definitions/PetWithArbitraryObject" + } + }, + "400": { + "description": "Invalid ID supplied" + } + }, + "security": [ + { + "api_key": [] + }, + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, "/pet/{petId}": { "get": { "tags": [ @@ -536,6 +585,33 @@ ] } }, + "/store/inventory?response=arbitrary_object": { + "get": { + "tags": [ + "store" + ], + "summary": "Returns pet inventories by status", + "description": "Returns an arbitrary object which is actually a map of status codes to quantities", + "operationId": "getInventoryInObject", + "produces": [ + "application/json", + "application/xml" + ], + "responses": { + "200": { + "description": "successful operation", + "schema": { + "type": "object" + } + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, "/store/order": { "post": { "tags": [ @@ -1110,6 +1186,57 @@ "name": "Pet" } }, + "PetWithArbitraryObject": { + "required": [ + "name", + "photoUrls" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "category": { + "type": "object" + }, + "name": { + "type": "string", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "xml": { + "name": "photoUrl", + "wrapped": true + }, + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "xml": { + "name": "tag", + "wrapped": true + }, + "items": { + "$ref": "#/definitions/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + }, + "xml": { + "name": "PetWithArbitraryObject" + } + }, "Tag": { "properties": { "id": { 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 27aacf882bb..bddfd069a13 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 @@ -9,13 +9,14 @@ import io.swagger.client.Pair; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.PetWithArbitraryObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-29T12:55:35.772+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:54.084+08:00") public class PetApi { private ApiClient apiClient; @@ -405,6 +406,54 @@ public class PetApi { } + /** + * 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 PetWithArbitraryObject + * @throws ApiException if fails to make API call + */ + public PetWithArbitraryObject getPetByIdWithObject(Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdWithObject"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; + + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + + } + /** * 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 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 bf00bfb831a..272c9fe4b1b 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 @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-29T12:55:35.772+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:54.084+08:00") public class StoreApi { private ApiClient apiClient; @@ -120,6 +120,47 @@ public class StoreApi { } + /** + * Returns pet inventories by status + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + * @throws ApiException if fails to make API call + */ + public Object getInventoryInObject() throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key" }; + + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + + } + /** * Place an order for a pet * diff --git a/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java new file mode 100644 index 00000000000..d9fdcf1e916 --- /dev/null +++ b/samples/client/petstore/java/default/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java @@ -0,0 +1,199 @@ +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; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:54.084+08:00") +public class PetWithArbitraryObject { + + private Long id = null; + private Object category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + + + public enum StatusEnum { + AVAILABLE("available"), + PENDING("pending"), + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + + + /** + **/ + public PetWithArbitraryObject id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public PetWithArbitraryObject category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + **/ + public PetWithArbitraryObject name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", required = true, value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public PetWithArbitraryObject photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + public PetWithArbitraryObject tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + public PetWithArbitraryObject status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(example = "null", value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; + return Objects.equals(this.id, petWithArbitraryObject.id) && + Objects.equals(this.category, petWithArbitraryObject.category) && + Objects.equals(this.name, petWithArbitraryObject.name) && + Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && + Objects.equals(this.tags, petWithArbitraryObject.tags) && + Objects.equals(this.status, petWithArbitraryObject.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetWithArbitraryObject {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + 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 d9356ceea7a..025db31017b 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 @@ -4,6 +4,7 @@ import io.swagger.client.ApiClient; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.PetWithArbitraryObject; import java.util.ArrayList; import java.util.HashMap; @@ -11,7 +12,7 @@ import java.util.List; import java.util.Map; import feign.*; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-25T16:20:49.744+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00") public interface PetApi extends ApiClient.Api { @@ -43,8 +44,8 @@ public interface PetApi extends ApiClient.Api { /** * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * @param status Status values that need to be considered for filter + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for query * @return List */ @RequestLine("GET /pet/findByStatus?status={status}") @@ -125,6 +126,19 @@ 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 PetWithArbitraryObject + */ + @RequestLine("GET /pet/{petId}?response=inline_arbitrary_object") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + PetWithArbitraryObject getPetByIdWithObject(@Param("petId") Long petId); + /** * Fake endpoint to test byte array return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java index 7dd50c82e21..39cad855720 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/api/StoreApi.java @@ -10,10 +10,23 @@ import java.util.List; import java.util.Map; 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-03-02T21:04:56.888+08:00") public interface StoreApi extends ApiClient.Api { + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query + * @return List + */ + @RequestLine("GET /store/findByStatus?status={status}") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + List findOrdersByStatus(@Param("status") String status); + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -26,6 +39,18 @@ public interface StoreApi extends ApiClient.Api { }) Map getInventory(); + /** + * Returns pet inventories by status + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + */ + @RequestLine("GET /store/inventory?response=arbitrary_object") + @Headers({ + "Content-type: application/json", + "Accepts: application/json", + }) + Object getInventoryInObject(); + /** * Place an order for a pet * diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java new file mode 100644 index 00000000000..1f36205c611 --- /dev/null +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java @@ -0,0 +1,199 @@ +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; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:56.888+08:00") +public class PetWithArbitraryObject { + + private Long id = null; + private Object category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + + + public enum StatusEnum { + AVAILABLE("available"), + PENDING("pending"), + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + + + /** + **/ + public PetWithArbitraryObject id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public PetWithArbitraryObject category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + **/ + public PetWithArbitraryObject name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", required = true, value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public PetWithArbitraryObject photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + public PetWithArbitraryObject tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + public PetWithArbitraryObject status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(example = "null", value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; + return Objects.equals(this.id, petWithArbitraryObject.id) && + Objects.equals(this.category, petWithArbitraryObject.category) && + Objects.equals(this.name, petWithArbitraryObject.name) && + Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && + Objects.equals(this.tags, petWithArbitraryObject.tags) && + Objects.equals(this.status, petWithArbitraryObject.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetWithArbitraryObject {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + 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 a568a9e3dfd..f78c24df3c1 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 @@ -9,13 +9,14 @@ import javax.ws.rs.core.GenericType; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.PetWithArbitraryObject; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-29T12:55:37.248+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:55.453+08:00") public class PetApi { private ApiClient apiClient; @@ -405,6 +406,54 @@ public class PetApi { } + /** + * 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 PetWithArbitraryObject + * @throws ApiException if fails to make API call + */ + public PetWithArbitraryObject getPetByIdWithObject(Long petId) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException(400, "Missing the required parameter 'petId' when calling getPetByIdWithObject"); + } + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; + + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + + } + /** * 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 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 14c25968846..56d6f8e6b60 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 @@ -14,7 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-29T12:55:37.248+08:00") +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:55.453+08:00") public class StoreApi { private ApiClient apiClient; @@ -120,6 +120,47 @@ public class StoreApi { } + /** + * Returns pet inventories by status + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + * @throws ApiException if fails to make API call + */ + public Object getInventoryInObject() throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + + + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { "api_key" }; + + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + + } + /** * Place an order for a pet * diff --git a/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java new file mode 100644 index 00000000000..3a19cf49fa8 --- /dev/null +++ b/samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java @@ -0,0 +1,199 @@ +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; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + + + + + +@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-02T21:04:55.453+08:00") +public class PetWithArbitraryObject { + + private Long id = null; + private Object category = null; + private String name = null; + private List photoUrls = new ArrayList(); + private List tags = new ArrayList(); + + + public enum StatusEnum { + AVAILABLE("available"), + PENDING("pending"), + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + @JsonValue + public String toString() { + return value; + } + } + + private StatusEnum status = null; + + + /** + **/ + public PetWithArbitraryObject id(Long id) { + this.id = id; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("id") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + public PetWithArbitraryObject category(Object category) { + this.category = category; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("category") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + **/ + public PetWithArbitraryObject name(String name) { + this.name = name; + return this; + } + + @ApiModelProperty(example = "doggie", required = true, value = "") + @JsonProperty("name") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + public PetWithArbitraryObject photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + @ApiModelProperty(example = "null", required = true, value = "") + @JsonProperty("photoUrls") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + public PetWithArbitraryObject tags(List tags) { + this.tags = tags; + return this; + } + + @ApiModelProperty(example = "null", value = "") + @JsonProperty("tags") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + public PetWithArbitraryObject status(StatusEnum status) { + this.status = status; + return this; + } + + @ApiModelProperty(example = "null", value = "pet status in the store") + @JsonProperty("status") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; + return Objects.equals(this.id, petWithArbitraryObject.id) && + Objects.equals(this.category, petWithArbitraryObject.category) && + Objects.equals(this.name, petWithArbitraryObject.name) && + Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && + Objects.equals(this.tags, petWithArbitraryObject.tags) && + Objects.equals(this.status, petWithArbitraryObject.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetWithArbitraryObject {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + 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 4cc6c7d3051..033fd69c63d 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 @@ -19,6 +19,7 @@ import java.io.IOException; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.PetWithArbitraryObject; import java.lang.reflect.Type; import java.util.ArrayList; @@ -895,6 +896,114 @@ public class PetApi { return call; } + /* Build call for getPetByIdWithObject */ + private Call getPetByIdWithObjectCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + // verify the required parameter 'petId' is set + if (petId == null) { + throw new ApiException("Missing the required parameter 'petId' when calling getPetByIdWithObject(Async)"); + } + + + // create path and map variables + String localVarPath = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json") + .replaceAll("\\{" + "petId" + "\\}", apiClient.escapeString(petId.toString())); + + List localVarQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * 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 PetWithArbitraryObject + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public PetWithArbitraryObject getPetByIdWithObject(Long petId) throws ApiException { + ApiResponse resp = getPetByIdWithObjectWithHttpInfo(petId); + return resp.getData(); + } + + /** + * 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 ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getPetByIdWithObjectWithHttpInfo(Long petId) throws ApiException { + Call call = getPetByIdWithObjectCall(petId, null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' (asynchronously) + * 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 + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call getPetByIdWithObjectAsync(Long petId, final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = getPetByIdWithObjectCall(petId, progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /* Build call for petPetIdtestingByteArraytrueGet */ private Call petPetIdtestingByteArraytrueGetCall(Long petId, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = null; 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 3e11765bedc..d08d931c81a 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 @@ -248,6 +248,105 @@ public class StoreApi { return call; } + /* Build call for getInventoryInObject */ + private Call getInventoryInObjectCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Object localVarPostBody = null; + + + // create path and map variables + String localVarPath = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json"); + + List localVarQueryParams = new ArrayList(); + + Map localVarHeaderParams = new HashMap(); + + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json", "application/xml" + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + if(progressListener != null) { + apiClient.getHttpClient().networkInterceptors().add(new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + Response originalResponse = chain.proceed(chain.request()); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), progressListener)) + .build(); + } + }); + } + + String[] localVarAuthNames = new String[] { "api_key" }; + return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); + } + + /** + * Returns pet inventories by status + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public Object getInventoryInObject() throws ApiException { + ApiResponse resp = getInventoryInObjectWithHttpInfo(); + return resp.getData(); + } + + /** + * Returns pet inventories by status + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return ApiResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + */ + public ApiResponse getInventoryInObjectWithHttpInfo() throws ApiException { + Call call = getInventoryInObjectCall(null, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return apiClient.execute(call, localVarReturnType); + } + + /** + * Returns pet inventories by status (asynchronously) + * Returns an arbitrary object which is actually a map of status codes to quantities + * @param callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + */ + public Call getInventoryInObjectAsync(final ApiCallback callback) throws ApiException { + + ProgressResponseBody.ProgressListener progressListener = null; + ProgressRequestBody.ProgressRequestListener progressRequestListener = null; + + if (callback != null) { + progressListener = new ProgressResponseBody.ProgressListener() { + @Override + public void update(long bytesRead, long contentLength, boolean done) { + callback.onDownloadProgress(bytesRead, contentLength, done); + } + }; + + progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { + @Override + public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { + callback.onUploadProgress(bytesWritten, contentLength, done); + } + }; + } + + Call call = getInventoryInObjectCall(progressListener, progressRequestListener); + Type localVarReturnType = new TypeToken(){}.getType(); + apiClient.executeAsync(call, localVarReturnType, callback); + return call; + } + /* Build call for placeOrder */ private Call placeOrderCall(Order body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { Object localVarPostBody = body; diff --git a/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java new file mode 100644 index 00000000000..60d46909334 --- /dev/null +++ b/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java @@ -0,0 +1,176 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class PetWithArbitraryObject { + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + @SerializedName("tags") + private List tags = new ArrayList(); + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; + return Objects.equals(this.id, petWithArbitraryObject.id) && + Objects.equals(this.category, petWithArbitraryObject.category) && + Objects.equals(this.name, petWithArbitraryObject.name) && + Objects.equals(this.photoUrls, petWithArbitraryObject.photoUrls) && + Objects.equals(this.tags, petWithArbitraryObject.tags) && + Objects.equals(this.status, petWithArbitraryObject.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetWithArbitraryObject {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java index 7a6db104c81..4b4fc5ab5ce 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/PetApi.java @@ -8,6 +8,7 @@ import retrofit.mime.*; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.PetWithArbitraryObject; import java.util.ArrayList; import java.util.HashMap; @@ -71,8 +72,8 @@ public interface PetApi { /** * Finds Pets by status * Sync method - * Multiple status values can be provided with comma seperated strings - * @param status Status values that need to be considered for filter + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for query * @return List */ @@ -84,7 +85,7 @@ public interface PetApi { /** * Finds Pets by status * Async method - * @param status Status values that need to be considered for filter + * @param status Status values that need to be considered for query * @param cb callback method * @return void */ @@ -238,6 +239,32 @@ public interface PetApi { @Path("petId") Long petId, @Part("additionalMetadata") String additionalMetadata, @Part("file") TypedFile file, Callback cb ); + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Sync method + * 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 PetWithArbitraryObject + */ + + @GET("/pet/{petId}?response=inline_arbitrary_object") + PetWithArbitraryObject getPetByIdWithObject( + @Path("petId") Long petId + ); + + /** + * Fake endpoint to test byte array return by 'Find pet by ID' + * Async method + * @param petId ID of pet that needs to be fetched + * @param cb callback method + * @return void + */ + + @GET("/pet/{petId}?response=inline_arbitrary_object") + void getPetByIdWithObject( + @Path("petId") Long petId, Callback cb + ); + /** * Fake endpoint to test byte array return by 'Find pet by ID' * Sync method diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java index c0e56c36e94..7ee9852a505 100644 --- a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/api/StoreApi.java @@ -15,6 +15,32 @@ import java.util.Map; public interface StoreApi { + /** + * Finds orders by status + * Sync method + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query + * @return List + */ + + @GET("/store/findByStatus") + List findOrdersByStatus( + @Query("status") String status + ); + + /** + * Finds orders by status + * Async method + * @param status Status value that needs to be considered for query + * @param cb callback method + * @return void + */ + + @GET("/store/findByStatus") + void findOrdersByStatus( + @Query("status") String status, Callback> cb + ); + /** * Returns pet inventories by status * Sync method @@ -38,6 +64,29 @@ public interface StoreApi { Callback> cb ); + /** + * Returns pet inventories by status + * Sync method + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Object + */ + + @GET("/store/inventory?response=arbitrary_object") + Object getInventoryInObject(); + + + /** + * Returns pet inventories by status + * Async method + * @param cb callback method + * @return void + */ + + @GET("/store/inventory?response=arbitrary_object") + void getInventoryInObject( + Callback cb + ); + /** * Place an order for a pet * Sync method diff --git a/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java new file mode 100644 index 00000000000..ce3ec9ede16 --- /dev/null +++ b/samples/client/petstore/java/retrofit/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java @@ -0,0 +1,176 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class PetWithArbitraryObject { + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + @SerializedName("tags") + private List tags = new ArrayList(); + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; + return Objects.equals(id, petWithArbitraryObject.id) && + Objects.equals(category, petWithArbitraryObject.category) && + Objects.equals(name, petWithArbitraryObject.name) && + Objects.equals(photoUrls, petWithArbitraryObject.photoUrls) && + Objects.equals(tags, petWithArbitraryObject.tags) && + Objects.equals(status, petWithArbitraryObject.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetWithArbitraryObject {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java index 58eb090f9eb..9fb0c97939c 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/PetApi.java @@ -10,6 +10,7 @@ import okhttp3.RequestBody; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.PetWithArbitraryObject; import java.util.ArrayList; import java.util.HashMap; @@ -46,8 +47,8 @@ public interface PetApi { /** * Finds Pets by status - * Multiple status values can be provided with comma seperated strings - * @param status Status values that need to be considered for filter + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for query * @return Call> */ @@ -129,6 +130,19 @@ public interface PetApi { ); + /** + * 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 Call + */ + + @GET("pet/{petId}?response=inline_arbitrary_object") + Call getPetByIdWithObject( + @Path("petId") Long petId + ); + + /** * Fake endpoint to test byte array return by 'Find pet by ID' * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java index 6277aa58e0c..9a0b29ecb82 100644 --- a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/api/StoreApi.java @@ -17,6 +17,19 @@ import java.util.Map; public interface StoreApi { + /** + * Finds orders by status + * A single status value can be provided as a string + * @param status Status value that needs to be considered for query + * @return Call> + */ + + @GET("store/findByStatus") + Call> findOrdersByStatus( + @Query("status") String status + ); + + /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -28,6 +41,17 @@ public interface StoreApi { + /** + * Returns pet inventories by status + * Returns an arbitrary object which is actually a map of status codes to quantities + * @return Call + */ + + @GET("store/inventory?response=arbitrary_object") + Call getInventoryInObject(); + + + /** * Place an order for a pet * diff --git a/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java new file mode 100644 index 00000000000..ce3ec9ede16 --- /dev/null +++ b/samples/client/petstore/java/retrofit2/src/main/java/io/swagger/client/model/PetWithArbitraryObject.java @@ -0,0 +1,176 @@ +package io.swagger.client.model; + +import java.util.Objects; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.client.model.Tag; +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + + + + +@ApiModel(description = "") +public class PetWithArbitraryObject { + + @SerializedName("id") + private Long id = null; + + @SerializedName("category") + private Object category = null; + + @SerializedName("name") + private String name = null; + + @SerializedName("photoUrls") + private List photoUrls = new ArrayList(); + + @SerializedName("tags") + private List tags = new ArrayList(); + + +public enum StatusEnum { + @SerializedName("available") + AVAILABLE("available"), + + @SerializedName("pending") + PENDING("pending"), + + @SerializedName("sold") + SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @Override + public String toString() { + return value; + } +} + + @SerializedName("status") + private StatusEnum status = null; + + + + /** + **/ + @ApiModelProperty(value = "") + public Long getId() { + return id; + } + public void setId(Long id) { + this.id = id; + } + + + /** + **/ + @ApiModelProperty(value = "") + public Object getCategory() { + return category; + } + public void setCategory(Object category) { + this.category = category; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + + /** + **/ + @ApiModelProperty(required = true, value = "") + public List getPhotoUrls() { + return photoUrls; + } + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + + /** + **/ + @ApiModelProperty(value = "") + public List getTags() { + return tags; + } + public void setTags(List tags) { + this.tags = tags; + } + + + /** + * pet status in the store + **/ + @ApiModelProperty(value = "pet status in the store") + public StatusEnum getStatus() { + return status; + } + public void setStatus(StatusEnum status) { + this.status = status; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PetWithArbitraryObject petWithArbitraryObject = (PetWithArbitraryObject) o; + return Objects.equals(id, petWithArbitraryObject.id) && + Objects.equals(category, petWithArbitraryObject.category) && + Objects.equals(name, petWithArbitraryObject.name) && + Objects.equals(photoUrls, petWithArbitraryObject.photoUrls) && + Objects.equals(tags, petWithArbitraryObject.tags) && + Objects.equals(status, petWithArbitraryObject.status); + } + + @Override + public int hashCode() { + return Objects.hash(id, category, name, photoUrls, tags, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PetWithArbitraryObject {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +}