From 9311dcaccbfac1d8beda29a6017be217f462b399 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 18:39:54 +0800 Subject: [PATCH 01/13] update codegen to support global consumes and produces --- .../io/swagger/codegen/CodegenConfig.java | 2 + .../io/swagger/codegen/DefaultCodegen.java | 40 +++++++++++++++---- .../io/swagger/codegen/DefaultGenerator.java | 2 +- .../codegen/languages/SwiftCodegen.java | 6 ++- .../petstore/objc/SwaggerClient.podspec | 8 ++-- .../petstore/objc/SwaggerClient/SWGOrder.h | 2 +- .../petstore/objc/SwaggerClient/SWGOrder.m | 4 +- .../petstore/objc/SwaggerClient/SWGPet.h | 2 +- .../petstore/objc/SwaggerClient/SWGPetApi.m | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.h | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.m | 2 +- .../php/SwaggerClient-php/lib/Api/PetApi.php | 31 -------------- .../SwaggerClient-php/lib/Api/StoreApi.php | 7 ---- .../lib/ObjectSerializer.php | 2 +- 14 files changed, 52 insertions(+), 60 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index 10d7363cc3..b50147a6ff 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -67,6 +67,8 @@ public interface CodegenConfig { CodegenModel fromModel(String name, Model model, Map allDefinitions); + CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map definitions, Swagger swagger); + CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map definitions); List fromSecurity(Map schemes); 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 efc0aa31db..d0185c0ad0 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 @@ -861,8 +861,12 @@ public class DefaultCodegen { } return responses.get(code); } - + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions) { + return fromOperation(path, httpMethod, operation, definitions, null); + } + + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions, Swagger swagger) { CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION); Set imports = new HashSet(); op.vendorExtensions = operation.getVendorExtensions(); @@ -899,14 +903,25 @@ public class DefaultCodegen { op.notes = escapeText(operation.getDescription()); op.tags = operation.getTags(); - if (operation.getConsumes() != null && operation.getConsumes().size() > 0) { + List consumes = new ArrayList(); + if (operation.getConsumes() != null && operation.getConsumes().size() > 0) { + // use consumes defined in the operation + consumes = operation.getConsumes(); + } else if (swagger != null && swagger.getConsumes() != null && swagger.getConsumes().size() > 0) { + // use consumes defined globally + consumes = swagger.getConsumes(); + LOGGER.debug("Using global consumes (" + swagger.getConsumes() + ") for " + op.operationId); + } + + // if "consumes" is defined (per operation or using global definition) + if (consumes != null && consumes.size() > 0) { List> c = new ArrayList>(); int count = 0; - for (String key : operation.getConsumes()) { + for (String key : consumes) { Map mediaType = new HashMap(); mediaType.put("mediaType", key); count += 1; - if (count < operation.getConsumes().size()) { + if (count < consumes.size()) { mediaType.put("hasMore", "true"); } else { mediaType.put("hasMore", null); @@ -917,14 +932,25 @@ public class DefaultCodegen { op.hasConsumes = true; } - if (operation.getProduces() != null && operation.getProduces().size() > 0) { + List produces = new ArrayList(); + if (operation.getProduces() != null && operation.getProduces().size() > 0) { + // use produces defined in the operation + produces = operation.getProduces(); + } else if (swagger != null && swagger.getProduces() != null && swagger.getProduces().size() > 0) { + // use produces defined globally + produces = swagger.getProduces(); + LOGGER.debug("Using global produces (" + swagger.getProduces() + ") for " + op.operationId); + } + + // if "produces" is defined (per operation or using global definition) + if (produces != null && produces.size() > 0) { List> c = new ArrayList>(); int count = 0; - for (String key : operation.getProduces()) { + for (String key : produces) { Map mediaType = new HashMap(); mediaType.put("mediaType", key); count += 1; - if (count < operation.getProduces().size()) { + if (count < produces.size()) { mediaType.put("hasMore", "true"); } else { mediaType.put("hasMore", null); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index a785f45bdf..2b61635e0b 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -470,7 +470,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String tag : tags) { CodegenOperation co = null; try { - co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions()); + co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions(), swagger); co.tags = new ArrayList(); co.tags.add(sanitizeTag(tag)); config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 55c3864adb..9bb1dfd61d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -1,9 +1,11 @@ package io.swagger.codegen.languages; import com.google.common.base.Predicate; + import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import io.swagger.codegen.*; +import io.swagger.models.Swagger; import io.swagger.models.Model; import io.swagger.models.Operation; import io.swagger.models.parameters.HeaderParameter; @@ -256,7 +258,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { } @Override - public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions) { + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions, Swagger swagger) { path = normalizePath(path); List parameters = operation.getParameters(); parameters = Lists.newArrayList(Iterators.filter(parameters.iterator(), new Predicate() { @@ -266,7 +268,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { } })); operation.setParameters(parameters); - return super.fromOperation(path, httpMethod, operation, definitions); + return super.fromOperation(path, httpMethod, operation, definitions, swagger); } private static String normalizePath(String path) { diff --git a/samples/client/petstore/objc/SwaggerClient.podspec b/samples/client/petstore/objc/SwaggerClient.podspec index 4445bc52ad..0afb511073 100644 --- a/samples/client/petstore/objc/SwaggerClient.podspec +++ b/samples/client/petstore/objc/SwaggerClient.podspec @@ -21,10 +21,10 @@ Pod::Spec.new do |s| s.framework = 'SystemConfiguration' - s.homepage = "" - s.license = "" - s.source = { :git => ".git", :tag => "#{s.version}" } - s.author = { "" => "" } + s.homepage = "https://github.com/swagger-api/swagger-codegen" + s.license = "MIT" + s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" } + s.author = { "Swagger" => "apiteam@swagger.io" } s.source_files = 'SwaggerClient/**/*' s.public_header_files = 'SwaggerClient/**/*.h' diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h index 48a7cf0d6c..4b132c57be 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h @@ -26,6 +26,6 @@ */ @property(nonatomic) NSString* status; -@property(nonatomic) NSNumber* complete; +@property(nonatomic) NSString* count; @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index 83fe5741cd..8bf5f75c5a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -8,7 +8,7 @@ */ + (JSONKeyMapper *)keyMapper { - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"count": @"count" }]; } /** @@ -18,7 +18,7 @@ */ + (BOOL)propertyIsOptional:(NSString *)propertyName { - NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; + NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"count"]; if ([optionalProperties containsObject:propertyName]) { return YES; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h index 84f10969e5..e340e0e2b8 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h @@ -7,8 +7,8 @@ * Do not edit the class manually. */ -#import "SWGCategory.h" #import "SWGTag.h" +#import "SWGCategory.h" @protocol SWGPet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index b890e03570..156700c9a7 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -450,7 +450,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth", @"api_key"]; + NSArray *authSettings = @[@"api_key", @"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h index ec41ecd990..21f314684f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h @@ -99,7 +99,7 @@ /// Get user by user name /// /// -/// @param username The name that needs to be fetched. Use user1 for testing. +/// @param username The name that needs to be fetched. Use user1 for testing. /// /// /// @return SWGUser* diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 5c3c313b2e..75cf8d51b0 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -470,7 +470,7 @@ static SWGUserApi* singletonAPI = nil; /// /// Get user by user name /// -/// @param username The name that needs to be fetched. Use user1 for testing. +/// @param username The name that needs to be fetched. Use user1 for testing. /// /// @returns SWGUser* /// diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index e8dea97be9..57af48845e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -135,9 +135,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { @@ -200,9 +197,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { @@ -264,9 +258,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { @@ -340,9 +331,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { @@ -424,16 +412,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - - $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); - if (isset($apiKey)) { - $headerParams['api_key'] = $apiKey; - } - - - // make the API Call try { @@ -523,9 +501,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { @@ -599,9 +574,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { @@ -679,9 +651,6 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } - - //TODO support oauth - // make the API Call try { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index b64b52d222..1b0f955869 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -130,13 +130,6 @@ class StoreApi $httpBody = $formParams; // for HTTP post (form) } - $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); - if (isset($apiKey)) { - $headerParams['api_key'] = $apiKey; - } - - - // make the API Call try { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index efdc1c896a..0d281b9d1f 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -193,7 +193,7 @@ class ObjectSerializer $deserialized = $values; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); - } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { + } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { From 5144c54895c04a0c58a5d25521721507c36bc2fd Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 22:47:24 +0800 Subject: [PATCH 02/13] add test case for global consumes and produces --- .../io/swagger/codegen/DefaultCodegen.java | 26 ++++++---- .../java/io/swagger/codegen/CodegenTest.java | 48 +++++++++++++++++++ 2 files changed, 66 insertions(+), 8 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 d0185c0ad0..558f22bc0a 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 @@ -902,15 +902,21 @@ public class DefaultCodegen { op.summary = escapeText(operation.getSummary()); op.notes = escapeText(operation.getDescription()); op.tags = operation.getTags(); + op.hasConsumes = false; + op.hasProduces = false; List consumes = new ArrayList(); - if (operation.getConsumes() != null && operation.getConsumes().size() > 0) { - // use consumes defined in the operation - consumes = operation.getConsumes(); + if (operation.getConsumes() != null) { + if (operation.getConsumes().size() > 0) { + // use consumes defined in the operation + consumes = operation.getConsumes(); + } else { + // empty list, do nothing to override global setting + } } else if (swagger != null && swagger.getConsumes() != null && swagger.getConsumes().size() > 0) { // use consumes defined globally consumes = swagger.getConsumes(); - LOGGER.debug("Using global consumes (" + swagger.getConsumes() + ") for " + op.operationId); + LOGGER.debug("No consumes defined in operation. Using global consumes (" + swagger.getConsumes() + ") for " + op.operationId); } // if "consumes" is defined (per operation or using global definition) @@ -933,13 +939,17 @@ public class DefaultCodegen { } List produces = new ArrayList(); - if (operation.getProduces() != null && operation.getProduces().size() > 0) { - // use produces defined in the operation - produces = operation.getProduces(); + if (operation.getProduces() != null) { + if (operation.getProduces().size() > 0) { + // use produces defined in the operation + produces = operation.getProduces(); + } else { + // empty list, do nothing to override global setting + } } else if (swagger != null && swagger.getProduces() != null && swagger.getProduces().size() > 0) { // use produces defined globally produces = swagger.getProduces(); - LOGGER.debug("Using global produces (" + swagger.getProduces() + ") for " + op.operationId); + LOGGER.debug("No produces defined in operation. Using global produces (" + swagger.getProduces() + ") for " + op.operationId); } // if "produces" is defined (per operation or using global definition) diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java index ee70b427bf..68ebb349e6 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java @@ -139,4 +139,52 @@ public class CodegenTest { Assert.assertTrue(op.bodyParam.isBinary); Assert.assertTrue(op.responses.get(0).isBinary); } + + @Test(description = "use operation consumes and producus") + public void localConsumesAndProducesTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); + final DefaultCodegen codegen = new DefaultCodegen(); + final String path = "/tests/localConsumesAndProduces"; + final Operation p = model.getPaths().get(path).getGet(); + CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model); + + Assert.assertTrue(op.hasConsumes); + Assert.assertEquals(op.consumes.size(), 1); + Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/json"); + Assert.assertTrue(op.hasProduces); + Assert.assertEquals(op.produces.size(), 1); + Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/json"); + } + + @Test(description = "use spec consumes and producus") + public void globalConsumesAndProducesTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); + final DefaultCodegen codegen = new DefaultCodegen(); + final String path = "/tests/globalConsumesAndProduces"; + final Operation p = model.getPaths().get(path).getGet(); + CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model); + + Assert.assertTrue(op.hasConsumes); + Assert.assertEquals(op.consumes.size(), 1); + Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/global_consumes"); + Assert.assertTrue(op.hasProduces); + Assert.assertEquals(op.produces.size(), 1); + Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/global_produces"); + } + + @Test(description = "use spec consumes and producus (reset in operation with empty array)") + public void localResetConsumesAndProducesTest() { + final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); + final DefaultCodegen codegen = new DefaultCodegen(); + final String path = "/tests/localResetConsumesAndProduces"; + final Operation p = model.getPaths().get(path).getGet(); + CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model); + + Assert.assertNotNull(op); + Assert.assertFalse(op.hasConsumes); + Assert.assertNull(op.consumes); + Assert.assertFalse(op.hasProduces); + Assert.assertNull(op.produces); + + } } From 64fd94262f1b36a98e60328b4453290e4a370bb1 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 22:54:13 +0800 Subject: [PATCH 03/13] add globalConsumesAndProduces.json --- .../2_0/globalConsumesAndProduces.json | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json diff --git a/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json new file mode 100644 index 0000000000..221d00b6da --- /dev/null +++ b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json @@ -0,0 +1,149 @@ +{ + "swagger": "2.0", + "info": { + "description": "Spec for testing global consumes and produces", + "version": "1.0.0", + "title": "Swagger Petstore", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "email": "apiteam@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "host": "petstore.swagger.io", + "basePath": "/v2", + "consumes": ["application/global_consumes"], + "produces": ["application/global_produces"], + "schemes": [ + "http" + ], + "paths": { + "/tests/localConsumesAndProduces": { + "get": { + "tags": [ + "tests" + ], + "summary": "Operation with local consumes and produces", + "description": "", + "operationId": "localConsumesAndProduces", + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "parameters": [ + ], + "responses": { + "200": { + "description": "successful operation. Returning a simple int.", + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "post": { + "tags": [ + "tests" + ], + "summary": "Operation with global consumes and produces", + "description": "", + "operationId": "globalConsumesAndProduces", + "parameters": [ + ], + "responses": { + "200": { + "description": "successful operation. Returning a simple int.", + "schema": { + "type": "integer", + "format": "int64" + } + } + } + } + }, + "/tests/globalConsumesAndProduces": { + "get": { + "tags": [ + "tests" + ], + "summary": "Operation with global consumes and produces", + "description": "", + "operationId": "globalConsumesAndProduces", + "parameters": [ + ], + "responses": { + "200": { + "description": "successful operation. Returning a simple int.", + "schema": { + "type": "integer", + "format": "int64" + } + } + } + } + }, + "/tests/localResetConsumesAndProduces": { + "get": { + "tags": [ + "tests" + ], + "summary": "Operation with local consumes and produces set to empty (reset)", + "description": "", + "operationId": "localResetConsumesAndProduces", + "parameters": [ + ], + "consumes": [], + "produces": [], + "responses": { + "200": { + "description": "successful operation. Returning a simple int.", + "schema": { + "type": "integer", + "format": "int64" + } + } + } + } + } + + }, + "securityDefinitions": { + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + }, + "petstore_auth": { + "type": "oauth2", + "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", + "flow": "implicit", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + }, + "definitions": { + "CustomModel": { + "required": [ + "id" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string", + "example": "doggie" + } + } + } + } +} \ No newline at end of file From 6cc5a32d4013cd405aa83cfd377302273e3cbbbd Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 23:09:41 +0800 Subject: [PATCH 04/13] update objc sample --- .../petstore/objc/SwaggerClient/SWGApiClient.m | 15 ++++++++++----- .../objc/SwaggerClient/SWGConfiguration.m | 7 ------- .../petstore/objc/SwaggerClient/SWGOrder.h | 2 +- .../petstore/objc/SwaggerClient/SWGOrder.m | 4 ++-- .../petstore/objc/SwaggerClient/SWGPetApi.m | 16 ++++++++-------- .../petstore/objc/SwaggerClient/SWGStoreApi.m | 2 +- samples/client/petstore/ruby/lib/petstore.rb | 2 +- .../petstore/ruby/lib/petstore/api/pet_api.rb | 16 ++++++++-------- .../petstore/ruby/lib/petstore/api/store_api.rb | 2 +- .../petstore/ruby/lib/petstore/api/user_api.rb | 2 +- .../petstore/ruby/lib/petstore/api_client.rb | 2 -- .../petstore/ruby/lib/petstore/configuration.rb | 7 ------- 12 files changed, 33 insertions(+), 44 deletions(-) diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index fc3c790786..dcd33575fc 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -311,9 +311,10 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; - resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [resultArray addObject:[self deserialize:obj class:innerType]]; } @@ -332,9 +333,10 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; - resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [resultArray addObject:[self deserialize:obj class:innerType]]; }]; @@ -352,9 +354,10 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + NSDictionary *dataDict = data; NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]]; - resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]]; + resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; }]; @@ -728,7 +731,8 @@ static void (^reachabilityChangeBlock)(int); return [object ISO8601String]; } else if ([object isKindOfClass:[NSArray class]]) { - NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; + NSArray *objectArray = object; + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]]; [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { if (obj) { [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; @@ -737,7 +741,8 @@ static void (^reachabilityChangeBlock)(int); return sanitizedObjs; } else if ([object isKindOfClass:[NSDictionary class]]) { - NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; + NSDictionary *objectDict = object; + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]]; [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { if (obj) { [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 16ce311c59..3f1f926b33 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -107,13 +107,6 @@ - (NSDictionary *) authSettings { return @{ - @"api_key": - @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"api_key", - @"value": [self getApiKeyWithPrefix:@"api_key"] - }, }; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h index 4b132c57be..48a7cf0d6c 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h @@ -26,6 +26,6 @@ */ @property(nonatomic) NSString* status; -@property(nonatomic) NSString* count; +@property(nonatomic) NSNumber* complete; @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index 8bf5f75c5a..83fe5741cd 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -8,7 +8,7 @@ */ + (JSONKeyMapper *)keyMapper { - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"count": @"count" }]; + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; } /** @@ -18,7 +18,7 @@ */ + (BOOL)propertyIsOptional:(NSString *)propertyName { - NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"count"]; + NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; if ([optionalProperties containsObject:propertyName]) { return YES; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 156700c9a7..64ff58e31e 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -118,7 +118,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -196,7 +196,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -280,7 +280,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -364,7 +364,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -450,7 +450,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -542,7 +542,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -646,7 +646,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -738,7 +738,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index 5fdf86b43a..8450022164 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -115,7 +115,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index c13e99f29f..61640d687a 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -14,8 +14,8 @@ require 'petstore/models/order' # APIs require 'petstore/api/user_api' -require 'petstore/api/store_api' require 'petstore/api/pet_api' +require 'petstore/api/store_api' module Petstore class << self diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index a9d30a0014..bb1b66c19a 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -42,7 +42,7 @@ module Petstore post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, @@ -89,7 +89,7 @@ module Petstore post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, @@ -137,7 +137,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -186,7 +186,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -237,7 +237,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -292,7 +292,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, @@ -344,7 +344,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, @@ -398,7 +398,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 235ff1c410..b33aa87a50 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -41,7 +41,7 @@ module Petstore post_body = nil - auth_names = ['api_key'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index f4672e2a35..7f546330f3 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -248,7 +248,7 @@ module Petstore # Get user by user name # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 4f747bcd6a..77e9c44871 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -62,8 +62,6 @@ module Petstore form_params = opts[:form_params] || {} - update_params_for_auth! header_params, query_params, opts[:auth_names] - req_opts = { :method => http_method, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 008be48ee4..5e333ee79e 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -160,13 +160,6 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'api_key' => - { - type: 'api_key', - in: 'header', - key: 'api_key', - value: api_key_with_prefix('api_key') - }, } end end From 9ecb2e92ae83e05eac75552ae3844faf056f335a Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 23:13:26 +0800 Subject: [PATCH 05/13] restore sample files for objc, php and ruby --- .../petstore/objc/SwaggerClient.podspec | 8 ++--- .../objc/SwaggerClient/SWGApiClient.m | 15 +++------ .../objc/SwaggerClient/SWGConfiguration.m | 7 +++++ .../petstore/objc/SwaggerClient/SWGPet.h | 2 +- .../petstore/objc/SwaggerClient/SWGPetApi.m | 16 +++++----- .../petstore/objc/SwaggerClient/SWGStoreApi.m | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.h | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.m | 2 +- .../php/SwaggerClient-php/lib/Api/PetApi.php | 31 +++++++++++++++++++ .../SwaggerClient-php/lib/Api/StoreApi.php | 7 +++++ .../lib/ObjectSerializer.php | 2 +- samples/client/petstore/ruby/lib/petstore.rb | 2 +- .../petstore/ruby/lib/petstore/api/pet_api.rb | 16 +++++----- .../ruby/lib/petstore/api/store_api.rb | 2 +- .../ruby/lib/petstore/api/user_api.rb | 2 +- .../petstore/ruby/lib/petstore/api_client.rb | 2 ++ .../ruby/lib/petstore/configuration.rb | 7 +++++ 17 files changed, 87 insertions(+), 38 deletions(-) diff --git a/samples/client/petstore/objc/SwaggerClient.podspec b/samples/client/petstore/objc/SwaggerClient.podspec index 0afb511073..4445bc52ad 100644 --- a/samples/client/petstore/objc/SwaggerClient.podspec +++ b/samples/client/petstore/objc/SwaggerClient.podspec @@ -21,10 +21,10 @@ Pod::Spec.new do |s| s.framework = 'SystemConfiguration' - s.homepage = "https://github.com/swagger-api/swagger-codegen" - s.license = "MIT" - s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" } - s.author = { "Swagger" => "apiteam@swagger.io" } + s.homepage = "" + s.license = "" + s.source = { :git => ".git", :tag => "#{s.version}" } + s.author = { "" => "" } s.source_files = 'SwaggerClient/**/*' s.public_header_files = 'SwaggerClient/**/*.h' diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index dcd33575fc..fc3c790786 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -311,10 +311,9 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { - NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; - resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; + resultArray = [NSMutableArray arrayWithCapacity:[data count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [resultArray addObject:[self deserialize:obj class:innerType]]; } @@ -333,10 +332,9 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { - NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; - resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; + resultArray = [NSMutableArray arrayWithCapacity:[data count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [resultArray addObject:[self deserialize:obj class:innerType]]; }]; @@ -354,10 +352,9 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { - NSDictionary *dataDict = data; NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]]; - resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; + resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; }]; @@ -731,8 +728,7 @@ static void (^reachabilityChangeBlock)(int); return [object ISO8601String]; } else if ([object isKindOfClass:[NSArray class]]) { - NSArray *objectArray = object; - NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]]; + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { if (obj) { [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; @@ -741,8 +737,7 @@ static void (^reachabilityChangeBlock)(int); return sanitizedObjs; } else if ([object isKindOfClass:[NSDictionary class]]) { - NSDictionary *objectDict = object; - NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]]; + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { if (obj) { [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 3f1f926b33..16ce311c59 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -107,6 +107,13 @@ - (NSDictionary *) authSettings { return @{ + @"api_key": + @{ + @"type": @"api_key", + @"in": @"header", + @"key": @"api_key", + @"value": [self getApiKeyWithPrefix:@"api_key"] + }, }; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h index e340e0e2b8..84f10969e5 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h @@ -7,8 +7,8 @@ * Do not edit the class manually. */ -#import "SWGTag.h" #import "SWGCategory.h" +#import "SWGTag.h" @protocol SWGPet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 64ff58e31e..b890e03570 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -118,7 +118,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -196,7 +196,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -280,7 +280,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -364,7 +364,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -450,7 +450,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth", @"api_key"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -542,7 +542,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -646,7 +646,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -738,7 +738,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index 8450022164..5fdf86b43a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -115,7 +115,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[]; + NSArray *authSettings = @[@"api_key"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h index 21f314684f..ec41ecd990 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h @@ -99,7 +99,7 @@ /// Get user by user name /// /// -/// @param username The name that needs to be fetched. Use user1 for testing. +/// @param username The name that needs to be fetched. Use user1 for testing. /// /// /// @return SWGUser* diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 75cf8d51b0..5c3c313b2e 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -470,7 +470,7 @@ static SWGUserApi* singletonAPI = nil; /// /// Get user by user name /// -/// @param username The name that needs to be fetched. Use user1 for testing. +/// @param username The name that needs to be fetched. Use user1 for testing. /// /// @returns SWGUser* /// diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index 57af48845e..e8dea97be9 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -135,6 +135,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { @@ -197,6 +200,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { @@ -258,6 +264,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { @@ -331,6 +340,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { @@ -412,6 +424,16 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + + $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); + if (isset($apiKey)) { + $headerParams['api_key'] = $apiKey; + } + + + // make the API Call try { @@ -501,6 +523,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { @@ -574,6 +599,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { @@ -651,6 +679,9 @@ class PetApi $httpBody = $formParams; // for HTTP post (form) } + + //TODO support oauth + // make the API Call try { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index 1b0f955869..b64b52d222 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -130,6 +130,13 @@ class StoreApi $httpBody = $formParams; // for HTTP post (form) } + $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); + if (isset($apiKey)) { + $headerParams['api_key'] = $apiKey; + } + + + // make the API Call try { diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php index 0d281b9d1f..efdc1c896a 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php @@ -193,7 +193,7 @@ class ObjectSerializer $deserialized = $values; } elseif ($class === '\DateTime') { $deserialized = new \DateTime($data); - } elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { + } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) { settype($data, $class); $deserialized = $data; } elseif ($class === '\SplFileObject') { diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index 61640d687a..c13e99f29f 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -14,8 +14,8 @@ require 'petstore/models/order' # APIs require 'petstore/api/user_api' -require 'petstore/api/pet_api' require 'petstore/api/store_api' +require 'petstore/api/pet_api' module Petstore class << self diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index bb1b66c19a..a9d30a0014 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -42,7 +42,7 @@ module Petstore post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] + auth_names = ['petstore_auth'] @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, @@ -89,7 +89,7 @@ module Petstore post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = [] + auth_names = ['petstore_auth'] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, @@ -137,7 +137,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['petstore_auth'] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -186,7 +186,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['petstore_auth'] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -237,7 +237,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['petstore_auth', 'api_key'] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -292,7 +292,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['petstore_auth'] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, @@ -344,7 +344,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['petstore_auth'] @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, @@ -398,7 +398,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['petstore_auth'] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index b33aa87a50..235ff1c410 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -41,7 +41,7 @@ module Petstore post_body = nil - auth_names = [] + auth_names = ['api_key'] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index 7f546330f3..f4672e2a35 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -248,7 +248,7 @@ module Petstore # Get user by user name # - # @param username The name that needs to be fetched. Use user1 for testing. + # @param username The name that needs to be fetched. Use user1 for testing. # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 77e9c44871..4f747bcd6a 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -62,6 +62,8 @@ module Petstore form_params = opts[:form_params] || {} + update_params_for_auth! header_params, query_params, opts[:auth_names] + req_opts = { :method => http_method, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 5e333ee79e..008be48ee4 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -160,6 +160,13 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { + 'api_key' => + { + type: 'api_key', + in: 'header', + key: 'api_key', + value: api_key_with_prefix('api_key') + }, } end end From 5cd01af35059c4424040aa5c558e2f58dbdaaa31 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 23:22:42 +0800 Subject: [PATCH 06/13] fix typo in test cases --- .../src/test/java/io/swagger/codegen/CodegenTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java index 68ebb349e6..0fa8953e7b 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java @@ -140,7 +140,7 @@ public class CodegenTest { Assert.assertTrue(op.responses.get(0).isBinary); } - @Test(description = "use operation consumes and producus") + @Test(description = "use operation consumes and produces") public void localConsumesAndProducesTest() { final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); final DefaultCodegen codegen = new DefaultCodegen(); @@ -156,7 +156,7 @@ public class CodegenTest { Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/json"); } - @Test(description = "use spec consumes and producus") + @Test(description = "use spec consumes and produces") public void globalConsumesAndProducesTest() { final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); final DefaultCodegen codegen = new DefaultCodegen(); @@ -172,7 +172,7 @@ public class CodegenTest { Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/global_produces"); } - @Test(description = "use spec consumes and producus (reset in operation with empty array)") + @Test(description = "use operation consumes and produces (reset in operation with empty array)") public void localResetConsumesAndProducesTest() { final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); final DefaultCodegen codegen = new DefaultCodegen(); From 00517a1ad3a5f98e513064f9186197b5628b6b57 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 23:27:21 +0800 Subject: [PATCH 07/13] remove unused operation in test json file --- .../2_0/globalConsumesAndProduces.json | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json index 221d00b6da..520218ed70 100644 --- a/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json +++ b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json @@ -46,26 +46,7 @@ } } } - }, - "post": { - "tags": [ - "tests" - ], - "summary": "Operation with global consumes and produces", - "description": "", - "operationId": "globalConsumesAndProduces", - "parameters": [ - ], - "responses": { - "200": { - "description": "successful operation. Returning a simple int.", - "schema": { - "type": "integer", - "format": "int64" - } - } - } - } + } }, "/tests/globalConsumesAndProduces": { "get": { @@ -146,4 +127,4 @@ } } } -} \ No newline at end of file +} From 6fd54d52858142071c5fd5c77e1524aa147a2848 Mon Sep 17 00:00:00 2001 From: Eran Stiller Date: Mon, 12 Oct 2015 08:51:00 +0300 Subject: [PATCH 08/13] Fix bug in handling 204 responses --- .../src/main/resources/android-java/apiInvoker.mustache | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache index ac24335df1..b5f0ae7a66 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache @@ -365,8 +365,10 @@ public class ApiInvoker { int code = response.getStatusLine().getStatusCode(); String responseString = null; - if(code == 204) + if(code == 204) { responseString = ""; + return responseString; + } else if(code >= 200 && code < 300) { if(response.getEntity() != null) { HttpEntity resEntity = response.getEntity(); From 15f5eae2a80da4c658b466da04d11d5d51532cee Mon Sep 17 00:00:00 2001 From: Eran Stiller Date: Mon, 12 Oct 2015 08:51:48 +0300 Subject: [PATCH 09/13] Regenerate Android-Java sample --- .../client/petstore/android-java/build.gradle | 6 ++ .../java/io/swagger/client/ApiInvoker.java | 4 +- .../main/java/io/swagger/client/JsonUtil.java | 32 +++++---- .../java/io/swagger/client/api/PetApi.java | 42 +++++++++--- .../java/io/swagger/client/api/StoreApi.java | 10 ++- .../java/io/swagger/client/api/UserApi.java | 35 +++++++++- .../io/swagger/client/model/ApiResponse.java | 68 +++++++++++++++++++ .../io/swagger/client/model/Category.java | 4 ++ .../java/io/swagger/client/model/Order.java | 4 ++ .../java/io/swagger/client/model/Pet.java | 10 ++- .../java/io/swagger/client/model/Tag.java | 4 ++ .../java/io/swagger/client/model/User.java | 4 ++ 12 files changed, 196 insertions(+), 27 deletions(-) create mode 100644 samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java diff --git a/samples/client/petstore/android-java/build.gradle b/samples/client/petstore/android-java/build.gradle index 417503cb51..c5f4edf79c 100644 --- a/samples/client/petstore/android-java/build.gradle +++ b/samples/client/petstore/android-java/build.gradle @@ -1,6 +1,8 @@ + group = 'io.swagger' project.version = '1.0.0' + buildscript { repositories { jcenter() @@ -21,8 +23,10 @@ allprojects { apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + android { compileSdkVersion 22 buildToolsVersion '22.0.0' @@ -81,6 +85,7 @@ afterEvaluate { } } + task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' @@ -89,3 +94,4 @@ task sourcesJar(type: Jar) { artifacts { archives sourcesJar } + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java index eabb47e818..aa786ff5b3 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java @@ -365,8 +365,10 @@ public class ApiInvoker { int code = response.getStatusLine().getStatusCode(); String responseString = null; - if(code == 204) + if(code == 204) { responseString = ""; + return responseString; + } else if(code >= 200 && code < 300) { if(response.getEntity() != null) { HttpEntity resEntity = response.getEntity(); diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java index 5aa10d3ea8..93a59d71b5 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java @@ -35,6 +35,10 @@ public class JsonUtil { public static Type getListTypeForDeserialization(Class cls) { String className = cls.getSimpleName(); + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + if ("User".equalsIgnoreCase(className)) { return new TypeToken>(){}.getType(); } @@ -43,16 +47,16 @@ public class JsonUtil { return new TypeToken>(){}.getType(); } - if ("Pet".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); - } - if ("Tag".equalsIgnoreCase(className)) { return new TypeToken>(){}.getType(); } - if ("Order".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); + if ("Pet".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("ApiResponse".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } return new TypeToken>(){}.getType(); @@ -61,6 +65,10 @@ public class JsonUtil { public static Type getTypeForDeserialization(Class cls) { String className = cls.getSimpleName(); + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + if ("User".equalsIgnoreCase(className)) { return new TypeToken(){}.getType(); } @@ -69,16 +77,16 @@ public class JsonUtil { return new TypeToken(){}.getType(); } - if ("Pet".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); - } - if ("Tag".equalsIgnoreCase(className)) { return new TypeToken(){}.getType(); } - if ("Order".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); + if ("Pet".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("ApiResponse".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); } return new TypeToken(){}.getType(); diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java index f6b6403a34..5a607ba393 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java @@ -10,6 +10,8 @@ import java.util.*; import io.swagger.client.model.Pet; import java.io.File; +import io.swagger.client.model.ApiResponse; + import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -18,6 +20,7 @@ import java.util.Map; import java.util.HashMap; import java.io.File; + public class PetApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -48,6 +51,11 @@ public class PetApi { public void updatePet (Pet body) throws ApiException { Object postBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updatePet"); + } + // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -102,6 +110,11 @@ public class PetApi { public void addPet (Pet body) throws ApiException { Object postBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling addPet"); + } + // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -156,6 +169,11 @@ public class PetApi { public List findPetsByStatus (List status) throws ApiException { Object postBody = null; + // verify the required parameter 'status' is set + if (status == null) { + throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); + } + // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -168,7 +186,7 @@ public class PetApi { Map formParams = new HashMap(); - queryParams.addAll(ApiInvoker.parameterToPairs("multi", "status", status)); + queryParams.addAll(ApiInvoker.parameterToPairs("csv", "status", status)); @@ -212,6 +230,11 @@ public class PetApi { public List findPetsByTags (List tags) throws ApiException { Object postBody = null; + // verify the required parameter 'tags' is set + if (tags == null) { + throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); + } + // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -224,7 +247,7 @@ public class PetApi { Map formParams = new HashMap(); - queryParams.addAll(ApiInvoker.parameterToPairs("multi", "tags", tags)); + queryParams.addAll(ApiInvoker.parameterToPairs("csv", "tags", tags)); @@ -261,8 +284,8 @@ public class PetApi { /** * 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 + * Returns a single pet + * @param petId ID of pet to return * @return Pet */ public Pet getPetById (Long petId) throws ApiException { @@ -326,7 +349,7 @@ public class PetApi { * @param status Updated status of the pet * @return void */ - public void updatePetWithForm (String petId, String name, String status) throws ApiException { + public void updatePetWithForm (Long petId, String name, String status) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -457,9 +480,9 @@ public class PetApi { * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload - * @return void + * @return ApiResponse */ - public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { + public ApiResponse uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -512,10 +535,10 @@ public class PetApi { try { String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); if(response != null){ - return ; + return (ApiResponse) ApiInvoker.deserialize(response, "", ApiResponse.class); } else { - return ; + return null; } } catch (ApiException ex) { throw ex; @@ -523,3 +546,4 @@ public class PetApi { } } + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java index 49a3ac4aa9..b89a0ddbd4 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java @@ -11,6 +11,7 @@ import java.util.*; import java.util.Map; import io.swagger.client.model.Order; + import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -18,6 +19,7 @@ import java.util.Map; import java.util.HashMap; import java.io.File; + public class StoreApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -101,6 +103,11 @@ public class StoreApi { public Order placeOrder (Order body) throws ApiException { Object postBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"); + } + // create path and map variables String path = "/store/order".replaceAll("\\{format\\}","json"); @@ -152,7 +159,7 @@ public class StoreApi { * @param orderId ID of pet that needs to be fetched * @return Order */ - public Order getOrderById (String orderId) throws ApiException { + public Order getOrderById (Long orderId) throws ApiException { Object postBody = null; // verify the required parameter 'orderId' is set @@ -265,3 +272,4 @@ public class StoreApi { } } + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java index a16a745c7f..6703b54f75 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java @@ -11,6 +11,7 @@ import java.util.*; import io.swagger.client.model.User; import java.util.*; + import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -18,6 +19,7 @@ import java.util.Map; import java.util.HashMap; import java.io.File; + public class UserApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -48,6 +50,11 @@ public class UserApi { public void createUser (User body) throws ApiException { Object postBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUser"); + } + // create path and map variables String path = "/user".replaceAll("\\{format\\}","json"); @@ -102,6 +109,11 @@ public class UserApi { public void createUsersWithArrayInput (List body) throws ApiException { Object postBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); + } + // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -156,6 +168,11 @@ public class UserApi { public void createUsersWithListInput (List body) throws ApiException { Object postBody = body; + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"); + } + // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -211,6 +228,16 @@ public class UserApi { public String loginUser (String username, String password) throws ApiException { Object postBody = null; + // verify the required parameter 'username' is set + if (username == null) { + throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); + } + + // verify the required parameter 'password' is set + if (password == null) { + throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); + } + // create path and map variables String path = "/user/login".replaceAll("\\{format\\}","json"); @@ -316,7 +343,7 @@ public class UserApi { /** * Get user by user name * - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ public User getUserByName (String username) throws ApiException { @@ -387,6 +414,11 @@ public class UserApi { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); } + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException(400, "Missing the required parameter 'body' when calling updateUser"); + } + // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -492,3 +524,4 @@ public class UserApi { } } + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java new file mode 100644 index 0000000000..6dd0a9c2fc --- /dev/null +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java @@ -0,0 +1,68 @@ +package io.swagger.client.model; + + + +import io.swagger.annotations.*; +import com.google.gson.annotations.SerializedName; + + + +@ApiModel(description = "") +public class ApiResponse { + + @SerializedName("code") + private Integer code = null; + @SerializedName("type") + private String type = null; + @SerializedName("message") + private String message = null; + + + /** + **/ + @ApiModelProperty(value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + + /** + **/ + @ApiModelProperty(value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + + /** + **/ + @ApiModelProperty(value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiResponse {\n"); + + sb.append(" code: ").append(code).append("\n"); + sb.append(" type: ").append(type).append("\n"); + sb.append(" message: ").append(message).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} + + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java index 44c71e8a62..98e5c25c80 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java @@ -1,10 +1,12 @@ package io.swagger.client.model; + import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; + @ApiModel(description = "") public class Category { @@ -48,3 +50,5 @@ public class Category { return sb.toString(); } } + + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java index f3f42db615..4ef664deba 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java @@ -2,10 +2,12 @@ package io.swagger.client.model; import java.util.Date; + import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; + @ApiModel(description = "") public class Order { @@ -109,3 +111,5 @@ public class Order { return sb.toString(); } } + + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java index 90a840e6e4..cf7eb877b2 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java @@ -1,13 +1,15 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import io.swagger.client.model.Tag; import java.util.*; +import io.swagger.client.model.Tag; + import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; + @ApiModel(description = "") public class Pet { @@ -18,9 +20,9 @@ public class Pet { @SerializedName("name") private String name = null; @SerializedName("photoUrls") - private List photoUrls = new ArrayList() ; + private List photoUrls = null; @SerializedName("tags") - private List tags = new ArrayList() ; + private List tags = null; public enum StatusEnum { available, pending, sold, }; @@ -111,3 +113,5 @@ public class Pet { return sb.toString(); } } + + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java index 7c9651b1ba..e87a002a14 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java @@ -1,10 +1,12 @@ package io.swagger.client.model; + import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; + @ApiModel(description = "") public class Tag { @@ -48,3 +50,5 @@ public class Tag { return sb.toString(); } } + + diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java index dc022697eb..fabdab0b4e 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java @@ -1,10 +1,12 @@ package io.swagger.client.model; + import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; + @ApiModel(description = "") public class User { @@ -133,3 +135,5 @@ public class User { return sb.toString(); } } + + From 1fb2a97497a15c6b61de66ba3e721a2810e038d7 Mon Sep 17 00:00:00 2001 From: Eran Stiller Date: Mon, 12 Oct 2015 09:22:36 +0300 Subject: [PATCH 10/13] Revert "Regenerate Android-Java sample" This reverts commit 15f5eae2a80da4c658b466da04d11d5d51532cee. --- .../client/petstore/android-java/build.gradle | 6 -- .../java/io/swagger/client/ApiInvoker.java | 4 +- .../main/java/io/swagger/client/JsonUtil.java | 32 ++++----- .../java/io/swagger/client/api/PetApi.java | 42 +++--------- .../java/io/swagger/client/api/StoreApi.java | 10 +-- .../java/io/swagger/client/api/UserApi.java | 35 +--------- .../io/swagger/client/model/ApiResponse.java | 68 ------------------- .../io/swagger/client/model/Category.java | 4 -- .../java/io/swagger/client/model/Order.java | 4 -- .../java/io/swagger/client/model/Pet.java | 10 +-- .../java/io/swagger/client/model/Tag.java | 4 -- .../java/io/swagger/client/model/User.java | 4 -- 12 files changed, 27 insertions(+), 196 deletions(-) delete mode 100644 samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java diff --git a/samples/client/petstore/android-java/build.gradle b/samples/client/petstore/android-java/build.gradle index c5f4edf79c..417503cb51 100644 --- a/samples/client/petstore/android-java/build.gradle +++ b/samples/client/petstore/android-java/build.gradle @@ -1,8 +1,6 @@ - group = 'io.swagger' project.version = '1.0.0' - buildscript { repositories { jcenter() @@ -23,10 +21,8 @@ allprojects { apply plugin: 'com.android.library' - apply plugin: 'com.github.dcendents.android-maven' - android { compileSdkVersion 22 buildToolsVersion '22.0.0' @@ -85,7 +81,6 @@ afterEvaluate { } } - task sourcesJar(type: Jar) { from android.sourceSets.main.java.srcDirs classifier = 'sources' @@ -94,4 +89,3 @@ task sourcesJar(type: Jar) { artifacts { archives sourcesJar } - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java index aa786ff5b3..eabb47e818 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java @@ -365,10 +365,8 @@ public class ApiInvoker { int code = response.getStatusLine().getStatusCode(); String responseString = null; - if(code == 204) { + if(code == 204) responseString = ""; - return responseString; - } else if(code >= 200 && code < 300) { if(response.getEntity() != null) { HttpEntity resEntity = response.getEntity(); diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java index 93a59d71b5..5aa10d3ea8 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/JsonUtil.java @@ -35,10 +35,6 @@ public class JsonUtil { public static Type getListTypeForDeserialization(Class cls) { String className = cls.getSimpleName(); - if ("Order".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); - } - if ("User".equalsIgnoreCase(className)) { return new TypeToken>(){}.getType(); } @@ -47,16 +43,16 @@ public class JsonUtil { return new TypeToken>(){}.getType(); } - if ("Tag".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); - } - if ("Pet".equalsIgnoreCase(className)) { return new TypeToken>(){}.getType(); } - if ("ApiResponse".equalsIgnoreCase(className)) { - return new TypeToken>(){}.getType(); + if ("Tag".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); + } + + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken>(){}.getType(); } return new TypeToken>(){}.getType(); @@ -65,10 +61,6 @@ public class JsonUtil { public static Type getTypeForDeserialization(Class cls) { String className = cls.getSimpleName(); - if ("Order".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); - } - if ("User".equalsIgnoreCase(className)) { return new TypeToken(){}.getType(); } @@ -77,16 +69,16 @@ public class JsonUtil { return new TypeToken(){}.getType(); } - if ("Tag".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); - } - if ("Pet".equalsIgnoreCase(className)) { return new TypeToken(){}.getType(); } - if ("ApiResponse".equalsIgnoreCase(className)) { - return new TypeToken(){}.getType(); + if ("Tag".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); + } + + if ("Order".equalsIgnoreCase(className)) { + return new TypeToken(){}.getType(); } return new TypeToken(){}.getType(); diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java index 5a607ba393..f6b6403a34 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/PetApi.java @@ -10,8 +10,6 @@ import java.util.*; import io.swagger.client.model.Pet; import java.io.File; -import io.swagger.client.model.ApiResponse; - import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -20,7 +18,6 @@ import java.util.Map; import java.util.HashMap; import java.io.File; - public class PetApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -51,11 +48,6 @@ public class PetApi { public void updatePet (Pet body) throws ApiException { Object postBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling updatePet"); - } - // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -110,11 +102,6 @@ public class PetApi { public void addPet (Pet body) throws ApiException { Object postBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling addPet"); - } - // create path and map variables String path = "/pet".replaceAll("\\{format\\}","json"); @@ -169,11 +156,6 @@ public class PetApi { public List findPetsByStatus (List status) throws ApiException { Object postBody = null; - // verify the required parameter 'status' is set - if (status == null) { - throw new ApiException(400, "Missing the required parameter 'status' when calling findPetsByStatus"); - } - // create path and map variables String path = "/pet/findByStatus".replaceAll("\\{format\\}","json"); @@ -186,7 +168,7 @@ public class PetApi { Map formParams = new HashMap(); - queryParams.addAll(ApiInvoker.parameterToPairs("csv", "status", status)); + queryParams.addAll(ApiInvoker.parameterToPairs("multi", "status", status)); @@ -230,11 +212,6 @@ public class PetApi { public List findPetsByTags (List tags) throws ApiException { Object postBody = null; - // verify the required parameter 'tags' is set - if (tags == null) { - throw new ApiException(400, "Missing the required parameter 'tags' when calling findPetsByTags"); - } - // create path and map variables String path = "/pet/findByTags".replaceAll("\\{format\\}","json"); @@ -247,7 +224,7 @@ public class PetApi { Map formParams = new HashMap(); - queryParams.addAll(ApiInvoker.parameterToPairs("csv", "tags", tags)); + queryParams.addAll(ApiInvoker.parameterToPairs("multi", "tags", tags)); @@ -284,8 +261,8 @@ public class PetApi { /** * Find pet by ID - * Returns a single pet - * @param petId ID of pet to return + * 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 Pet */ public Pet getPetById (Long petId) throws ApiException { @@ -349,7 +326,7 @@ public class PetApi { * @param status Updated status of the pet * @return void */ - public void updatePetWithForm (Long petId, String name, String status) throws ApiException { + public void updatePetWithForm (String petId, String name, String status) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -480,9 +457,9 @@ public class PetApi { * @param petId ID of pet to update * @param additionalMetadata Additional data to pass to server * @param file file to upload - * @return ApiResponse + * @return void */ - public ApiResponse uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { + public void uploadFile (Long petId, String additionalMetadata, File file) throws ApiException { Object postBody = null; // verify the required parameter 'petId' is set @@ -535,10 +512,10 @@ public class PetApi { try { String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); if(response != null){ - return (ApiResponse) ApiInvoker.deserialize(response, "", ApiResponse.class); + return ; } else { - return null; + return ; } } catch (ApiException ex) { throw ex; @@ -546,4 +523,3 @@ public class PetApi { } } - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java index b89a0ddbd4..49a3ac4aa9 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/StoreApi.java @@ -11,7 +11,6 @@ import java.util.*; import java.util.Map; import io.swagger.client.model.Order; - import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -19,7 +18,6 @@ import java.util.Map; import java.util.HashMap; import java.io.File; - public class StoreApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -103,11 +101,6 @@ public class StoreApi { public Order placeOrder (Order body) throws ApiException { Object postBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling placeOrder"); - } - // create path and map variables String path = "/store/order".replaceAll("\\{format\\}","json"); @@ -159,7 +152,7 @@ public class StoreApi { * @param orderId ID of pet that needs to be fetched * @return Order */ - public Order getOrderById (Long orderId) throws ApiException { + public Order getOrderById (String orderId) throws ApiException { Object postBody = null; // verify the required parameter 'orderId' is set @@ -272,4 +265,3 @@ public class StoreApi { } } - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java index 6703b54f75..a16a745c7f 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/api/UserApi.java @@ -11,7 +11,6 @@ import java.util.*; import io.swagger.client.model.User; import java.util.*; - import org.apache.http.HttpEntity; import org.apache.http.entity.mime.MultipartEntityBuilder; @@ -19,7 +18,6 @@ import java.util.Map; import java.util.HashMap; import java.io.File; - public class UserApi { String basePath = "http://petstore.swagger.io/v2"; ApiInvoker apiInvoker = ApiInvoker.getInstance(); @@ -50,11 +48,6 @@ public class UserApi { public void createUser (User body) throws ApiException { Object postBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUser"); - } - // create path and map variables String path = "/user".replaceAll("\\{format\\}","json"); @@ -109,11 +102,6 @@ public class UserApi { public void createUsersWithArrayInput (List body) throws ApiException { Object postBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithArrayInput"); - } - // create path and map variables String path = "/user/createWithArray".replaceAll("\\{format\\}","json"); @@ -168,11 +156,6 @@ public class UserApi { public void createUsersWithListInput (List body) throws ApiException { Object postBody = body; - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling createUsersWithListInput"); - } - // create path and map variables String path = "/user/createWithList".replaceAll("\\{format\\}","json"); @@ -228,16 +211,6 @@ public class UserApi { public String loginUser (String username, String password) throws ApiException { Object postBody = null; - // verify the required parameter 'username' is set - if (username == null) { - throw new ApiException(400, "Missing the required parameter 'username' when calling loginUser"); - } - - // verify the required parameter 'password' is set - if (password == null) { - throw new ApiException(400, "Missing the required parameter 'password' when calling loginUser"); - } - // create path and map variables String path = "/user/login".replaceAll("\\{format\\}","json"); @@ -343,7 +316,7 @@ public class UserApi { /** * Get user by user name * - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ public User getUserByName (String username) throws ApiException { @@ -414,11 +387,6 @@ public class UserApi { throw new ApiException(400, "Missing the required parameter 'username' when calling updateUser"); } - // verify the required parameter 'body' is set - if (body == null) { - throw new ApiException(400, "Missing the required parameter 'body' when calling updateUser"); - } - // create path and map variables String path = "/user/{username}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "username" + "\\}", apiInvoker.escapeString(username.toString())); @@ -524,4 +492,3 @@ public class UserApi { } } - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java deleted file mode 100644 index 6dd0a9c2fc..0000000000 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/ApiResponse.java +++ /dev/null @@ -1,68 +0,0 @@ -package io.swagger.client.model; - - - -import io.swagger.annotations.*; -import com.google.gson.annotations.SerializedName; - - - -@ApiModel(description = "") -public class ApiResponse { - - @SerializedName("code") - private Integer code = null; - @SerializedName("type") - private String type = null; - @SerializedName("message") - private String message = null; - - - /** - **/ - @ApiModelProperty(value = "") - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - - - /** - **/ - @ApiModelProperty(value = "") - public String getType() { - return type; - } - public void setType(String type) { - this.type = type; - } - - - /** - **/ - @ApiModelProperty(value = "") - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ApiResponse {\n"); - - sb.append(" code: ").append(code).append("\n"); - sb.append(" type: ").append(type).append("\n"); - sb.append(" message: ").append(message).append("\n"); - sb.append("}\n"); - return sb.toString(); - } -} - - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java index 98e5c25c80..44c71e8a62 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Category.java @@ -1,12 +1,10 @@ package io.swagger.client.model; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Category { @@ -50,5 +48,3 @@ public class Category { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java index 4ef664deba..f3f42db615 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Order.java @@ -2,12 +2,10 @@ package io.swagger.client.model; import java.util.Date; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Order { @@ -111,5 +109,3 @@ public class Order { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java index cf7eb877b2..90a840e6e4 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Pet.java @@ -1,15 +1,13 @@ package io.swagger.client.model; import io.swagger.client.model.Category; -import java.util.*; import io.swagger.client.model.Tag; - +import java.util.*; import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Pet { @@ -20,9 +18,9 @@ public class Pet { @SerializedName("name") private String name = null; @SerializedName("photoUrls") - private List photoUrls = null; + private List photoUrls = new ArrayList() ; @SerializedName("tags") - private List tags = null; + private List tags = new ArrayList() ; public enum StatusEnum { available, pending, sold, }; @@ -113,5 +111,3 @@ public class Pet { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java index e87a002a14..7c9651b1ba 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/Tag.java @@ -1,12 +1,10 @@ package io.swagger.client.model; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class Tag { @@ -50,5 +48,3 @@ public class Tag { return sb.toString(); } } - - diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java index fabdab0b4e..dc022697eb 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/model/User.java @@ -1,12 +1,10 @@ package io.swagger.client.model; - import io.swagger.annotations.*; import com.google.gson.annotations.SerializedName; - @ApiModel(description = "") public class User { @@ -135,5 +133,3 @@ public class User { return sb.toString(); } } - - From 748460488aa6477f406cb3e5d15eb9334ba34192 Mon Sep 17 00:00:00 2001 From: Eran Stiller Date: Mon, 12 Oct 2015 09:25:24 +0300 Subject: [PATCH 11/13] Regenerate only the ApiInvoker.java file in the sample --- .../src/main/java/io/swagger/client/ApiInvoker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java index eabb47e818..aa786ff5b3 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java @@ -365,8 +365,10 @@ public class ApiInvoker { int code = response.getStatusLine().getStatusCode(); String responseString = null; - if(code == 204) + if(code == 204) { responseString = ""; + return responseString; + } else if(code >= 200 && code < 300) { if(response.getEntity() != null) { HttpEntity resEntity = response.getEntity(); From e562b0ae34f7161ca4fb629cb22b5e2967d16dfd Mon Sep 17 00:00:00 2001 From: Eran Stiller Date: Mon, 12 Oct 2015 09:52:20 +0300 Subject: [PATCH 12/13] Fix indentation --- .../src/main/resources/android-java/apiInvoker.mustache | 4 ++-- .../src/main/java/io/swagger/client/ApiInvoker.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache index b5f0ae7a66..1f6d77a071 100644 --- a/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android-java/apiInvoker.mustache @@ -367,8 +367,8 @@ public class ApiInvoker { String responseString = null; if(code == 204) { responseString = ""; - return responseString; - } + return responseString; + } else if(code >= 200 && code < 300) { if(response.getEntity() != null) { HttpEntity resEntity = response.getEntity(); diff --git a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java index aa786ff5b3..5eddeb6b9e 100644 --- a/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android-java/src/main/java/io/swagger/client/ApiInvoker.java @@ -367,8 +367,8 @@ public class ApiInvoker { String responseString = null; if(code == 204) { responseString = ""; - return responseString; - } + return responseString; + } else if(code >= 200 && code < 300) { if(response.getEntity() != null) { HttpEntity resEntity = response.getEntity(); From 0b4b5e8839cd3f447fde86e4aa2a8db8fc2985f6 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 13 Oct 2015 23:47:42 +0800 Subject: [PATCH 13/13] Revert "Add support for top-level consumes and produces" --- .../io/swagger/codegen/CodegenConfig.java | 2 - .../io/swagger/codegen/DefaultCodegen.java | 50 +------ .../io/swagger/codegen/DefaultGenerator.java | 2 +- .../codegen/languages/SwiftCodegen.java | 6 +- .../java/io/swagger/codegen/CodegenTest.java | 48 ------- .../2_0/globalConsumesAndProduces.json | 130 ------------------ 6 files changed, 10 insertions(+), 228 deletions(-) delete mode 100644 modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java index b50147a6ff..10d7363cc3 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java @@ -67,8 +67,6 @@ public interface CodegenConfig { CodegenModel fromModel(String name, Model model, Map allDefinitions); - CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map definitions, Swagger swagger); - CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map definitions); List fromSecurity(Map schemes); 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 b5dd47b476..69d7cadbf0 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 @@ -867,12 +867,8 @@ public class DefaultCodegen { } return responses.get(code); } - + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions) { - return fromOperation(path, httpMethod, operation, definitions, null); - } - - public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions, Swagger swagger) { CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION); Set imports = new HashSet(); op.vendorExtensions = operation.getVendorExtensions(); @@ -908,32 +904,15 @@ public class DefaultCodegen { op.summary = escapeText(operation.getSummary()); op.notes = escapeText(operation.getDescription()); op.tags = operation.getTags(); - op.hasConsumes = false; - op.hasProduces = false; - List consumes = new ArrayList(); - if (operation.getConsumes() != null) { - if (operation.getConsumes().size() > 0) { - // use consumes defined in the operation - consumes = operation.getConsumes(); - } else { - // empty list, do nothing to override global setting - } - } else if (swagger != null && swagger.getConsumes() != null && swagger.getConsumes().size() > 0) { - // use consumes defined globally - consumes = swagger.getConsumes(); - LOGGER.debug("No consumes defined in operation. Using global consumes (" + swagger.getConsumes() + ") for " + op.operationId); - } - - // if "consumes" is defined (per operation or using global definition) - if (consumes != null && consumes.size() > 0) { + if (operation.getConsumes() != null && operation.getConsumes().size() > 0) { List> c = new ArrayList>(); int count = 0; - for (String key : consumes) { + for (String key : operation.getConsumes()) { Map mediaType = new HashMap(); mediaType.put("mediaType", key); count += 1; - if (count < consumes.size()) { + if (count < operation.getConsumes().size()) { mediaType.put("hasMore", "true"); } else { mediaType.put("hasMore", null); @@ -944,29 +923,14 @@ public class DefaultCodegen { op.hasConsumes = true; } - List produces = new ArrayList(); - if (operation.getProduces() != null) { - if (operation.getProduces().size() > 0) { - // use produces defined in the operation - produces = operation.getProduces(); - } else { - // empty list, do nothing to override global setting - } - } else if (swagger != null && swagger.getProduces() != null && swagger.getProduces().size() > 0) { - // use produces defined globally - produces = swagger.getProduces(); - LOGGER.debug("No produces defined in operation. Using global produces (" + swagger.getProduces() + ") for " + op.operationId); - } - - // if "produces" is defined (per operation or using global definition) - if (produces != null && produces.size() > 0) { + if (operation.getProduces() != null && operation.getProduces().size() > 0) { List> c = new ArrayList>(); int count = 0; - for (String key : produces) { + for (String key : operation.getProduces()) { Map mediaType = new HashMap(); mediaType.put("mediaType", key); count += 1; - if (count < produces.size()) { + if (count < operation.getProduces().size()) { mediaType.put("hasMore", "true"); } else { mediaType.put("hasMore", null); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 2b61635e0b..a785f45bdf 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -470,7 +470,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (String tag : tags) { CodegenOperation co = null; try { - co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions(), swagger); + co = config.fromOperation(resourcePath, httpMethod, operation, swagger.getDefinitions()); co.tags = new ArrayList(); co.tags.add(sanitizeTag(tag)); config.addOperationToGroup(sanitizeTag(tag), resourcePath, operation, co, operations); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 9bb1dfd61d..55c3864adb 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -1,11 +1,9 @@ package io.swagger.codegen.languages; import com.google.common.base.Predicate; - import com.google.common.collect.Iterators; import com.google.common.collect.Lists; import io.swagger.codegen.*; -import io.swagger.models.Swagger; import io.swagger.models.Model; import io.swagger.models.Operation; import io.swagger.models.parameters.HeaderParameter; @@ -258,7 +256,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { } @Override - public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions, Swagger swagger) { + public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map definitions) { path = normalizePath(path); List parameters = operation.getParameters(); parameters = Lists.newArrayList(Iterators.filter(parameters.iterator(), new Predicate() { @@ -268,7 +266,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { } })); operation.setParameters(parameters); - return super.fromOperation(path, httpMethod, operation, definitions, swagger); + return super.fromOperation(path, httpMethod, operation, definitions); } private static String normalizePath(String path) { diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java index 0fa8953e7b..ee70b427bf 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/CodegenTest.java @@ -139,52 +139,4 @@ public class CodegenTest { Assert.assertTrue(op.bodyParam.isBinary); Assert.assertTrue(op.responses.get(0).isBinary); } - - @Test(description = "use operation consumes and produces") - public void localConsumesAndProducesTest() { - final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); - final DefaultCodegen codegen = new DefaultCodegen(); - final String path = "/tests/localConsumesAndProduces"; - final Operation p = model.getPaths().get(path).getGet(); - CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model); - - Assert.assertTrue(op.hasConsumes); - Assert.assertEquals(op.consumes.size(), 1); - Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/json"); - Assert.assertTrue(op.hasProduces); - Assert.assertEquals(op.produces.size(), 1); - Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/json"); - } - - @Test(description = "use spec consumes and produces") - public void globalConsumesAndProducesTest() { - final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); - final DefaultCodegen codegen = new DefaultCodegen(); - final String path = "/tests/globalConsumesAndProduces"; - final Operation p = model.getPaths().get(path).getGet(); - CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model); - - Assert.assertTrue(op.hasConsumes); - Assert.assertEquals(op.consumes.size(), 1); - Assert.assertEquals(op.consumes.get(0).get("mediaType"), "application/global_consumes"); - Assert.assertTrue(op.hasProduces); - Assert.assertEquals(op.produces.size(), 1); - Assert.assertEquals(op.produces.get(0).get("mediaType"), "application/global_produces"); - } - - @Test(description = "use operation consumes and produces (reset in operation with empty array)") - public void localResetConsumesAndProducesTest() { - final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json"); - final DefaultCodegen codegen = new DefaultCodegen(); - final String path = "/tests/localResetConsumesAndProduces"; - final Operation p = model.getPaths().get(path).getGet(); - CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions(), model); - - Assert.assertNotNull(op); - Assert.assertFalse(op.hasConsumes); - Assert.assertNull(op.consumes); - Assert.assertFalse(op.hasProduces); - Assert.assertNull(op.produces); - - } } diff --git a/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json b/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json deleted file mode 100644 index 520218ed70..0000000000 --- a/modules/swagger-codegen/src/test/resources/2_0/globalConsumesAndProduces.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "description": "Spec for testing global consumes and produces", - "version": "1.0.0", - "title": "Swagger Petstore", - "termsOfService": "http://swagger.io/terms/", - "contact": { - "email": "apiteam@swagger.io" - }, - "license": { - "name": "Apache 2.0", - "url": "http://www.apache.org/licenses/LICENSE-2.0.html" - } - }, - "host": "petstore.swagger.io", - "basePath": "/v2", - "consumes": ["application/global_consumes"], - "produces": ["application/global_produces"], - "schemes": [ - "http" - ], - "paths": { - "/tests/localConsumesAndProduces": { - "get": { - "tags": [ - "tests" - ], - "summary": "Operation with local consumes and produces", - "description": "", - "operationId": "localConsumesAndProduces", - "produces": [ - "application/json" - ], - "consumes": [ - "application/json" - ], - "parameters": [ - ], - "responses": { - "200": { - "description": "successful operation. Returning a simple int.", - "schema": { - "type": "integer", - "format": "int64" - } - } - } - } - }, - "/tests/globalConsumesAndProduces": { - "get": { - "tags": [ - "tests" - ], - "summary": "Operation with global consumes and produces", - "description": "", - "operationId": "globalConsumesAndProduces", - "parameters": [ - ], - "responses": { - "200": { - "description": "successful operation. Returning a simple int.", - "schema": { - "type": "integer", - "format": "int64" - } - } - } - } - }, - "/tests/localResetConsumesAndProduces": { - "get": { - "tags": [ - "tests" - ], - "summary": "Operation with local consumes and produces set to empty (reset)", - "description": "", - "operationId": "localResetConsumesAndProduces", - "parameters": [ - ], - "consumes": [], - "produces": [], - "responses": { - "200": { - "description": "successful operation. Returning a simple int.", - "schema": { - "type": "integer", - "format": "int64" - } - } - } - } - } - - }, - "securityDefinitions": { - "api_key": { - "type": "apiKey", - "name": "api_key", - "in": "header" - }, - "petstore_auth": { - "type": "oauth2", - "authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", - "flow": "implicit", - "scopes": { - "write:pets": "modify pets in your account", - "read:pets": "read your pets" - } - } - }, - "definitions": { - "CustomModel": { - "required": [ - "id" - ], - "properties": { - "id": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string", - "example": "doggie" - } - } - } - } -}