- {{#vars}}
{{name}} {{#isNotRequired}}(optional){{/isNotRequired}}
{{datatype}} {{description}}
+ {{#vars}}
{{name}} {{^required}}(optional){{/required}}
{{datatype}} {{description}}
{{#isEnum}}
{{#_enum}}
{{this}}
{{/_enum}}
diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache
index a7dec733321..142e14a9e80 100644
--- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache
@@ -716,11 +716,11 @@ static void (^reachabilityChangeBlock)(int);
for (NSString *auth in authSettings) {
NSDictionary *authSetting = [[config authSettings] objectForKey:auth];
- if (authSetting) {
- if ([authSetting[@"in"] isEqualToString:@"header"]) {
+ if (authSetting) { // auth setting is set only if the key is non-empty
+ if ([authSetting[@"in"] isEqualToString:@"header"] && [authSetting[@"key"] length] != 0) {
[headersWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]];
}
- else if ([authSetting[@"in"] isEqualToString:@"query"]) {
+ else if ([authSetting[@"in"] isEqualToString:@"query"] && [authSetting[@"key"] length] != 0) {
[querysWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]];
}
}
diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache
index b7ec5bb6021..a039e7e168e 100644
--- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache
@@ -14,6 +14,7 @@
{{#models}}{{#model}}#import "{{classname}}.h"
{{/model}}{{/models}}
+{{^models}}#import "{{classPrefix}}Object.h"{{/models}}
@class {{classPrefix}}Configuration;
diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache
index 167b05aef1f..4f5442ed213 100644
--- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache
@@ -29,6 +29,7 @@
self.host = @"{{basePath}}";
self.username = @"";
self.password = @"";
+ self.accessToken= @"";
self.tempFolderPath = nil;
self.debug = NO;
self.verifySSL = YES;
@@ -42,18 +43,23 @@
#pragma mark - Instance Methods
- (NSString *) getApiKeyWithPrefix:(NSString *)key {
- if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) {
+ if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // both api key prefix and api key are set
return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]];
}
- else if ([self.apiKey objectForKey:key]) {
+ else if ([self.apiKey objectForKey:key] != (id)[NSNull null] && [[self.apiKey objectForKey:key] length] != 0) { // only api key, no api key prefix
return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]];
}
- else {
+ else { // return empty string if nothing is set
return @"";
}
}
- (NSString *) getBasicAuthToken {
+ // return empty string if username and password are empty
+ if (self.username.length == 0 && self.password.length == 0){
+ return @"";
+ }
+
NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password];
NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding];
basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]];
@@ -61,6 +67,15 @@
return basicAuthCredentials;
}
+- (NSString *) getAccessToken {
+ if (self.accessToken.length == 0) { // token not set, return empty string
+ return @"";
+ }
+ else {
+ return [NSString stringWithFormat:@"BEARER %@", self.accessToken];
+ }
+}
+
#pragma mark - Setter Methods
- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier {
@@ -126,6 +141,15 @@
@"value": [self getBasicAuthToken]
},
{{/isBasic}}
+{{#isOAuth}}
+ @"{{name}}":
+ @{
+ @"type": @"oauth",
+ @"in": @"header",
+ @"key": @"Authorization",
+ @"value": [self getAccessToken]
+ },
+{{/isOAuth}}
{{/authMethods}}
};
}
diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache
index 9abe135bc47..b77ddfe5dee 100644
--- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache
@@ -46,6 +46,11 @@
*/
@property (nonatomic) NSString *password;
+/**
+ * Access token for OAuth
+ */
+@property (nonatomic) NSString *accessToken;
+
/**
* Temp folder for file download
*/
@@ -132,6 +137,11 @@
*/
- (NSString *) getBasicAuthToken;
+/**
+ * Gets OAuth access token
+ */
+- (NSString *) getAccessToken;
+
/**
* Gets Authentication Setings
*/
diff --git a/modules/swagger-codegen/src/main/resources/objc/README.mustache b/modules/swagger-codegen/src/main/resources/objc/README.mustache
index 30a8927c41a..c0bc1178b0b 100644
--- a/modules/swagger-codegen/src/main/resources/objc/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/README.mustache
@@ -1,20 +1,147 @@
# {{podName}}
+{{#appDescription}}
+{{{appDescription}}}
+{{/appDescription}}
+
+This ObjC package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
+
+- API version: {{appVersion}}
+- Package version: {{artifactVersion}}
+- Build date: {{generatedDate}}
+- Build package: {{generatorClass}}
+{{#infoUrl}}
+For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
+{{/infoUrl}}
+
## Requirements
-The API client library requires ARC (Automatic Reference Counting) to be enabled in your Xcode project.
+The SDK requires [**ARC (Automatic Reference Counting)**](http://stackoverflow.com/questions/7778356/how-to-enable-disable-automatic-reference-counting) to be enabled in the Xcode project.
-## Installation
+## Installation & Usage
+### Install from Github using [CocoaPods](https://cocoapods.org/)
-To install it, put the API client library in your project and then simply add the following line to your Podfile:
+Add the following to the Podfile:
```ruby
-pod "{{podName}}", :path => "/path/to/lib"
+pod '{{podName}}', :git => 'https://github.com/{{gitUserId}}/{{gitRepoId}}.git'
+```
+
+To specify a particular branch, append `, :branch => 'branch-name-here'`
+
+To specify a particular commit, append `, :commit => '11aa22'`
+
+### Install from local path using [CocoaPods](https://cocoapods.org/)
+
+Put the SDK under your project folder (e.g. /path/to/objc_project/Vendor/{{podName}}) and then add the following to the Podfile:
+
+```ruby
+pod '{{podName}}', :path => 'Vendor/{{podName}}'
+```
+
+### Usage
+
+Import the following:
+```objc
+#import <{{podName}}/{{{classPrefix}}}ApiClient.h>
+#import <{{podName}}/{{{classPrefix}}}Configuration.h>
+// load models
+{{#models}}{{#model}}#import <{{podName}}/{{{classname}}}.h>
+{{/model}}{{/models}}// load API classes for accessing endpoints
+{{#apiInfo}}{{#apis}}#import <{{podName}}/{{{classname}}}.h>
+{{/apis}}{{/apiInfo}}
```
## Recommendation
-It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issue.
+It's recommended to create an instance of ApiClient per thread in a multi-threaded environment to avoid any potential issue.
+
+## Getting Started
+
+Please follow the [installation procedure](#installation--usage) and then run the following:
+
+```objc
+{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
+{{#hasAuthMethods}}
+{{classPrefix}}Configuration *apiConfig = [{{classPrefix}}Configuration sharedConfig];
+{{#authMethods}}{{#isBasic}}// Configure HTTP basic authorization (authentication scheme: {{{name}}})
+[apiConfig setUsername:@"YOUR_USERNAME"];
+[apiConfig setPassword:@"YOUR_PASSWORD"];
+{{/isBasic}}{{#isApiKey}}
+// Configure API key authorization: (authentication scheme: {{{name}}})
+[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"];
+// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
+//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"{{{keyParamName}}}"];
+{{/isApiKey}}{{#isOAuth}}
+// Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}})
+[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
+{{/isOAuth}}{{/authMethods}}
+{{/hasAuthMethods}}
+
+{{#allParams}}{{{dataType}}} *{{paramName}} = {{{example}}}; // {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
+{{/allParams}}
+
+@try
+{
+ {{classname}} *apiInstance = [[{{classname}} alloc] init];
+
+{{#summary}} // {{{.}}}
+{{/summary}} [apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
+ {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
+ {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error)) {
+{{#returnType}}
+ if (output) {
+ NSLog(@"%@", output);
+ }
+{{/returnType}}
+ if (error) {
+ NSLog(@"Error: %@", error);
+ }
+ }];
+}
+@catch (NSException *exception)
+{
+ NSLog(@"Exception when calling {{classname}}->{{operationId}}: %@ ", exception.name);
+ NSLog(@"Reason: %@ ", exception.reason);
+}
+{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
+```
+
+## Documentation for API Endpoints
+
+All URIs are relative to *{{basePath}}*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
+
+## Documentation For Models
+
+{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
+{{/model}}{{/models}}
+
+## Documentation For Authorization
+
+{{^authMethods}} All endpoints do not require authorization.
+{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
+{{#authMethods}}## {{{name}}}
+
+{{#isApiKey}}- **Type**: API key
+- **API key parameter name**: {{{keyParamName}}}
+- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
+{{/isApiKey}}
+{{#isBasic}}- **Type**: HTTP basic authentication
+{{/isBasic}}
+{{#isOAuth}}- **Type**: OAuth
+- **Flow**: {{{flow}}}
+- **Authorization URL**: {{{authorizationUrl}}}
+- **Scopes**: {{^scopes}}N/A{{/scopes}}
+{{#scopes}} - **{{{scope}}}**: {{{description}}}
+{{/scopes}}
+{{/isOAuth}}
+
+{{/authMethods}}
## Author
diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache
index 41560eabd3e..2a7880d8367 100644
--- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache
@@ -40,7 +40,6 @@ static {{classname}}* singletonAPI = nil;
#pragma mark -
+({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key {
-
if (singletonAPI == nil) {
singletonAPI = [[{{classname}} alloc] init];
[singletonAPI addHeader:headerValue forKey:key];
@@ -49,7 +48,6 @@ static {{classname}}* singletonAPI = nil;
}
+({{classname}}*) sharedAPI {
-
if (singletonAPI == nil) {
singletonAPI = [[{{classname}} alloc] init];
}
@@ -82,14 +80,15 @@ static {{classname}}* singletonAPI = nil;
-(NSNumber*) {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
{{paramName}}{{/secondaryParam}}: ({{{dataType}}}) {{paramName}}{{/allParams}}
{{#hasParams}}completionHandler: {{/hasParams}}(void (^)({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error)) handler {
-
- {{#allParams}}{{#required}}
+ {{#allParams}}
+ {{#required}}
// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == nil) {
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `{{paramName}}` when calling `{{nickname}}`"];
}
- {{/required}}{{/allParams}}
+ {{/required}}
+ {{/allParams}}
NSMutableString* resourcePath = [NSMutableString stringWithFormat:@"{{path}}"];
// remove format in URL if needed
@@ -98,13 +97,15 @@ static {{classname}}* singletonAPI = nil;
}
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
- {{#pathParams}}if ({{paramName}} != nil) {
+ {{#pathParams}}
+ if ({{paramName}} != nil) {
pathParams[@"{{baseName}}"] = {{paramName}};
}
{{/pathParams}}
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
- {{#queryParams}}if ({{paramName}} != nil) {
+ {{#queryParams}}
+ if ({{paramName}} != nil) {
{{#collectionFormat}}
queryParams[@"{{baseName}}"] = [[{{classPrefix}}QueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"];
{{/collectionFormat}}
@@ -112,12 +113,13 @@ static {{classname}}* singletonAPI = nil;
}
{{/queryParams}}
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
-
- {{#headerParams}}if ({{paramName}} != nil) {
+ {{#headerParams}}
+
+ if ({{paramName}} != nil) {
headerParams[@"{{baseName}}"] = {{paramName}};
}
- {{/headerParams}}
+ {{/headerParams}}
// HTTP header `Accept`
headerParams[@"Accept"] = [{{classPrefix}}ApiClient selectHeaderAccept:@[{{#produces}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]];
if ([headerParams[@"Accept"] length] == 0) {
@@ -144,25 +146,20 @@ static {{classname}}* singletonAPI = nil;
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
{{#bodyParam}}
bodyParam = {{paramName}};
- {{/bodyParam}}{{^bodyParam}}
+ {{/bodyParam}}
+ {{^bodyParam}}
{{#formParams}}
{{#notFile}}
if ({{paramName}}) {
formParams[@"{{baseName}}"] = {{paramName}};
}
- {{/notFile}}{{#isFile}}
+ {{/notFile}}
+ {{#isFile}}
localVarFiles[@"{{paramName}}"] = {{paramName}};
{{/isFile}}
{{/formParams}}
{{/bodyParam}}
- {{#requiredParamCount}}
- {{#requiredParams}}
- if ({{paramName}} == nil) {
- // error
- }
- {{/requiredParams}}
- {{/requiredParamCount}}
return [self.apiClient requestWithPath: resourcePath
method: @"{{httpMethod}}"
pathParams: pathParams
diff --git a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache
index fdf6726dac8..7c5a9d335cf 100644
--- a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache
+++ b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache
@@ -27,7 +27,7 @@
/// {{{summary}}}
/// {{#notes}}{{{notes}}}{{/notes}}
///
-/// {{#allParams}}@param {{paramName}} {{description}}
+/// {{#allParams}}@param {{paramName}} {{description}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
/// {{/allParams}}
///
/// @return {{{returnType}}}
diff --git a/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache b/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache
new file mode 100644
index 00000000000..3400300c8dc
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/objc/api_doc.mustache
@@ -0,0 +1,93 @@
+# {{classname}}{{#description}}
+{{description}}{{/description}}
+
+All URIs are relative to *{{basePath}}*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{/operation}}{{/operations}}
+
+{{#operations}}
+{{#operation}}
+# **{{{operationId}}}**
+```objc
+-(NSNumber*) {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
+ {{paramName}}{{/secondaryParam}}: ({{{dataType}}}) {{paramName}}{{/allParams}}
+ {{#hasParams}}completionHandler: {{/hasParams}}(void (^)({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error)) handler;
+```
+
+{{{summary}}}{{#notes}}
+
+{{{notes}}}{{/notes}}
+
+### Example
+```objc
+{{#hasAuthMethods}}
+{{classPrefix}}Configuration *apiConfig = [{{classPrefix}}Configuration sharedConfig];
+{{#authMethods}}{{#isBasic}}// Configure HTTP basic authorization (authentication scheme: {{{name}}})
+[apiConfig setUsername:@"YOUR_USERNAME"];
+[apiConfig setPassword:@"YOUR_PASSWORD"];
+{{/isBasic}}{{#isApiKey}}
+// Configure API key authorization: (authentication scheme: {{{name}}})
+[apiConfig setApiKey:@"YOUR_API_KEY" forApiKeyIdentifier:@"{{{keyParamName}}}"];
+// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
+//[apiConfig setApiKeyPrefix:@"BEARER" forApiKeyIdentifier:@"{{{keyParamName}}}"];
+{{/isApiKey}}{{#isOAuth}}
+// Configure OAuth2 access token for authorization: (authentication scheme: {{{name}}})
+[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];
+{{/isOAuth}}{{/authMethods}}
+{{/hasAuthMethods}}
+
+{{#allParams}}{{{dataType}}} {{paramName}} = {{{example}}}; // {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
+{{/allParams}}
+
+@try
+{
+ {{classname}} *apiInstance = [[{{classname}} alloc] init];
+
+{{#summary}} // {{{.}}}
+{{/summary}} [apiInstance {{#vendorExtensions.x-objc-operationId}}{{vendorExtensions.x-objc-operationId}}{{/vendorExtensions.x-objc-operationId}}{{^vendorExtensions.x-objc-operationId}}{{nickname}}{{#hasParams}}With{{vendorExtensions.firstParamAltName}}{{/hasParams}}{{^hasParams}}WithCompletionHandler: {{/hasParams}}{{/vendorExtensions.x-objc-operationId}}{{#allParams}}{{#secondaryParam}}
+ {{paramName}}{{/secondaryParam}}:{{paramName}}{{/allParams}}
+ {{#hasParams}}completionHandler: {{/hasParams}}^({{#returnBaseType}}{{{returnType}}} output, {{/returnBaseType}}NSError* error) {
+{{#returnType}}
+ if (output) {
+ NSLog(@"%@", output);
+ }
+{{/returnType}}
+ if (error) {
+ NSLog(@"Error: %@", error);
+ }
+ }];
+}
+@catch (NSException *exception)
+{
+ NSLog(@"Exception when calling {{classname}}->{{operationId}}: %@ ", exception.name);
+ NSLog(@"Reason: %@ ", exception.reason);
+}
+```
+
+### Parameters
+{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
+{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
+{{/allParams}}
+
+### Return type
+
+{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
+
+### Authorization
+
+{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
+
+### HTTP request headers
+
+ - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+{{/operation}}
+{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/objc/model_doc.mustache b/modules/swagger-codegen/src/main/resources/objc/model_doc.mustache
new file mode 100644
index 00000000000..569550df372
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/objc/model_doc.mustache
@@ -0,0 +1,11 @@
+{{#models}}{{#model}}# {{classname}}
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
+{{/vars}}
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+{{/model}}{{/models}}
diff --git a/modules/swagger-codegen/src/main/resources/perl/README.mustache b/modules/swagger-codegen/src/main/resources/perl/README.mustache
index 185859ec4a3..b312193f1cc 100644
--- a/modules/swagger-codegen/src/main/resources/perl/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/README.mustache
@@ -8,7 +8,7 @@
Automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
-- API verion: {{appVersion}}
+- API version: {{appVersion}}
- Package version: {{moduleVersion}}
- Build date: {{generatedDate}}
- Build package: {{generatorClass}}
@@ -303,7 +303,7 @@ Class | Method | HTTP request | Description
{{/isBasic}}
{{#isOAuth}}- **Type**: OAuth
- **Flow**: {{{flow}}}
-- **Authorizatoin URL**: {{{authorizationUrl}}}
+- **Authorization URL**: {{{authorizationUrl}}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}} - **{{{scope}}}**: {{{description}}}
{{/scopes}}
diff --git a/modules/swagger-codegen/src/main/resources/perl/api.mustache b/modules/swagger-codegen/src/main/resources/perl/api.mustache
index 7e0770f332f..d96a2302a8a 100644
--- a/modules/swagger-codegen/src/main/resources/perl/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/api.mustache
@@ -81,13 +81,15 @@ sub new {
sub {{operationId}} {
my ($self, %args) = @_;
- {{#allParams}}{{#required}}
+ {{#allParams}}
+ {{#required}}
# verify the required parameter '{{paramName}}' is set
unless (exists $args{'{{paramName}}'}) {
croak("Missing the required parameter '{{paramName}}' when calling {{operationId}}");
}
- {{/required}}{{/allParams}}
+ {{/required}}
+ {{/allParams}}
# parse inputs
my $_resource_path = '{{path}}';
$_resource_path =~ s/{format}/json/; # default format to json
@@ -104,54 +106,70 @@ sub {{operationId}} {
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type({{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}});
- {{#queryParams}}# query params
+ {{#queryParams}}
+ # query params
if ( exists $args{'{{paramName}}'}) {
$query_params->{'{{baseName}}'} = $self->{api_client}->to_query_value($args{'{{paramName}}'});
- }{{/queryParams}}
- {{#headerParams}}# header params
+ }
+
+ {{/queryParams}}
+ {{#headerParams}}
+ # header params
if ( exists $args{'{{paramName}}'}) {
$header_params->{'{{baseName}}'} = $self->{api_client}->to_header_value($args{'{{paramName}}'});
- }{{/headerParams}}
- {{#pathParams}}# path params
+ }
+
+ {{/headerParams}}
+ {{#pathParams}}
+ # path params
if ( exists $args{'{{paramName}}'}) {
my $_base_variable = "{" . "{{baseName}}" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'{{paramName}}'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
- }{{/pathParams}}
- {{#formParams}}# form params
+ }
+
+ {{/pathParams}}
+ {{#formParams}}
+ # form params
if ( exists $args{'{{paramName}}'} ) {
{{#isFile}}$form_params->{'{{baseName}}'} = [] unless defined $form_params->{'{{baseName}}'};
push @{$form_params->{'{{baseName}}'}}, $args{'{{paramName}}'};
{{/isFile}}
{{^isFile}}$form_params->{'{{baseName}}'} = $self->{api_client}->to_form_value($args{'{{paramName}}'});
{{/isFile}}
- }{{/formParams}}
+ }
+
+ {{/formParams}}
my $_body_data;
- {{#bodyParams}}# body params
+ {{#bodyParams}}
+ # body params
if ( exists $args{'{{paramName}}'}) {
$_body_data = $args{'{{paramName}}'};
- }{{/bodyParams}}
+ }
+ {{/bodyParams}}
# authentication setting, if any
my $auth_settings = [qw({{#authMethods}}{{name}} {{/authMethods}})];
# make the API Call
- {{#returnType}}my $response = $self->{api_client}->call_api($_resource_path, $_method,
+ {{#returnType}}
+ my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('{{returnType}}', $response);
- return $_response_object;{{/returnType}}
- {{^returnType}}$self->{api_client}->call_api($_resource_path, $_method,
+ return $_response_object;
+ {{/returnType}}
+ {{^returnType}}
+ $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
return;
{{/returnType}}
}
{{/operation}}
-{{newline}}
{{/operations}}
1;
diff --git a/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache b/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache
index eb270b7e216..c68934ece2a 100644
--- a/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/api_doc.mustache
@@ -65,7 +65,7 @@ Name | Type | Description | Notes
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
-### HTTP reuqest headers
+### HTTP request headers
- **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
diff --git a/modules/swagger-codegen/src/main/resources/perl/object.mustache b/modules/swagger-codegen/src/main/resources/perl/object.mustache
index 79c59cebaf3..126c6409c7f 100644
--- a/modules/swagger-codegen/src/main/resources/perl/object.mustache
+++ b/modules/swagger-codegen/src/main/resources/perl/object.mustache
@@ -30,14 +30,15 @@ __PACKAGE__->class_documentation({description => '{{description}}',
} );
__PACKAGE__->method_documentation({
- {{#vars}}'{{name}}' => {
+{{#vars}}
+ '{{name}}' => {
datatype => '{{datatype}}',
base_name => '{{baseName}}',
description => '{{description}}',
format => '{{format}}',
read_only => '{{readOnly}}',
},
- {{/vars}}
+{{/vars}}
});
__PACKAGE__->swagger_types( {
diff --git a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
index 891149d8f55..7945137c664 100644
--- a/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ApiClient.mustache
@@ -259,7 +259,7 @@ class ApiClient
*
* @return string Accept (e.g. application/json)
*/
- public static function selectHeaderAccept($accept)
+ public function selectHeaderAccept($accept)
{
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
return null;
@@ -277,7 +277,7 @@ class ApiClient
*
* @return string Content-Type (e.g. application/json)
*/
- public static function selectHeaderContentType($content_type)
+ public function selectHeaderContentType($content_type)
{
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
return 'application/json';
@@ -299,9 +299,9 @@ class ApiClient
{
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();
- $key = ''; // [+]
+ $key = '';
- foreach(explode("\n", $raw_headers) as $i => $h)
+ foreach(explode("\n", $raw_headers) as $h)
{
$h = explode(':', $h, 2);
@@ -311,26 +311,22 @@ class ApiClient
$headers[$h[0]] = trim($h[1]);
elseif (is_array($headers[$h[0]]))
{
- // $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-]
- // $headers[$h[0]] = $tmp; // [-]
- $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+]
+ $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1])));
}
else
{
- // $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-]
- // $headers[$h[0]] = $tmp; // [-]
- $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+]
+ $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1])));
}
- $key = $h[0]; // [+]
+ $key = $h[0];
+ }
+ else
+ {
+ if (substr($h[0], 0, 1) == "\t")
+ $headers[$key] .= "\r\n\t".trim($h[0]);
+ elseif (!$key)
+ $headers[0] = trim($h[0]);trim($h[0]);
}
- else // [+]
- { // [+]
- if (substr($h[0], 0, 1) == "\t") // [+]
- $headers[$key] .= "\r\n\t".trim($h[0]); // [+]
- elseif (!$key) // [+]
- $headers[0] = trim($h[0]);trim($h[0]); // [+]
- } // [+]
}
return $headers;
diff --git a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
index 759bf3c6bfb..34d79b0ae39 100644
--- a/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache
@@ -55,14 +55,14 @@ class ObjectSerializer
public static function sanitizeForSerialization($data)
{
if (is_scalar($data) || null === $data) {
- $sanitized = $data;
+ return $data;
} elseif ($data instanceof \DateTime) {
- $sanitized = $data->format(\DateTime::ATOM);
+ return $data->format(\DateTime::ATOM);
} elseif (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = self::sanitizeForSerialization($value);
}
- $sanitized = $data;
+ return $data;
} elseif (is_object($data)) {
$values = array();
foreach (array_keys($data::swaggerTypes()) as $property) {
@@ -71,12 +71,10 @@ class ObjectSerializer
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($data->$getter());
}
}
- $sanitized = (object)$values;
+ return (object)$values;
} else {
- $sanitized = (string)$data;
+ return (string)$data;
}
-
- return $sanitized;
}
/**
@@ -224,7 +222,7 @@ class ObjectSerializer
public static function deserialize($data, $class, $httpHeaders=null, $discriminator=null)
{
if (null === $data) {
- $deserialized = null;
+ return null;
} elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = array();
@@ -235,16 +233,17 @@ class ObjectSerializer
$deserialized[$key] = self::deserialize($value, $subClass, null, $discriminator);
}
}
+ return $deserialized;
} elseif (strcasecmp(substr($class, -2), '[]') == 0) {
$subClass = substr($class, 0, -2);
$values = array();
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass, null, $discriminator);
}
- $deserialized = $values;
+ return $values;
} elseif ($class === 'object') {
settype($data, 'array');
- $deserialized = $data;
+ return $data;
} elseif ($class === '\DateTime') {
// Some API's return an invalid, empty string as a
// date-time property. DateTime::__construct() will return
@@ -253,13 +252,13 @@ class ObjectSerializer
// be interpreted as a missing field/value. Let's handle
// this graceful.
if (!empty($data)) {
- $deserialized = new \DateTime($data);
+ return new \DateTime($data);
} else {
- $deserialized = null;
+ return null;
}
} elseif (in_array($class, array({{&primitives}}))) {
settype($data, $class);
- $deserialized = $data;
+ return $data;
} elseif ($class === '\SplFileObject') {
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
@@ -270,7 +269,8 @@ class ObjectSerializer
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
-
+ return $deserialized;
+
} else {
// If a discriminator is defined and points to a valid subclass, use it.
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
@@ -292,9 +292,7 @@ class ObjectSerializer
$instance->$propertySetter(self::deserialize($propertyValue, $type, null, $discriminator));
}
}
- $deserialized = $instance;
+ return $instance;
}
-
- return $deserialized;
}
}
diff --git a/modules/swagger-codegen/src/main/resources/php/README.mustache b/modules/swagger-codegen/src/main/resources/php/README.mustache
index 4088ddf1fbe..e64b0bf22c6 100644
--- a/modules/swagger-codegen/src/main/resources/php/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/README.mustache
@@ -5,7 +5,7 @@
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
-- API verion: {{appVersion}}
+- API version: {{appVersion}}
- Package version: {{artifactVersion}}
- Build date: {{generatedDate}}
- Build package: {{generatorClass}}
@@ -116,7 +116,7 @@ Class | Method | HTTP request | Description
{{/isBasic}}
{{#isOAuth}}- **Type**: OAuth
- **Flow**: {{{flow}}}
-- **Authorizatoin URL**: {{{authorizationUrl}}}
+- **Authorization URL**: {{{authorizationUrl}}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}} - **{{{scope}}}**: {{{description}}}
{{/scopes}}
diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache
index adbbd8e1fe2..2692ba66f94 100644
--- a/modules/swagger-codegen/src/main/resources/php/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api.mustache
@@ -102,7 +102,7 @@ use \{{invokerPackage}}\ObjectSerializer;
*/
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
- list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+ list($response) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
return $response;
}
@@ -130,11 +130,11 @@ use \{{invokerPackage}}\ObjectSerializer;
$queryParams = array();
$headerParams = array();
$formParams = array();
- $_header_accept = ApiClient::selectHeaderAccept(array({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}));
+ $_header_accept = $this->apiClient->selectHeaderAccept(array({{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
- $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}}));
+ $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}}));
{{#queryParams}}// query params
{{#collectionFormat}}
@@ -223,14 +223,14 @@ use \{{invokerPackage}}\ObjectSerializer;
return array(null, $statusCode, $httpHeader);
}
- return array(\{{invokerPackage}}\ObjectSerializer::deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader);
+ return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader{{#discriminator}}, '{{discriminator}}'{{/discriminator}}), $statusCode, $httpHeader);
{{/returnType}}{{^returnType}}
return array(null, $statusCode, $httpHeader);
{{/returnType}}
} catch (ApiException $e) {
switch ($e->getCode()) { {{#responses}}{{#dataType}}
{{^isWildcard}}case {{code}}:{{/isWildcard}}{{#isWildcard}}default:{{/isWildcard}}
- $data = \{{invokerPackage}}\ObjectSerializer::deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders());
+ $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '{{dataType}}', $e->getResponseHeaders());
$e->setResponseObject($data);
break;{{/dataType}}{{/responses}}
}
diff --git a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache
index bb55e80604c..ba3529e969c 100644
--- a/modules/swagger-codegen/src/main/resources/php/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/api_doc.mustache
@@ -61,7 +61,7 @@ Name | Type | Description | Notes
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
-### HTTP reuqest headers
+### HTTP request headers
- **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
diff --git a/modules/swagger-codegen/src/main/resources/php/model.mustache b/modules/swagger-codegen/src/main/resources/php/model.mustache
index b58af994c24..6f292e854af 100644
--- a/modules/swagger-codegen/src/main/resources/php/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/php/model.mustache
@@ -48,6 +48,12 @@ use \ArrayAccess;
*/
class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayAccess
{
+ /**
+ * The original name of the model.
+ * @var string
+ */
+ static $swaggerModelName = '{{name}}';
+
/**
* Array of property to type mappings. Used for (de)serialization
* @var string[]
@@ -115,6 +121,11 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
public function __construct(array $data = null)
{
{{#parent}}parent::__construct($data);{{/parent}}
+ {{#discriminator}}// Initialize discriminator property with the model name.
+ $discrimintor = array_search('{{discriminator}}', self::$attributeMap);
+ $this->{$discrimintor} = static::$swaggerModelName;
+ {{/discriminator}}
+
if ($data != null) {
{{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}
{{/hasMore}}{{/vars}}
@@ -192,11 +203,11 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
*/
public function __toString()
{
- if (defined('JSON_PRETTY_PRINT')) {
+ if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
- } else {
- return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this));
}
+
+ return json_encode(\{{invokerPackage}}\ObjectSerializer::sanitizeForSerialization($this));
}
}
{{/model}}
diff --git a/modules/swagger-codegen/src/main/resources/python/README.mustache b/modules/swagger-codegen/src/main/resources/python/README.mustache
index 463bbb37a18..8fe1045f661 100644
--- a/modules/swagger-codegen/src/main/resources/python/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/README.mustache
@@ -1,73 +1,122 @@
+# {{packageName}}
+{{#appDescription}}
+{{{appDescription}}}
+{{/appDescription}}
+
+This Python package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
+
+- API version: {{appVersion}}
+- Package version: {{packageVersion}}
+- Build date: {{generatedDate}}
+- Build package: {{generatorClass}}
+{{#infoUrl}}
+For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
+{{/infoUrl}}
+
## Requirements.
-Python 2.7 and later.
-## Setuptools
-You can install the bindings via [Setuptools](http://pypi.python.org/pypi/setuptools).
+Python 2.7 and 3.4+
+
+## Installation & Usage
+### pip install
+
+If the python package is hosted on Github, you can install directly from Github
```sh
-python setup.py install
+pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git
+```
+(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/{{{gitUserId}}}/{{{gitRepoId}}}.git`)
+
+Then import the package:
+```python
+import {{{packageName}}}
```
-Or you can install from Github via pip:
+### Setuptools
+
+Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
-pip install git+https://github.com/geekerzp/swagger_client.git
+python setup.py install --user
```
+(or `sudo python setup.py install` to install the package for all users)
-To use the bindings, import the pacakge:
-
+Then import the package:
```python
-import swagger_client
-```
-
-## Manual Installation
-If you do not wish to use setuptools, you can download the latest release.
-Then, to use the bindings, import the package:
-
-```python
-import path.to.swagger_client
+import {{{packageName}}}
```
## Getting Started
-TODO
+Please follow the [installation procedure](#installation--usage) and then run the following:
-## Documentation
+```python
+import time
+import {{{packageName}}}
+from {{{packageName}}}.rest import ApiException
+from pprint import pprint
+{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
+# Configure HTTP basic authorization: {{{name}}}
+{{{packageName}}}.configuration.username = 'YOUR_USERNAME'
+{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}}
+# Configure API key authorization: {{{name}}}
+{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
+# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
+# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'BEARER'{{/isApiKey}}{{#isOAuth}}
+# Configure OAuth2 access token for authorization: {{{name}}}
+{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}}
+{{/hasAuthMethods}}
+# create an instance of the API class
+api_instance = {{{packageName}}}.{{{classname}}}
+{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
+{{/allParams}}
-TODO
-
-## Tests
-
-(Please make sure you have [virtualenv](http://docs.python-guide.org/en/latest/dev/virtualenvs/) installed)
-
- Execute the following command to run the tests in the current Python (v2 or v3) environment:
-
-```sh
-$ make test
-[... magically installs dependencies and runs tests on your virtualenv]
-Ran 7 tests in 19.289s
-
-OK
+try:
+{{#summary}} # {{{.}}}
+{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
+ pprint(api_response){{/returnType}}
+except ApiException as e:
+ print "Exception when calling {{classname}}->{{operationId}}: %s\n" % e
+{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}}
```
-or
-```
-$ mvn integration-test -rf :PythonPetstoreClientTests
-Using 2195432783 as seed
-[INFO] ------------------------------------------------------------------------
-[INFO] BUILD SUCCESS
-[INFO] ------------------------------------------------------------------------
-[INFO] Total time: 37.594 s
-[INFO] Finished at: 2015-05-16T18:00:35+08:00
-[INFO] Final Memory: 11M/156M
-[INFO] ------------------------------------------------------------------------
-```
-If you want to run the tests in all the python platforms:
+## Documentation for API Endpoints
-```sh
-$ make test-all
-[... tox creates a virtualenv for every platform and runs tests inside of each]
- py27: commands succeeded
- py34: commands succeeded
- congratulations :)
-```
+All URIs are relative to *{{basePath}}*
+
+Class | Method | HTTP request | Description
+------------ | ------------- | ------------- | -------------
+{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
+
+## Documentation For Models
+
+{{#models}}{{#model}} - [{{{classname}}}]({{modelDocPath}}{{{classname}}}.md)
+{{/model}}{{/models}}
+
+## Documentation For Authorization
+
+{{^authMethods}} All endpoints do not require authorization.
+{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
+{{#authMethods}}## {{{name}}}
+
+{{#isApiKey}}- **Type**: API key
+- **API key parameter name**: {{{keyParamName}}}
+- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
+{{/isApiKey}}
+{{#isBasic}}- **Type**: HTTP basic authentication
+{{/isBasic}}
+{{#isOAuth}}- **Type**: OAuth
+- **Flow**: {{{flow}}}
+- **Authorization URL**: {{{authorizationUrl}}}
+- **Scopes**: {{^scopes}}N/A{{/scopes}}
+{{#scopes}} - **{{{scope}}}**: {{{description}}}
+{{/scopes}}
+{{/isOAuth}}
+
+{{/authMethods}}
+
+## Author
+
+{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
+{{/hasMore}}{{/apis}}{{/apiInfo}}
diff --git a/modules/swagger-codegen/src/main/resources/python/api.mustache b/modules/swagger-codegen/src/main/resources/python/api.mustache
index 230f05d94af..0967a2ec6b3 100644
--- a/modules/swagger-codegen/src/main/resources/python/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/api.mustache
@@ -47,7 +47,7 @@ class {{classname}}(object):
self.api_client = config.api_client
{{#operation}}
- def {{nickname}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs):
+ def {{operationId}}(self, {{#sortParamsByRequiredFlag}}{{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}{{/sortParamsByRequiredFlag}}**kwargs):
"""
{{{summary}}}
{{{notes}}}
@@ -59,10 +59,10 @@ class {{classname}}(object):
>>> pprint(response)
>>>
{{#sortParamsByRequiredFlag}}
- >>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function)
+ >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}callback=callback_function)
{{/sortParamsByRequiredFlag}}
{{^sortParamsByRequiredFlag}}
- >>> thread = api.{{nickname}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function)
+ >>> thread = api.{{operationId}}({{#allParams}}{{#required}}{{paramName}}={{paramName}}_value, {{/required}}{{/allParams}}callback=callback_function)
{{/sortParamsByRequiredFlag}}
:param callback function: The callback function
@@ -83,7 +83,7 @@ class {{classname}}(object):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
- " to method {{nickname}}" % key
+ " to method {{operationId}}" % key
)
params[key] = val
del params['kwargs']
@@ -92,7 +92,7 @@ class {{classname}}(object):
{{#required}}
# verify the required parameter '{{paramName}}' is set
if ('{{paramName}}' not in params) or (params['{{paramName}}'] is None):
- raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{nickname}}`")
+ raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`")
{{/required}}
{{/allParams}}
diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache
index 98fee823591..07b9419e08f 100644
--- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache
@@ -371,7 +371,8 @@ class ApiClient(object):
elif method == "DELETE":
return self.rest_client.DELETE(url,
query_params=query_params,
- headers=headers)
+ headers=headers,
+ body=body)
else:
raise ValueError(
"http method must be `GET`, `HEAD`,"
diff --git a/modules/swagger-codegen/src/main/resources/python/api_doc.mustache b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache
new file mode 100644
index 00000000000..99a05f8c43d
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/api_doc.mustache
@@ -0,0 +1,74 @@
+# {{packageName}}.{{classname}}{{#description}}
+{{description}}{{/description}}
+
+All URIs are relative to *{{basePath}}*
+
+Method | HTTP request | Description
+------------- | ------------- | -------------
+{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
+{{/operation}}{{/operations}}
+
+{{#operations}}
+{{#operation}}
+# **{{{operationId}}}**
+> {{#returnType}}{{{returnType}}} {{/returnType}}{{{operationId}}}({{#allParams}}{{#required}}{{{paramName}}}{{/required}}{{^required}}{{{paramName}}}={{{paramName}}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
+
+{{{summary}}}{{#notes}}
+
+{{{notes}}}{{/notes}}
+
+### Example
+```python
+import time
+import {{{packageName}}}
+from {{{packageName}}}.rest import ApiException
+from pprint import pprint
+{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
+# Configure HTTP basic authorization: {{{name}}}
+{{{packageName}}}.configuration.username = 'YOUR_USERNAME'
+{{{packageName}}}.configuration.password = 'YOUR_PASSWORD'{{/isBasic}}{{#isApiKey}}
+# Configure API key authorization: {{{name}}}
+{{{packageName}}}.configuration.api_key['{{{keyParamName}}}'] = 'YOUR_API_KEY'
+# Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
+# {{{packageName}}}.configuration.api_key_prefix['{{{keyParamName}}}'] = 'BEARER'{{/isApiKey}}{{#isOAuth}}
+# Configure OAuth2 access token for authorization: {{{name}}}
+{{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}}
+{{/hasAuthMethods}}
+
+# create an instance of the API class
+api_instance = {{{packageName}}}.{{{classname}}}()
+{{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
+{{/allParams}}
+
+try:
+{{#summary}} # {{{.}}}
+{{/summary}} {{#returnType}}api_response = {{/returnType}}api_instance.{{{operationId}}}({{#allParams}}{{#required}}{{paramName}}{{/required}}{{^required}}{{paramName}}={{paramName}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}
+ pprint(api_response){{/returnType}}
+except ApiException as e:
+ print "Exception when calling {{classname}}->{{operationId}}: %s\n" % e
+```
+
+### Parameters
+{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}
+Name | Type | Description | Notes
+------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}
+{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
+{{/allParams}}
+
+### Return type
+
+{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}}void (empty response body){{/returnType}}
+
+### Authorization
+
+{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}
+
+### HTTP request headers
+
+ - **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
+ - **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
+
+[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
+
+{{/operation}}
+{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/python/model_doc.mustache b/modules/swagger-codegen/src/main/resources/python/model_doc.mustache
new file mode 100644
index 00000000000..569550df372
--- /dev/null
+++ b/modules/swagger-codegen/src/main/resources/python/model_doc.mustache
@@ -0,0 +1,11 @@
+{{#models}}{{#model}}# {{classname}}
+
+## Properties
+Name | Type | Description | Notes
+------------ | ------------- | ------------- | -------------
+{{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
+{{/vars}}
+
+[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
+
+{{/model}}{{/models}}
diff --git a/modules/swagger-codegen/src/main/resources/python/rest.mustache b/modules/swagger-codegen/src/main/resources/python/rest.mustache
index c5b9a4e6f91..352bb503ac5 100644
--- a/modules/swagger-codegen/src/main/resources/python/rest.mustache
+++ b/modules/swagger-codegen/src/main/resources/python/rest.mustache
@@ -133,8 +133,8 @@ class RESTClientObject(object):
headers['Content-Type'] = 'application/json'
try:
- # For `POST`, `PUT`, `PATCH`, `OPTIONS`
- if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']:
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
+ if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if query_params:
url += '?' + urlencode(query_params)
if headers['Content-Type'] == 'application/json':
@@ -154,7 +154,7 @@ class RESTClientObject(object):
fields=post_params,
encode_multipart=True,
headers=headers)
- # For `GET`, `HEAD`, `DELETE`
+ # For `GET`, `HEAD`
else:
r = self.pool_manager.request(method, url,
fields=query_params,
@@ -195,10 +195,11 @@ class RESTClientObject(object):
post_params=post_params,
body=body)
- def DELETE(self, url, headers=None, query_params=None):
+ def DELETE(self, url, headers=None, query_params=None, body=None):
return self.request("DELETE", url,
headers=headers,
- query_params=query_params)
+ query_params=query_params,
+ body=body)
def POST(self, url, headers=None, query_params=None, post_params=None, body=None):
return self.request("POST", url,
diff --git a/modules/swagger-codegen/src/main/resources/ruby/README.mustache b/modules/swagger-codegen/src/main/resources/ruby/README.mustache
index 3566329c244..7f54eef9e69 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/README.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/README.mustache
@@ -8,7 +8,7 @@
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
-- API verion: {{appVersion}}
+- API version: {{appVersion}}
- Package version: {{gemVersion}}
- Build date: {{generatedDate}}
- Build package: {{generatorClass}}
@@ -119,7 +119,7 @@ Class | Method | HTTP request | Description
{{/isBasic}}
{{#isOAuth}}- **Type**: OAuth
- **Flow**: {{flow}}
-- **Authorizatoin URL**: {{authorizationUrl}}
+- **Authorization URL**: {{authorizationUrl}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}} - {{scope}}: {{description}}
{{/scopes}}
diff --git a/modules/swagger-codegen/src/main/resources/ruby/api.mustache b/modules/swagger-codegen/src/main/resources/ruby/api.mustache
index d67b39f0d48..594a813de72 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/api.mustache
@@ -21,7 +21,7 @@ module {{moduleName}}
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
- {{#returnType}}data, status_code, headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
+ {{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
{{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}}
end
@@ -58,12 +58,12 @@ module {{moduleName}}
header_params = {}
# HTTP header 'Accept' (if needed)
- _header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
- _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
+ local_header_accept = [{{#produces}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/produces}}]
+ local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
# HTTP header 'Content-Type'
- _header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
- header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type){{#headerParams}}{{#required}}
+ local_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
+ header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type){{#headerParams}}{{#required}}
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}{{/required}}{{/headerParams}}{{#headerParams}}{{^required}}
header_params[:'{{{baseName}}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if opts[:'{{{paramName}}}']{{/required}}{{/headerParams}}
diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache
index 520a50b76ca..d423ec82a19 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache
@@ -19,6 +19,8 @@ module {{moduleName}}
# @return [Hash]
attr_accessor :default_headers
+ # Initializes the ApiClient
+ # @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}"
@@ -59,6 +61,15 @@ module {{moduleName}}
return data, response.code, response.headers
end
+ # Builds the HTTP request
+ #
+ # @param [String] http_method HTTP method/verb (e.g. POST)
+ # @param [String] path URL path (e.g. /account/new)
+ # @option opts [Hash] :header_params Header parameters
+ # @option opts [Hash] :query_params Query parameters
+ # @option opts [Hash] :form_params Query parameters
+ # @option opts [Object] :body HTTP body (JSON/XML)
+ # @return [Typhoeus::Request] A Typhoeus Request
def build_request(http_method, path, opts = {})
url = build_request_url(path)
http_method = http_method.to_sym.downcase
@@ -100,12 +111,15 @@ module {{moduleName}}
# application/json
# application/json; charset=UTF8
# APPLICATION/JSON
+ # @param [String] mime MIME
+ # @return [Boolean] True if the MIME is applicaton/json
def json_mime?(mime)
- !!(mime =~ /\Aapplication\/json(;.*)?\z/i)
+ !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
end
# Deserialize the response to the given return type.
#
+ # @param [Response] response HTTP response
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
def deserialize(response, return_type)
body = response.body
@@ -136,6 +150,9 @@ module {{moduleName}}
end
# Convert data to the given return type.
+ # @param [Object] data Data to be converted
+ # @param [String] return_type Return type
+ # @return [Mixed] Data in a particular type
def convert_to_type(data, return_type)
return nil if data.nil?
case return_type
@@ -208,7 +225,7 @@ module {{moduleName}}
# @param [String] filename the filename to be sanitized
# @return [String] the sanitized filename
def sanitize_filename(filename)
- filename.gsub /.*[\/\\]/, ''
+ filename.gsub(/.*[\/\\]/, '')
end
def build_request_url(path)
@@ -217,6 +234,12 @@ module {{moduleName}}
URI.encode(@config.base_url + path)
end
+ # Builds the HTTP request body
+ #
+ # @param [Hash] header_params Header parameters
+ # @param [Hash] form_params Query parameters
+ # @param [Object] body HTTP body (JSON/XML)
+ # @return [String] HTTP body data in the form of string
def build_request_body(header_params, form_params, body)
# http form
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
@@ -240,6 +263,10 @@ module {{moduleName}}
end
# Update hearder and query params based on authentication settings.
+ #
+ # @param [Hash] header_params Header parameters
+ # @param [Hash] form_params Query parameters
+ # @param [String] auth_names Authentication scheme name
def update_params_for_auth!(header_params, query_params, auth_names)
Array(auth_names).each do |auth_name|
auth_setting = @config.auth_settings[auth_name]
@@ -252,6 +279,9 @@ module {{moduleName}}
end
end
+ # Sets user agent in HTTP header
+ #
+ # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
def user_agent=(user_agent)
@user_agent = user_agent
@default_headers['User-Agent'] = @user_agent
@@ -283,13 +313,13 @@ module {{moduleName}}
# @return [String] JSON string representation of the object
def object_to_http_body(model)
return model if model.nil? || model.is_a?(String)
- _body = nil
+ local_body = nil
if model.is_a?(Array)
- _body = model.map{|m| object_to_hash(m) }
+ local_body = model.map{|m| object_to_hash(m) }
else
- _body = object_to_hash(model)
+ local_body = object_to_hash(model)
end
- _body.to_json
+ local_body.to_json
end
# Convert object(non-array) to hash.
diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache
index 6d36e7dfe89..169920a4bc3 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/api_doc.mustache
@@ -68,7 +68,7 @@ Name | Type | Description | Notes
{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{name}}](../README.md#{{name}}){{^-last}}, {{/-last}}{{/authMethods}}
-### HTTP reuqest headers
+### HTTP request headers
- **Content-Type**: {{#consumes}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}
diff --git a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
index 2c7747c4127..87877d1763e 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/base_object.mustache
@@ -1,23 +1,27 @@
- # build the object from hash
+ # Builds the object from hash
+ # @param [Hash] attributes Model attributes in the form of hash
+ # @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /^Array<(.*)>/i
+ # check to ensure the input is an array given that the the attribute
+ # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
- else
- #TODO show warning in debug mode
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
- else
- # data not found in attributes(hash), not an issue as the data can be optional
- end
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
+ # Deserializes the data based on type
+ # @param string type Data type
+ # @param string value Value to be deserialized
+ # @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
@@ -51,21 +55,25 @@
end
end
else # model
- _model = {{moduleName}}.const_get(type).new
- _model.build_from_hash(value)
+ temp_model = {{moduleName}}.const_get(type).new
+ temp_model.build_from_hash(value)
end
end
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
def to_s
to_hash.to_s
end
- # to_body is an alias to to_body (backward compatibility))
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
- # return the object in the form of hash
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
@@ -76,8 +84,10 @@
hash
end
- # Method to output non-array value in the form of hash
+ # Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
+ # @param [Object] value Any valid value
+ # @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
diff --git a/modules/swagger-codegen/src/main/resources/ruby/model.mustache b/modules/swagger-codegen/src/main/resources/ruby/model.mustache
index 86567e1d594..5b7b617481f 100644
--- a/modules/swagger-codegen/src/main/resources/ruby/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/ruby/model.mustache
@@ -23,16 +23,19 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
# Attribute type mapping.
def self.swagger_types
{
- {{#vars}}:'{{{name}}}' => :'{{{datatype}}}'{{#hasMore}},{{/hasMore}}
+ {{#vars}}
+ :'{{{name}}}' => :'{{{datatype}}}'{{#hasMore}},{{/hasMore}}
{{/vars}}
}
end
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
{{#vars}}
if attributes[:'{{{baseName}}}']
@@ -46,6 +49,7 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
end
{{#vars}}{{#isEnum}}
# Custom attribute writer method checking allowed values (enum).
+ # @param [Object] {{{name}}} Object to be assigned
def {{{name}}}=({{{name}}})
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
if {{{name}}} && !allowed_values.include?({{{name}}})
@@ -54,7 +58,8 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
@{{{name}}} = {{{name}}}
end
{{/isEnum}}{{/vars}}
- # Check equality by comparing each attribute.
+ # Checks equality by comparing each attribute.
+ # @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class{{#vars}} &&
@@ -62,11 +67,13 @@ module {{moduleName}}{{#models}}{{#model}}{{#description}}
end
# @see the `==` method
+ # @param [Object] Object to be compared
def eql?(o)
self == o
end
- # Calculate hash code according to all attributes.
+ # Calculates hash code according to all attributes.
+ # @return [Fixnum] Hash code
def hash
[{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash
end
diff --git a/modules/swagger-codegen/src/main/resources/scala/api.mustache b/modules/swagger-codegen/src/main/resources/scala/api.mustache
index 41b58374dea..6345cd876c8 100644
--- a/modules/swagger-codegen/src/main/resources/scala/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/scala/api.mustache
@@ -44,14 +44,14 @@ class {{classname}}(val defBasePath: String = "{{basePath}}",
val headerParams = new HashMap[String, String]
val formParams = new HashMap[String, String]
- {{#requiredParamCount}}
- // verify required params are set
- (List({{/requiredParamCount}}{{#requiredParams}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/requiredParams}}{{#requiredParamCount}}).filter(_ != null)).size match {
- case {{requiredParamCount}} => // all required values set
- case _ => throw new Exception("missing required params")
- }
- {{/requiredParamCount}}
+ {{#allParams}}
+ {{#required}}
+ {{^isPrimitiveType}}
+ if ({{paramName}} == null) throw new Exception("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}")
+ {{/isPrimitiveType}}
+ {{/required}}
+ {{/allParams}}
{{#queryParams}}if(String.valueOf({{paramName}}) != "null") queryParams += "{{baseName}}" -> {{paramName}}.toString
{{/queryParams}}
@@ -71,7 +71,8 @@ class {{classname}}(val defBasePath: String = "{{basePath}}",
postBody = mp
}
else {
- {{#formParams}}{{#notFile}}formParams += "{{baseName}}" -> {{paramName}}.toString(){{/notFile}}
+ {{#formParams}}
+ {{#notFile}}formParams += "{{baseName}}" -> {{paramName}}.toString(){{/notFile}}
{{/formParams}}
}
@@ -87,6 +88,7 @@ class {{classname}}(val defBasePath: String = "{{basePath}}",
case ex: ApiException => throw ex
}
}
+
{{/operation}}
}
{{/operations}}
diff --git a/modules/swagger-codegen/src/main/resources/scala/pom.mustache b/modules/swagger-codegen/src/main/resources/scala/pom.mustache
index b3260b9fd62..51256c42491 100644
--- a/modules/swagger-codegen/src/main/resources/scala/pom.mustache
+++ b/modules/swagger-codegen/src/main/resources/scala/pom.mustache
@@ -210,7 +210,7 @@
1.2
2.2
1.19
-
1.5.7
+
1.5.8
1.0.5
1.0.0
2.4.2
diff --git a/modules/swagger-codegen/src/main/resources/scalatra/model.mustache b/modules/swagger-codegen/src/main/resources/scalatra/model.mustache
index 8c5d1954662..e9dac65dd79 100644
--- a/modules/swagger-codegen/src/main/resources/scalatra/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/scalatra/model.mustache
@@ -7,9 +7,8 @@ package {{package}}
{{#model}}
case class {{classname}} (
- {{#vars}}{{name}}: {{#isNotRequired}}Option[{{/isNotRequired}}{{datatype}}{{#isNotRequired}}] {{#description}} // {{description}}{{/description}}
- {{/isNotRequired}}{{#hasMore}},
- {{/hasMore}}{{/vars}}
+ {{#vars}}{{name}}: {{^required}}Option[{{/required}}{{datatype}}{{^required}}]{{/required}}{{#hasMore}},{{/hasMore}}{{#description}} // {{description}}{{/description}}
+ {{/vars}}
)
{{/model}}
-{{/models}}
\ No newline at end of file
+{{/models}}
diff --git a/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache b/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache
index 6b4d36f9410..2faa0a6f24d 100644
--- a/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/AlamofireImplementations.mustache
@@ -75,7 +75,7 @@ class AlamofireRequestBuilder
: RequestBuilder {
request.authenticate(usingCredential: credential)
}
- request.responseJSON(options: .AllowFragments) { response in
+ request.validate().responseJSON(options: .AllowFragments) { response in
managerStore.removeValueForKey(managerId)
if response.result.isFailure {
diff --git a/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache b/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache
index ed5786d3faa..54a1f127ef7 100644
--- a/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/Extensions.mustache
@@ -19,6 +19,14 @@ extension Int: JSONEncodable {
func encodeToJSON() -> AnyObject { return self }
}
+extension Int32: JSONEncodable {
+ func encodeToJSON() -> AnyObject { return NSNumber(int: self) }
+}
+
+extension Int64: JSONEncodable {
+ func encodeToJSON() -> AnyObject { return NSNumber(longLong: self) }
+}
+
extension Double: JSONEncodable {
func encodeToJSON() -> AnyObject { return self }
}
diff --git a/modules/swagger-codegen/src/main/resources/swift/Models.mustache b/modules/swagger-codegen/src/main/resources/swift/Models.mustache
index d3090faf2a0..795fdd3d5e7 100644
--- a/modules/swagger-codegen/src/main/resources/swift/Models.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/Models.mustache
@@ -56,6 +56,12 @@ class Decoders {
static func decode(clazz clazz: T.Type, source: AnyObject) -> T {
initialize()
+ if T.self is Int32.Type && source is NSNumber {
+ return source.intValue as! T;
+ }
+ if T.self is Int64.Type && source is NSNumber {
+ return source.longLongValue as! T;
+ }
if source is T {
return source as! T
}
@@ -124,11 +130,11 @@ class Decoders {
fatalError("formatter failed to parse \(source)")
} {{#models}}{{#model}}
- // Decoder for [{{{classname}}}]
+ // Decoder for [{{{classname}}}]
Decoders.addDecoder(clazz: [{{{classname}}}].self) { (source: AnyObject) -> [{{{classname}}}] in
return Decoders.decode(clazz: [{{{classname}}}].self, source: source)
}
- // Decoder for {{{classname}}}
+ // Decoder for {{{classname}}}
Decoders.addDecoder(clazz: {{{classname}}}.self) { (source: AnyObject) -> {{{classname}}} in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = {{classname}}(){{#vars}}{{#isEnum}}
diff --git a/modules/swagger-codegen/src/main/resources/swift/api.mustache b/modules/swagger-codegen/src/main/resources/swift/api.mustache
index ada4ec90d36..195fb88aeed 100644
--- a/modules/swagger-codegen/src/main/resources/swift/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/api.mustache
@@ -23,7 +23,7 @@ public class {{classname}}: APIBase {
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
- parameter completion: completion handler to receive the data and the error objects
*/
- public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: (({{#returnType}}data: {{{returnType}}}?, {{/returnType}}error: ErrorType?) -> Void)) {
+ public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}{{#hasParams}}, {{/hasParams}}completion: (({{#returnType}}data: {{{returnType}}}?, {{/returnType}}error: ErrorType?) -> Void)) {
{{operationId}}WithRequestBuilder({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}).execute { (response, error) -> Void in
completion({{#returnType}}data: response?.body, {{/returnType}}error: error);
}
@@ -37,7 +37,7 @@ public class {{classname}}: APIBase {
- parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}
- returns: Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
*/
- public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
+ public class func {{operationId}}({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
let deferred = Promise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>.pendingPromise()
{{operationId}}({{#allParams}}{{paramName}}: {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { {{#returnType}}data, {{/returnType}}error in
if let error = error {
@@ -69,7 +69,7 @@ public class {{classname}}: APIBase {
- returns: RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{description}}
*/
- public class func {{operationId}}WithRequestBuilder({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
+ public class func {{operationId}}WithRequestBuilder({{#allParams}}{{^secondaryParam}}{{paramName}} {{/secondaryParam}}{{paramName}}: {{{dataType}}}{{^required}}? = nil{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> RequestBuilder<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {
{{^pathParams}}let{{/pathParams}}{{#pathParams}}{{^secondaryParam}}var{{/secondaryParam}}{{/pathParams}} path = "{{path}}"{{#pathParams}}
path = path.stringByReplacingOccurrencesOfString("{{=<% %>=}}{<%paramName%>}<%={{ }}=%>", withString: "\({{paramName}})", options: .LiteralSearch, range: nil){{/pathParams}}
let URLString = {{projectName}}API.basePath + path
diff --git a/modules/swagger-codegen/src/main/resources/swift/model.mustache b/modules/swagger-codegen/src/main/resources/swift/model.mustache
index f095940a0c1..3c0a47c2987 100644
--- a/modules/swagger-codegen/src/main/resources/swift/model.mustache
+++ b/modules/swagger-codegen/src/main/resources/swift/model.mustache
@@ -11,22 +11,32 @@ import Foundation
/** {{description}} */{{/description}}
public class {{classname}}: JSONEncodable {
-{{#vars}}{{#isEnum}}
+{{#vars}}
+{{#isEnum}}
public enum {{datatypeWithEnum}}: String { {{#allowableValues}}{{#values}}
case {{enum}} = "{{raw}}"{{/values}}{{/allowableValues}}
}
- {{/isEnum}}{{/vars}}
- {{#vars}}{{#isEnum}}{{#description}}/** {{description}} */
- {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{/isEnum}}{{^isEnum}}{{#description}}/** {{description}} */
- {{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{/isEnum}}
- {{/vars}}
+{{/isEnum}}
+{{/vars}}
+{{#vars}}
+{{#isEnum}}
+ {{#description}}/** {{description}} */
+ {{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
+{{/isEnum}}
+{{^isEnum}}
+ {{#description}}/** {{description}} */
+ {{/description}}public var {{name}}: {{{datatype}}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{#required}}!{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
+{{/isEnum}}
+{{/vars}}
public init() {}
// MARK: JSONEncodable
func encodeToJSON() -> AnyObject {
- var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}
- nillableDictionary["{{baseName}}"] = self.{{name}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}}
+ var nillableDictionary = [String:AnyObject?](){{#vars}}{{#isNotContainer}}{{#isPrimitiveType}}{{^isEnum}}{{#isInteger}}
+ nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isInteger}}{{#isLong}}
+ nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isLong}}{{^isLong}}{{^isInteger}}
+ nillableDictionary["{{baseName}}"] = self.{{name}}{{/isInteger}}{{/isLong}}{{/isEnum}}{{/isPrimitiveType}}{{#isEnum}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.rawValue{{/isEnum}}{{^isPrimitiveType}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isPrimitiveType}}{{/isNotContainer}}{{#isContainer}}
nillableDictionary["{{baseName}}"] = self.{{name}}{{^unwrapRequired}}?{{/unwrapRequired}}{{#unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}.encodeToJSON(){{/isContainer}}{{/vars}}
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 4b422bb3c63..bd0fcc168cd 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
@@ -102,16 +102,18 @@ public class CodegenTest {
public void enumQueryParameterTest() {
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/petstore.json");
final DefaultCodegen codegen = new DefaultCodegen();
- final String path = "/store/findByStatus";
+ final String path = "/pet/findByStatus";
final Operation p = model.getPaths().get(path).getGet();
final CodegenOperation op = codegen.fromOperation(path, "get", p, model.getDefinitions());
Assert.assertEquals(op.queryParams.size(), 1);
final CodegenParameter statusParam = op.queryParams.get(0);
- Assert.assertEquals(statusParam.datatypeWithEnum, "StatusEnum");
- Assert.assertTrue(statusParam.isEnum);
- Assert.assertEquals(statusParam._enum.size(), 3);
+ Assert.assertEquals(statusParam.datatypeWithEnum, "List");
+ Assert.assertEquals(statusParam.baseType, "String");
+ // currently there's no way to tell if the inner type of a list is a enum
+ //Assert.assertTrue(statusParam.isEnum);
+ //Assert.assertEquals(statusParam._enum.size(), 3);
}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientOptionsTest.java
new file mode 100644
index 00000000000..528666c58e5
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoClientOptionsTest.java
@@ -0,0 +1,35 @@
+package io.swagger.codegen.Go;
+
+import io.swagger.codegen.AbstractOptionsTest;
+import io.swagger.codegen.CodegenConfig;
+import io.swagger.codegen.languages.GoClientCodegen;
+import io.swagger.codegen.options.GoClientOptionsProvider;
+
+import mockit.Expectations;
+import mockit.Tested;
+
+public class GoClientOptionsTest extends AbstractOptionsTest {
+
+ @Tested
+ private GoClientCodegen clientCodegen;
+
+ public GoClientOptionsTest() {
+ super(new GoClientOptionsProvider());
+ }
+
+ @Override
+ protected CodegenConfig getCodegenConfig() {
+ return clientCodegen;
+ }
+
+ @SuppressWarnings("unused")
+ @Override
+ protected void setExpectations() {
+ new Expectations(clientCodegen) {{
+ clientCodegen.setPackageVersion(GoClientOptionsProvider.PACKAGE_VERSION_VALUE);
+ times = 1;
+ clientCodegen.setPackageName(GoClientOptionsProvider.PACKAGE_NAME_VALUE);
+ times = 1;
+ }};
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoModelTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoModelTest.java
new file mode 100644
index 00000000000..83fa8d6437e
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/go/GoModelTest.java
@@ -0,0 +1,268 @@
+package io.swagger.codegen.Go;
+
+import io.swagger.codegen.CodegenModel;
+import io.swagger.codegen.CodegenProperty;
+import io.swagger.codegen.DefaultCodegen;
+import io.swagger.codegen.languages.GoClientCodegen;
+import io.swagger.models.ArrayModel;
+import io.swagger.models.Model;
+import io.swagger.models.ModelImpl;
+import io.swagger.models.properties.ArrayProperty;
+import io.swagger.models.properties.DateTimeProperty;
+import io.swagger.models.properties.LongProperty;
+import io.swagger.models.properties.MapProperty;
+import io.swagger.models.properties.RefProperty;
+import io.swagger.models.properties.StringProperty;
+
+import com.google.common.collect.Sets;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+@SuppressWarnings("static-method")
+public class GoModelTest {
+
+ @Test(description = "convert a simple Go model")
+ public void simpleModelTest() {
+ final Model model = new ModelImpl()
+ .description("a sample model")
+ .property("id", new LongProperty())
+ .property("name", new StringProperty())
+ .property("createdAt", new DateTimeProperty())
+ .required("id")
+ .required("name");
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 3);
+ Assert.assertEquals(cm.imports.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "id");
+ Assert.assertEquals(property1.datatype, "int64");
+ Assert.assertEquals(property1.name, "Id");
+ Assert.assertEquals(property1.defaultValue, "null");
+ Assert.assertEquals(property1.baseType, "int64");
+ Assert.assertTrue(property1.hasMore);
+ Assert.assertTrue(property1.required);
+ Assert.assertTrue(property1.isPrimitiveType);
+ Assert.assertTrue(property1.isNotContainer);
+
+ final CodegenProperty property2 = cm.vars.get(1);
+ Assert.assertEquals(property2.baseName, "name");
+ Assert.assertEquals(property2.datatype, "string");
+ Assert.assertEquals(property2.name, "Name");
+ Assert.assertEquals(property2.defaultValue, "null");
+ Assert.assertEquals(property2.baseType, "string");
+ Assert.assertTrue(property2.hasMore);
+ Assert.assertTrue(property2.required);
+ Assert.assertTrue(property2.isPrimitiveType);
+ Assert.assertTrue(property2.isNotContainer);
+
+ final CodegenProperty property3 = cm.vars.get(2);
+ Assert.assertEquals(property3.baseName, "createdAt");
+ Assert.assertEquals(property3.complexType, "time.Time");
+ Assert.assertEquals(property3.datatype, "time.Time");
+ Assert.assertEquals(property3.name, "CreatedAt");
+ Assert.assertEquals(property3.defaultValue, "null");
+ Assert.assertEquals(property3.baseType, "time.Time");
+ Assert.assertNull(property3.hasMore);
+ Assert.assertNull(property3.required);
+ Assert.assertTrue(property3.isNotContainer);
+ }
+
+ @Test(description = "convert a model with list property")
+ public void listPropertyTest() {
+ final Model model = new ModelImpl()
+ .description("a sample model")
+ .property("id", new LongProperty())
+ .property("urls", new ArrayProperty()
+ .items(new StringProperty()))
+ .required("id");
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 2);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "id");
+ Assert.assertEquals(property1.datatype, "int64");
+ Assert.assertEquals(property1.name, "Id");
+ Assert.assertEquals(property1.defaultValue, "null");
+ Assert.assertEquals(property1.baseType, "int64");
+ Assert.assertTrue(property1.hasMore);
+ Assert.assertTrue(property1.required);
+ Assert.assertTrue(property1.isPrimitiveType);
+ Assert.assertTrue(property1.isNotContainer);
+
+ final CodegenProperty property2 = cm.vars.get(1);
+ Assert.assertEquals(property2.baseName, "urls");
+ Assert.assertEquals(property2.datatype, "[]string");
+ Assert.assertEquals(property2.name, "Urls");
+ Assert.assertEquals(property2.baseType, "array");
+ Assert.assertNull(property2.hasMore);
+ Assert.assertEquals(property2.containerType, "array");
+ Assert.assertNull(property2.required);
+ Assert.assertTrue(property2.isPrimitiveType);
+ Assert.assertTrue(property2.isContainer);
+ }
+
+ @Test(description = "convert a model with a map property")
+ public void mapPropertyTest() {
+ final Model model = new ModelImpl()
+ .description("a sample model")
+ .property("translations", new MapProperty()
+ .additionalProperties(new StringProperty()))
+ .required("id");
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "translations");
+ Assert.assertEquals(property1.datatype, "map[string]string");
+ Assert.assertEquals(property1.name, "Translations");
+ Assert.assertEquals(property1.baseType, "map");
+ Assert.assertEquals(property1.containerType, "map");
+ Assert.assertNull(property1.required);
+ Assert.assertTrue(property1.isContainer);
+ Assert.assertTrue(property1.isPrimitiveType);
+ }
+
+ @Test(description = "convert a model with complex property")
+ public void complexPropertyTest() {
+ final Model model = new ModelImpl()
+ .description("a sample model")
+ .property("children", new RefProperty("#/definitions/Children"));
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "children");
+ Assert.assertEquals(property1.datatype, "Children");
+ Assert.assertEquals(property1.name, "Children");
+ Assert.assertEquals(property1.baseType, "Children");
+ Assert.assertNull(property1.required);
+ Assert.assertTrue(property1.isNotContainer);
+ }
+
+ @Test(description = "convert a model with complex list property")
+ public void complexListProperty() {
+ final Model model = new ModelImpl()
+ .description("a sample model")
+ .property("children", new ArrayProperty()
+ .items(new RefProperty("#/definitions/Children")));
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "children");
+ Assert.assertEquals(property1.datatype, "[]Children");
+ Assert.assertEquals(property1.name, "Children");
+ Assert.assertEquals(property1.baseType, "array");
+ Assert.assertEquals(property1.containerType, "array");
+ Assert.assertNull(property1.required);
+ Assert.assertTrue(property1.isContainer);
+ }
+
+ @Test(description = "convert a model with complex map property")
+ public void complexMapProperty() {
+ final Model model = new ModelImpl()
+ .description("a sample model")
+ .property("children", new MapProperty()
+ .additionalProperties(new RefProperty("#/definitions/Children")));
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a sample model");
+ Assert.assertEquals(cm.vars.size(), 1);
+ Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
+
+ final CodegenProperty property1 = cm.vars.get(0);
+ Assert.assertEquals(property1.baseName, "children");
+ Assert.assertEquals(property1.complexType, "Children");
+ Assert.assertEquals(property1.datatype, "map[string]Children");
+ Assert.assertEquals(property1.name, "Children");
+ Assert.assertEquals(property1.baseType, "map");
+ Assert.assertEquals(property1.containerType, "map");
+ Assert.assertNull(property1.required);
+ Assert.assertTrue(property1.isContainer);
+ Assert.assertNull(property1.isNotContainer);
+ }
+
+ @Test(description = "convert an array model")
+ public void arrayModelTest() {
+ final Model model = new ArrayModel()
+ .description("an array model")
+ .items(new RefProperty("#/definitions/Children"));
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "an array model");
+ Assert.assertEquals(cm.vars.size(), 0);
+ Assert.assertEquals(cm.imports.size(), 1);
+ }
+
+ @Test(description = "convert an map model")
+ public void mapModelTest() {
+ final Model model = new ModelImpl()
+ .description("a map model")
+ .additionalProperties(new RefProperty("#/definitions/Children"));
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel("sample", model);
+
+ Assert.assertEquals(cm.name, "sample");
+ Assert.assertEquals(cm.classname, "Sample");
+ Assert.assertEquals(cm.description, "a map model");
+ Assert.assertEquals(cm.vars.size(), 0);
+ Assert.assertEquals(cm.imports.size(), 1);
+ Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1);
+ }
+
+ @DataProvider(name = "modelNames")
+ public static Object[][] primeNumbers() {
+ return new Object[][] {
+ {"sample", "Sample"},
+ {"sample_name", "SampleName"},
+ {"sample__name", "SampleName"},
+ {"/sample", "Sample"},
+ {"\\sample", "Sample"},
+ {"sample.name", "SampleName"},
+ {"_sample", "Sample"},
+ };
+ }
+
+ @Test(dataProvider = "modelNames", description = "avoid inner class")
+ public void modelNameTest(String name, String expectedName) {
+ final Model model = new ModelImpl();
+ final DefaultCodegen codegen = new GoClientCodegen();
+ final CodegenModel cm = codegen.fromModel(name, model);
+
+ Assert.assertEquals(cm.name, name);
+ Assert.assertEquals(cm.classname, expectedName);
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/GoClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/GoClientOptionsProvider.java
new file mode 100644
index 00000000000..304d8acf457
--- /dev/null
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/GoClientOptionsProvider.java
@@ -0,0 +1,33 @@
+package io.swagger.codegen.options;
+
+import io.swagger.codegen.CodegenConstants;
+import io.swagger.codegen.languages.GoClientCodegen;
+
+import com.google.common.collect.ImmutableMap;
+
+import java.util.Map;
+
+public class GoClientOptionsProvider implements OptionsProvider {
+
+ public static final String PACKAGE_VERSION_VALUE = "1.0.0";
+ public static final String PACKAGE_NAME_VALUE = "Go";
+
+ @Override
+ public String getLanguage() {
+ return "go";
+ }
+
+ @Override
+ public Map createOptions() {
+ ImmutableMap.Builder builder = new ImmutableMap.Builder();
+ return builder
+ .put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
+ .put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
+ .build();
+ }
+
+ @Override
+ public boolean isServer() {
+ return false;
+ }
+}
diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java
index bf6fd0aba7d..d2b51b06fe4 100644
--- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java
+++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/JavaOptionsProvider.java
@@ -1,11 +1,9 @@
package io.swagger.codegen.options;
-import io.swagger.codegen.Codegen;
+import com.google.common.collect.ImmutableMap;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.JavaClientCodegen;
-import com.google.common.collect.ImmutableMap;
-
import java.util.Map;
public class JavaOptionsProvider implements OptionsProvider {
@@ -46,6 +44,7 @@ public class JavaOptionsProvider implements OptionsProvider {
.put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true")
.put(JavaClientCodegen.USE_RX_JAVA, "false")
.put(JavaClientCodegen.DATE_LIBRARY, "joda")
+ .put("hideGenerationTimestamp", "true")
.build();
}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json.orig b/modules/swagger-codegen/src/test/resources/2_0/petstore-orig.json
similarity index 100%
rename from modules/swagger-codegen/src/test/resources/2_0/petstore.json.orig
rename to modules/swagger-codegen/src/test/resources/2_0/petstore-orig.json
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
new file mode 100644
index 00000000000..bf84cf9c38c
--- /dev/null
+++ b/modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml
@@ -0,0 +1,792 @@
+swagger: '2.0'
+info:
+ description: 'This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose.'
+ 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
+tags:
+ - name: pet
+ description: Everything about your Pets
+ externalDocs:
+ description: Find out more
+ url: 'http://swagger.io'
+ - name: store
+ description: Access to Petstore orders
+ - name: user
+ description: Operations about user
+ externalDocs:
+ description: Find out more about our store
+ url: 'http://swagger.io'
+schemes:
+ - http
+paths:
+ /pet:
+ post:
+ tags:
+ - pet
+ summary: Add a new pet to the store
+ description: ''
+ operationId: addPet
+ consumes:
+ - application/json
+ - application/xml
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ description: Pet object that needs to be added to the store
+ required: true
+ schema:
+ $ref: '#/definitions/Pet'
+ responses:
+ '405':
+ description: Invalid input
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ put:
+ tags:
+ - pet
+ summary: Update an existing pet
+ description: ''
+ operationId: updatePet
+ consumes:
+ - application/json
+ - application/xml
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ description: Pet object that needs to be added to the store
+ required: true
+ schema:
+ $ref: '#/definitions/Pet'
+ responses:
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ '405':
+ description: Validation exception
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ /pet/findByStatus:
+ get:
+ tags:
+ - pet
+ summary: Finds Pets by status
+ description: Multiple status values can be provided with comma separated strings
+ operationId: findPetsByStatus
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: status
+ in: query
+ description: Status values that need to be considered for filter
+ required: true
+ type: array
+ items:
+ type: string
+ enum:
+ - available
+ - pending
+ - sold
+ default: available
+ collectionFormat: csv
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Pet'
+ '400':
+ description: Invalid status value
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ /pet/findByTags:
+ get:
+ tags:
+ - pet
+ summary: Finds Pets by tags
+ description: 'Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.'
+ operationId: findPetsByTags
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: tags
+ in: query
+ description: Tags to filter by
+ required: true
+ type: array
+ items:
+ type: string
+ collectionFormat: csv
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/Pet'
+ '400':
+ description: Invalid tag value
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ '/pet/{petId}':
+ get:
+ tags:
+ - pet
+ summary: Find pet by ID
+ description: Returns a single pet
+ operationId: getPetById
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to return
+ required: true
+ type: integer
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ $ref: '#/definitions/Pet'
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ security:
+ - api_key: []
+ post:
+ tags:
+ - pet
+ summary: Updates a pet in the store with form data
+ description: ''
+ operationId: updatePetWithForm
+ consumes:
+ - application/x-www-form-urlencoded
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet that needs to be updated
+ required: true
+ type: integer
+ format: int64
+ - name: name
+ in: formData
+ description: Updated name of the pet
+ required: false
+ type: string
+ - name: status
+ in: formData
+ description: Updated status of the pet
+ required: false
+ type: string
+ responses:
+ '405':
+ description: Invalid input
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ delete:
+ tags:
+ - pet
+ summary: Deletes a pet
+ description: ''
+ operationId: deletePet
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: api_key
+ in: header
+ required: false
+ type: string
+ - name: petId
+ in: path
+ description: Pet id to delete
+ required: true
+ type: integer
+ format: int64
+ responses:
+ '400':
+ description: Invalid pet value
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ '/pet/{petId}/uploadImage':
+ post:
+ tags:
+ - pet
+ summary: uploads an image
+ description: ''
+ operationId: uploadFile
+ consumes:
+ - multipart/form-data
+ produces:
+ - application/json
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to update
+ required: true
+ type: integer
+ format: int64
+ - name: additionalMetadata
+ in: formData
+ description: Additional data to pass to server
+ required: false
+ type: string
+ - name: file
+ in: formData
+ description: file to upload
+ required: false
+ type: file
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ $ref: '#/definitions/ApiResponse'
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ /store/inventory:
+ get:
+ tags:
+ - store
+ summary: Returns pet inventories by status
+ description: Returns a map of status codes to quantities
+ operationId: getInventory
+ produces:
+ - application/json
+ parameters: []
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ type: object
+ additionalProperties:
+ type: integer
+ format: int32
+ security:
+ - api_key: []
+ /store/order:
+ post:
+ tags:
+ - store
+ summary: Place an order for a pet
+ description: ''
+ operationId: placeOrder
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ description: order placed for purchasing the pet
+ required: true
+ schema:
+ $ref: '#/definitions/Order'
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ $ref: '#/definitions/Order'
+ '400':
+ description: Invalid Order
+ '/store/order/{orderId}':
+ get:
+ tags:
+ - store
+ summary: Find purchase order by ID
+ description: 'For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions'
+ operationId: getOrderById
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: orderId
+ in: path
+ description: ID of pet that needs to be fetched
+ required: true
+ type: integer
+ maximum: 5
+ minimum: 1
+ format: int64
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ $ref: '#/definitions/Order'
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Order not found
+ delete:
+ tags:
+ - store
+ summary: Delete purchase order by ID
+ description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ operationId: deleteOrder
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: orderId
+ in: path
+ description: ID of the order that needs to be deleted
+ required: true
+ type: string
+ minimum: 1
+ responses:
+ '400':
+ description: Invalid ID supplied
+ '404':
+ description: Order not found
+ /user:
+ post:
+ tags:
+ - user
+ summary: Create user
+ description: This can only be done by the logged in user.
+ operationId: createUser
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ description: Created user object
+ required: true
+ schema:
+ $ref: '#/definitions/User'
+ responses:
+ default:
+ description: successful operation
+ /user/createWithArray:
+ post:
+ tags:
+ - user
+ summary: Creates list of users with given input array
+ description: ''
+ operationId: createUsersWithArrayInput
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ description: List of user object
+ required: true
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/User'
+ responses:
+ default:
+ description: successful operation
+ /user/createWithList:
+ post:
+ tags:
+ - user
+ summary: Creates list of users with given input array
+ description: ''
+ operationId: createUsersWithListInput
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - in: body
+ name: body
+ description: List of user object
+ required: true
+ schema:
+ type: array
+ items:
+ $ref: '#/definitions/User'
+ responses:
+ default:
+ description: successful operation
+ /user/login:
+ get:
+ tags:
+ - user
+ summary: Logs user into the system
+ description: ''
+ operationId: loginUser
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: username
+ in: query
+ description: The user name for login
+ required: true
+ type: string
+ - name: password
+ in: query
+ description: The password for login in clear text
+ required: true
+ type: string
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ type: string
+ headers:
+ X-Rate-Limit:
+ type: integer
+ format: int32
+ description: calls per hour allowed by the user
+ X-Expires-After:
+ type: string
+ format: date-time
+ description: date in UTC when toekn expires
+ '400':
+ description: Invalid username/password supplied
+ /user/logout:
+ get:
+ tags:
+ - user
+ summary: Logs out current logged in user session
+ description: ''
+ operationId: logoutUser
+ produces:
+ - application/xml
+ - application/json
+ parameters: []
+ responses:
+ default:
+ description: successful operation
+ '/user/{username}':
+ get:
+ tags:
+ - user
+ summary: Get user by user name
+ description: ''
+ operationId: getUserByName
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: username
+ in: path
+ description: 'The name that needs to be fetched. Use user1 for testing. '
+ required: true
+ type: string
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ $ref: '#/definitions/User'
+ '400':
+ description: Invalid username supplied
+ '404':
+ description: User not found
+ put:
+ tags:
+ - user
+ summary: Updated user
+ description: This can only be done by the logged in user.
+ operationId: updateUser
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: username
+ in: path
+ description: name that need to be deleted
+ required: true
+ type: string
+ - in: body
+ name: body
+ description: Updated user object
+ required: true
+ schema:
+ $ref: '#/definitions/User'
+ responses:
+ '400':
+ description: Invalid user supplied
+ '404':
+ description: User not found
+ delete:
+ tags:
+ - user
+ summary: Delete user
+ description: This can only be done by the logged in user.
+ operationId: deleteUser
+ produces:
+ - application/xml
+ - application/json
+ parameters:
+ - name: username
+ in: path
+ description: The name that needs to be deleted
+ required: true
+ type: string
+ responses:
+ '400':
+ description: Invalid username supplied
+ '404':
+ description: User not found
+securityDefinitions:
+ 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
+ api_key:
+ type: apiKey
+ name: api_key
+ in: header
+definitions:
+ Order:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ petId:
+ type: integer
+ format: int64
+ quantity:
+ type: integer
+ format: int32
+ shipDate:
+ type: string
+ format: date-time
+ status:
+ type: string
+ description: Order Status
+ enum:
+ - placed
+ - approved
+ - delivered
+ complete:
+ type: boolean
+ default: false
+ xml:
+ name: Order
+ Category:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: Category
+ User:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ username:
+ type: string
+ firstName:
+ type: string
+ lastName:
+ type: string
+ email:
+ type: string
+ password:
+ type: string
+ phone:
+ type: string
+ userStatus:
+ type: integer
+ format: int32
+ description: User Status
+ xml:
+ name: User
+ Tag:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: Tag
+ Pet:
+ type: object
+ required:
+ - name
+ - photoUrls
+ properties:
+ id:
+ type: integer
+ format: int64
+ category:
+ $ref: '#/definitions/Category'
+ name:
+ type: string
+ example: doggie
+ photoUrls:
+ type: array
+ xml:
+ name: photoUrl
+ wrapped: true
+ items:
+ type: string
+ tags:
+ type: array
+ xml:
+ name: tag
+ wrapped: true
+ items:
+ $ref: '#/definitions/Tag'
+ status:
+ type: string
+ description: pet status in the store
+ enum:
+ - available
+ - pending
+ - sold
+ xml:
+ name: Pet
+ ApiResponse:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ type:
+ type: string
+ message:
+ type: string
+ '$special[model.name]':
+ properties:
+ '$special[property.name]':
+ type: integer
+ format: int64
+ xml:
+ name: '$special[model.name]'
+ Return:
+ description: Model for testing reserved words
+ properties:
+ return:
+ type: integer
+ format: int32
+ xml:
+ name: Return
+ Name:
+ description: Model for testing model name same as property name
+ required:
+ - name
+ properties:
+ name:
+ type: integer
+ format: int32
+ snake_case:
+ readOnly: true
+ type: integer
+ format: int32
+ xml:
+ name: Name
+ 200_response:
+ description: Model for testing model name starting with number
+ properties:
+ name:
+ type: integer
+ format: int32
+ xml:
+ name: Name
+ Dog:
+ allOf:
+ - $ref: '#/definitions/Animal'
+ - type: object
+ properties:
+ breed:
+ type: string
+ Cat:
+ allOf:
+ - $ref: '#/definitions/Animal'
+ - type: object
+ properties:
+ declawed:
+ type: boolean
+ Animal:
+ type: object
+ discriminator: className
+ required:
+ - className
+ properties:
+ className:
+ type: string
+ format_test:
+ type: object
+ required:
+ - number
+ properties:
+ integer:
+ type: integer
+ int32:
+ type: integer
+ format: int32
+ int64:
+ type: integer
+ format: int64
+ number:
+ type: number
+ float:
+ type: number
+ format: float
+ double:
+ type: number
+ format: double
+ string:
+ type: string
+ byte:
+ type: string
+ format: byte
+ binary:
+ type: string
+ format: binary
+ date:
+ type: string
+ format: date
+ dateTime:
+ type: string
+ format: date-time
+ password:
+ type: string
+ format: password
+externalDocs:
+ description: Find out more about Swagger
+ url: 'http://swagger.io'
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore.json b/modules/swagger-codegen/src/test/resources/2_0/petstore.json
index f248a42a49d..838b3c8b2da 100644
--- a/modules/swagger-codegen/src/test/resources/2_0/petstore.json
+++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.json
@@ -4,9 +4,9 @@
"description": "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters",
"version": "1.0.0",
"title": "Swagger Petstore",
- "termsOfService": "http://swagger.io/terms/",
+ "termsOfService": "http://helloreverb.com/terms/",
"contact": {
- "email": "apiteam@swagger.io"
+ "email": "apiteam@wordnik.com"
},
"license": {
"name": "Apache 2.0",
@@ -19,49 +19,6 @@
"http"
],
"paths": {
- "/pet?testing_byte_array=true": {
- "post": {
- "tags": [
- "pet"
- ],
- "summary": "Fake endpoint to test byte array in body parameter for adding a new pet to the store",
- "description": "",
- "operationId": "addPetUsingByteArray",
- "consumes": [
- "application/json",
- "application/xml"
- ],
- "produces": [
- "application/json",
- "application/xml"
- ],
- "parameters": [
- {
- "in": "body",
- "name": "body",
- "description": "Pet object in the form of byte array",
- "required": false,
- "schema": {
- "type": "string",
- "format": "binary"
- }
- }
- ],
- "responses": {
- "405": {
- "description": "Invalid input"
- }
- },
- "security": [
- {
- "petstore_auth": [
- "write:pets",
- "read:pets"
- ]
- }
- ]
- }
- },
"/pet": {
"post": {
"tags": [
@@ -156,7 +113,7 @@
"pet"
],
"summary": "Finds Pets by status",
- "description": "Multiple status values can be provided with comma separated strings",
+ "description": "Multiple status values can be provided with comma seperated strings",
"operationId": "findPetsByStatus",
"produces": [
"application/json",
@@ -166,23 +123,14 @@
{
"name": "status",
"in": "query",
- "description": "Status values that need to be considered for query",
+ "description": "Status values that need to be considered for filter",
"required": false,
"type": "array",
"items": {
"type": "string",
- "enum": [
- "available",
- "pending",
- "sold"
- ]
+ "enum": ["available", "pending", "sold"]
},
"collectionFormat": "multi",
- "enum": [
- "available",
- "pending",
- "sold"
- ],
"default": "available"
}
],
@@ -194,6 +142,15 @@
"items": {
"$ref": "#/definitions/Pet"
}
+ },
+ "examples": {
+ "application/json": {
+ "name": "Puma",
+ "type": "Dog",
+ "color": "Black",
+ "gender": "Female",
+ "breed": "Mixed"
+ }
}
},
"400": {
@@ -259,150 +216,6 @@
]
}
},
- "/pet/{petId}?testing_byte_array=true": {
- "get": {
- "tags": [
- "pet"
- ],
- "summary": "Fake endpoint to test byte array return by 'Find pet by ID'",
- "description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
- "operationId": "",
- "produces": [
- "application/json",
- "application/xml"
- ],
- "parameters": [
- {
- "name": "petId",
- "in": "path",
- "description": "ID of pet that needs to be fetched",
- "required": true,
- "type": "integer",
- "format": "int64"
- }
- ],
- "responses": {
- "404": {
- "description": "Pet not found"
- },
- "200": {
- "description": "successful operation",
- "schema": {
- "type": "string",
- "format": "binary"
- }
- },
- "400": {
- "description": "Invalid ID supplied"
- }
- },
- "security": [
- {
- "api_key": []
- },
- {
- "petstore_auth": [
- "write:pets",
- "read:pets"
- ]
- }
- ]
- }
- },
- "/pet/{petId}?response=inline_arbitrary_object": {
- "get": {
- "tags": [
- "pet"
- ],
- "summary": "Fake endpoint to test inline arbitrary object return by 'Find pet by ID'",
- "description": "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
- "operationId": "getPetByIdInObject",
- "produces": [
- "application/json",
- "application/xml"
- ],
- "parameters": [
- {
- "name": "petId",
- "in": "path",
- "description": "ID of pet that needs to be fetched",
- "required": true,
- "type": "integer",
- "format": "int64"
- }
- ],
- "responses": {
- "404": {
- "description": "Pet not found"
- },
- "200": {
- "description": "successful operation",
- "schema": {
- "type": "object",
- "required": [
- "id"
- ],
- "properties": {
- "id": {
- "type": "integer",
- "format": "int64"
- },
- "category": {
- "type": "object"
- },
- "name": {
- "type": "string",
- "example": "doggie"
- },
- "photoUrls": {
- "type": "array",
- "xml": {
- "name": "photoUrl",
- "wrapped": true
- },
- "items": {
- "type": "string"
- }
- },
- "tags": {
- "type": "array",
- "xml": {
- "name": "tag",
- "wrapped": true
- },
- "items": {
- "$ref": "#/definitions/Tag"
- }
- },
- "status": {
- "type": "string",
- "description": "pet status in the store",
- "enum": [
- "available",
- "pending",
- "sold"
- ]
- }
- }
- }
- },
- "400": {
- "description": "Invalid ID supplied"
- }
- },
- "security": [
- {
- "api_key": []
- },
- {
- "petstore_auth": [
- "write:pets",
- "read:pets"
- ]
- }
- ]
- }
- },
"/pet/{petId}": {
"get": {
"tags": [
@@ -630,33 +443,6 @@
]
}
},
- "/store/inventory?response=arbitrary_object": {
- "get": {
- "tags": [
- "store"
- ],
- "summary": "Fake endpoint to test arbitrary object return by 'Get inventory'",
- "description": "Returns an arbitrary object which is actually a map of status codes to quantities",
- "operationId": "getInventoryInObject",
- "produces": [
- "application/json",
- "application/xml"
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "type": "object"
- }
- }
- },
- "security": [
- {
- "api_key": []
- }
- ]
- }
- },
"/store/order": {
"post": {
"tags": [
@@ -690,62 +476,7 @@
"400": {
"description": "Invalid Order"
}
- },
- "security": [
- {
- "test_api_client_id": [],
- "test_api_client_secret": []
- }
- ]
- }
- },
- "/store/findByStatus": {
- "get": {
- "tags": [
- "store"
- ],
- "summary": "Finds orders by status",
- "description": "A single status value can be provided as a string",
- "operationId": "findOrdersByStatus",
- "produces": [
- "application/json",
- "application/xml"
- ],
- "parameters": [
- {
- "name": "status",
- "in": "query",
- "description": "Status value that needs to be considered for query",
- "required": false,
- "type": "string",
- "enum": [
- "placed",
- "approved",
- "delivered"
- ],
- "default": "placed"
- }
- ],
- "responses": {
- "200": {
- "description": "successful operation",
- "schema": {
- "type": "array",
- "items": {
- "$ref": "#/definitions/Order"
- }
- }
- },
- "400": {
- "description": "Invalid status value"
- }
- },
- "security": [
- {
- "test_api_client_id": [],
- "test_api_client_secret": []
- }
- ]
+ }
}
},
"/store/order/{orderId}": {
@@ -782,15 +513,7 @@
"400": {
"description": "Invalid ID supplied"
}
- },
- "security": [
- {
- "test_api_key_header": []
- },
- {
- "test_api_key_query": []
- }
- ]
+ }
},
"delete": {
"tags": [
@@ -1007,18 +730,6 @@
"description": "successful operation",
"schema": {
"$ref": "#/definitions/User"
- },
- "examples": {
- "application/json": {
- "id": 1,
- "username": "johnp",
- "firstName": "John",
- "lastName": "Public",
- "email": "johnp@swagger.io",
- "password": "-secret-",
- "phone": "0123456789",
- "userStatus": 0
- }
}
},
"400": {
@@ -1091,12 +802,7 @@
"400": {
"description": "Invalid username supplied"
}
- },
- "security": [
- {
- "test_http_basic": []
- }
- ]
+ }
}
}
},
@@ -1114,29 +820,6 @@
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
- },
- "test_api_client_id": {
- "type": "apiKey",
- "name": "x-test_api_client_id",
- "in": "header"
- },
- "test_api_client_secret": {
- "type": "apiKey",
- "name": "x-test_api_client_secret",
- "in": "header"
- },
- "test_api_key_header": {
- "type": "apiKey",
- "name": "test_api_key_header",
- "in": "header"
- },
- "test_api_key_query": {
- "type": "apiKey",
- "name": "test_api_key_query",
- "in": "query"
- },
- "test_http_basic": {
- "type": "basic"
}
},
"definitions": {
@@ -1257,8 +940,7 @@
"properties": {
"id": {
"type": "integer",
- "format": "int64",
- "readOnly": true
+ "format": "int64"
},
"petId": {
"type": "integer",
@@ -1288,93 +970,6 @@
"xml": {
"name": "Order"
}
- },
- "$special[model.name]": {
- "properties": {
- "$special[property.name]": {
- "type": "integer",
- "format": "int64"
- }
- },
- "xml": {
- "name": "$special[model.name]"
- }
- },
- "Return": {
- "descripton": "Model for testing reserved words",
- "properties": {
- "return": {
- "type": "integer",
- "format": "int32"
- }
- },
- "xml": {
- "name": "Return"
- }
- },
- "Name": {
- "descripton": "Model for testing model name same as property name",
- "properties": {
- "name": {
- "type": "integer",
- "format": "int32"
- },
- "snake_case": {
- "type": "integer",
- "format": "int32"
- }
- },
- "xml": {
- "name": "Name"
- }
- },
- "200_response": {
- "descripton": "Model for testing model name starting with number",
- "properties": {
- "name": {
- "type": "integer",
- "format": "int32"
- }
- },
- "xml": {
- "name": "Name"
- }
- },
- "Dog" : {
- "allOf" : [ {
- "$ref" : "#/definitions/Animal"
- }, {
- "type" : "object",
- "properties" : {
- "breed" : {
- "type" : "string"
- }
- }
- } ]
- },
- "Cat" : {
- "allOf" : [ {
- "$ref" : "#/definitions/Animal"
- }, {
- "type" : "object",
- "properties" : {
- "declawed" : {
- "type" : "boolean"
- }
- }
- } ]
- },
- "Animal" : {
- "type" : "object",
- "discriminator": "className",
- "required": [
- "className"
- ],
- "properties" : {
- "className" : {
- "type" : "string"
- }
- }
}
}
}
diff --git a/modules/swagger-codegen/src/test/resources/2_0/petstore_full.yml b/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml
similarity index 60%
rename from modules/swagger-codegen/src/test/resources/2_0/petstore_full.yml
rename to modules/swagger-codegen/src/test/resources/2_0/petstore.yaml
index cbfae8e4c45..73493835106 100644
--- a/modules/swagger-codegen/src/test/resources/2_0/petstore_full.yml
+++ b/modules/swagger-codegen/src/test/resources/2_0/petstore.yaml
@@ -1,287 +1,357 @@
-swagger: "2.0"
+swagger: '2.0'
info:
- description: |
- This is a sample server Petstore server.
-
- [Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.
-
- For this sample, you can use the api key `special-key` to test the authorization filters
- version: "1.0.0"
+ description: 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.'
+ version: 1.0.0
title: Swagger Petstore
- termsOfService: http://helloreverb.com/terms/
+ termsOfService: 'http://swagger.io/terms/'
contact:
- name: apiteam@swagger.io
+ email: apiteam@swagger.io
license:
name: Apache 2.0
- url: http://www.apache.org/licenses/LICENSE-2.0.html
+ url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
host: petstore.swagger.io
basePath: /v2
+tags:
+ - name: pet
+ description: Everything about your Pets
+ externalDocs:
+ description: Find out more
+ url: 'http://swagger.io'
+ - name: store
+ description: Access to Petstore orders
+ - name: user
+ description: Operations about user
+ externalDocs:
+ description: Find out more about our store
+ url: 'http://swagger.io'
schemes:
- http
paths:
- /pets:
+ /pet:
post:
tags:
- pet
summary: Add a new pet to the store
- description: ""
+ description: ''
operationId: addPet
consumes:
- application/json
- application/xml
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- in: body
name: body
description: Pet object that needs to be added to the store
- required: false
+ required: true
schema:
- $ref: "#/definitions/Pet"
+ $ref: '#/definitions/Pet'
responses:
- "405":
+ '405':
description: Invalid input
security:
- petstore_auth:
- - write_pets
- - read_pets
+ - 'write:pets'
+ - 'read:pets'
put:
tags:
- pet
summary: Update an existing pet
- description: ""
+ description: ''
operationId: updatePet
consumes:
- application/json
- application/xml
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- in: body
name: body
description: Pet object that needs to be added to the store
- required: false
+ required: true
schema:
- $ref: "#/definitions/Pet"
+ $ref: '#/definitions/Pet'
responses:
- "405":
- description: Validation exception
- "404":
- description: Pet not found
- "400":
+ '400':
description: Invalid ID supplied
+ '404':
+ description: Pet not found
+ '405':
+ description: Validation exception
security:
- petstore_auth:
- - write_pets
- - read_pets
- /pets/findByStatus:
+ - 'write:pets'
+ - 'read:pets'
+ /pet/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
- description: Multiple status values can be provided with comma seperated strings
+ description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: query
- name: status
+ - name: status
+ in: query
description: Status values that need to be considered for filter
- required: false
+ required: true
type: array
items:
type: string
- collectionFormat: multi
+ enum:
+ - available
+ - pending
+ - sold
+ default: available
+ collectionFormat: csv
responses:
- "200":
+ '200':
description: successful operation
schema:
type: array
items:
- $ref: "#/definitions/Pet"
- "400":
+ $ref: '#/definitions/Pet'
+ '400':
description: Invalid status value
security:
- petstore_auth:
- - write_pets
- - read_pets
- /pets/findByTags:
+ - 'write:pets'
+ - 'read:pets'
+ /pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
- description: Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
+ description: 'Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.'
operationId: findPetsByTags
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: query
- name: tags
+ - name: tags
+ in: query
description: Tags to filter by
- required: false
+ required: true
type: array
items:
type: string
- collectionFormat: multi
+ collectionFormat: csv
responses:
- "200":
+ '200':
description: successful operation
schema:
type: array
items:
- $ref: "#/definitions/Pet"
- "400":
+ $ref: '#/definitions/Pet'
+ '400':
description: Invalid tag value
security:
- petstore_auth:
- - write_pets
- - read_pets
- /pets/{petId}:
+ - 'write:pets'
+ - 'read:pets'
+ '/pet/{petId}':
get:
tags:
- pet
summary: Find pet by ID
- description: Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
+ description: Returns a single pet
operationId: getPetById
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: petId
- description: ID of pet that needs to be fetched
+ - name: petId
+ in: path
+ description: ID of pet to return
required: true
type: integer
format: int64
responses:
- "404":
- description: Pet not found
- "200":
+ '200':
description: successful operation
schema:
- $ref: "#/definitions/Pet"
- "400":
+ $ref: '#/definitions/Pet'
+ '400':
description: Invalid ID supplied
+ '404':
+ description: Pet not found
security:
- api_key: []
- - petstore_auth:
- - write_pets
- - read_pets
post:
tags:
- pet
summary: Updates a pet in the store with form data
- description: ""
+ description: ''
operationId: updatePetWithForm
consumes:
- application/x-www-form-urlencoded
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: petId
+ - name: petId
+ in: path
description: ID of pet that needs to be updated
required: true
- type: string
- - in: formData
- name: name
+ type: integer
+ format: int64
+ - name: name
+ in: formData
description: Updated name of the pet
- required: true
+ required: false
type: string
- - in: formData
- name: status
+ - name: status
+ in: formData
description: Updated status of the pet
- required: true
+ required: false
type: string
responses:
- "405":
+ '405':
description: Invalid input
security:
- petstore_auth:
- - write_pets
- - read_pets
+ - 'write:pets'
+ - 'read:pets'
delete:
tags:
- pet
summary: Deletes a pet
- description: ""
+ description: ''
operationId: deletePet
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: header
- name: api_key
- description: ""
- required: true
+ - name: api_key
+ in: header
+ required: false
type: string
- - in: path
- name: petId
+ - name: petId
+ in: path
description: Pet id to delete
required: true
type: integer
format: int64
responses:
- "400":
+ '400':
description: Invalid pet value
security:
- petstore_auth:
- - write_pets
- - read_pets
- /stores/order:
+ - 'write:pets'
+ - 'read:pets'
+ '/pet/{petId}/uploadImage':
+ post:
+ tags:
+ - pet
+ summary: uploads an image
+ description: ''
+ operationId: uploadFile
+ consumes:
+ - multipart/form-data
+ produces:
+ - application/json
+ parameters:
+ - name: petId
+ in: path
+ description: ID of pet to update
+ required: true
+ type: integer
+ format: int64
+ - name: additionalMetadata
+ in: formData
+ description: Additional data to pass to server
+ required: false
+ type: string
+ - name: file
+ in: formData
+ description: file to upload
+ required: false
+ type: file
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ $ref: '#/definitions/ApiResponse'
+ security:
+ - petstore_auth:
+ - 'write:pets'
+ - 'read:pets'
+ /store/inventory:
+ get:
+ tags:
+ - store
+ summary: Returns pet inventories by status
+ description: Returns a map of status codes to quantities
+ operationId: getInventory
+ produces:
+ - application/json
+ parameters: []
+ responses:
+ '200':
+ description: successful operation
+ schema:
+ type: object
+ additionalProperties:
+ type: integer
+ format: int32
+ security:
+ - api_key: []
+ /store/order:
post:
tags:
- store
summary: Place an order for a pet
- description: ""
+ description: ''
operationId: placeOrder
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- in: body
name: body
description: order placed for purchasing the pet
- required: false
+ required: true
schema:
- $ref: "#/definitions/Order"
+ $ref: '#/definitions/Order'
responses:
- "200":
+ '200':
description: successful operation
schema:
- $ref: "#/definitions/Order"
- "400":
+ $ref: '#/definitions/Order'
+ '400':
description: Invalid Order
- /stores/order/{orderId}:
+ '/store/order/{orderId}':
get:
tags:
- store
summary: Find purchase order by ID
- description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ description: 'For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions'
operationId: getOrderById
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: orderId
+ - name: orderId
+ in: path
description: ID of pet that needs to be fetched
required: true
- type: string
+ type: integer
+ maximum: 5
+ minimum: 1
+ format: int64
responses:
- "404":
- description: Order not found
- "200":
+ '200':
description: successful operation
schema:
- $ref: "#/definitions/Order"
- "400":
+ $ref: '#/definitions/Order'
+ '400':
description: Invalid ID supplied
+ '404':
+ description: Order not found
delete:
tags:
- store
@@ -289,20 +359,21 @@ paths:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
operationId: deleteOrder
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: orderId
+ - name: orderId
+ in: path
description: ID of the order that needs to be deleted
required: true
type: string
+ minimum: 1
responses:
- "404":
- description: Order not found
- "400":
+ '400':
description: Invalid ID supplied
- /users:
+ '404':
+ description: Order not found
+ /user:
post:
tags:
- user
@@ -310,128 +381,138 @@ paths:
description: This can only be done by the logged in user.
operationId: createUser
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- in: body
name: body
description: Created user object
- required: false
+ required: true
schema:
- $ref: "#/definitions/User"
+ $ref: '#/definitions/User'
responses:
default:
description: successful operation
- /users/createWithArray:
+ /user/createWithArray:
post:
tags:
- user
summary: Creates list of users with given input array
- description: ""
+ description: ''
operationId: createUsersWithArrayInput
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- in: body
name: body
description: List of user object
- required: false
+ required: true
schema:
type: array
items:
- $ref: "#/definitions/User"
+ $ref: '#/definitions/User'
responses:
default:
description: successful operation
- /users/createWithList:
+ /user/createWithList:
post:
tags:
- user
summary: Creates list of users with given input array
- description: ""
+ description: ''
operationId: createUsersWithListInput
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- in: body
name: body
description: List of user object
- required: false
+ required: true
schema:
type: array
items:
- $ref: "#/definitions/User"
+ $ref: '#/definitions/User'
responses:
default:
description: successful operation
- /users/login:
+ /user/login:
get:
tags:
- user
summary: Logs user into the system
- description: ""
+ description: ''
operationId: loginUser
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: query
- name: username
+ - name: username
+ in: query
description: The user name for login
- required: false
+ required: true
type: string
- - in: query
- name: password
+ - name: password
+ in: query
description: The password for login in clear text
- required: false
+ required: true
type: string
responses:
- "200":
+ '200':
description: successful operation
schema:
type: string
- "400":
+ headers:
+ X-Rate-Limit:
+ type: integer
+ format: int32
+ description: calls per hour allowed by the user
+ X-Expires-After:
+ type: string
+ format: date-time
+ description: date in UTC when toekn expires
+ '400':
description: Invalid username/password supplied
- /users/logout:
+ /user/logout:
get:
tags:
- user
summary: Logs out current logged in user session
- description: ""
+ description: ''
operationId: logoutUser
produces:
- - application/json
- application/xml
+ - application/json
+ parameters: []
responses:
default:
description: successful operation
- /users/{username}:
+ '/user/{username}':
get:
tags:
- user
summary: Get user by user name
- description: ""
+ description: ''
operationId: getUserByName
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: username
- description: The name that needs to be fetched. Use user1 for testing.
+ - name: username
+ in: path
+ description: 'The name that needs to be fetched. Use user1 for testing. '
required: true
type: string
responses:
- "404":
- description: User not found
- "200":
+ '200':
description: successful operation
schema:
- $ref: "#/definitions/User"
- "400":
+ $ref: '#/definitions/User'
+ '400':
description: Invalid username supplied
+ '404':
+ description: User not found
put:
tags:
- user
@@ -439,25 +520,25 @@ paths:
description: This can only be done by the logged in user.
operationId: updateUser
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: username
+ - name: username
+ in: path
description: name that need to be deleted
required: true
type: string
- in: body
name: body
description: Updated user object
- required: false
+ required: true
schema:
- $ref: "#/definitions/User"
+ $ref: '#/definitions/User'
responses:
- "404":
- description: User not found
- "400":
+ '400':
description: Invalid user supplied
+ '404':
+ description: User not found
delete:
tags:
- user
@@ -465,32 +546,69 @@ paths:
description: This can only be done by the logged in user.
operationId: deleteUser
produces:
- - application/json
- application/xml
+ - application/json
parameters:
- - in: path
- name: username
+ - name: username
+ in: path
description: The name that needs to be deleted
required: true
type: string
responses:
- "404":
- description: User not found
- "400":
+ '400':
description: Invalid username supplied
+ '404':
+ description: User not found
securityDefinitions:
+ 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
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:
+ Order:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ petId:
+ type: integer
+ format: int64
+ quantity:
+ type: integer
+ format: int32
+ shipDate:
+ type: string
+ format: date-time
+ status:
+ type: string
+ description: Order Status
+ enum:
+ - placed
+ - approved
+ - delivered
+ complete:
+ type: boolean
+ default: false
+ xml:
+ name: Order
+ Category:
+ type: object
+ properties:
+ id:
+ type: integer
+ format: int64
+ name:
+ type: string
+ xml:
+ name: Category
User:
type: object
properties:
@@ -513,7 +631,9 @@ definitions:
type: integer
format: int32
description: User Status
- Category:
+ xml:
+ name: User
+ Tag:
type: object
properties:
id:
@@ -521,6 +641,8 @@ definitions:
format: int64
name:
type: string
+ xml:
+ name: Tag
Pet:
type: object
required:
@@ -531,46 +653,43 @@ definitions:
type: integer
format: int64
category:
- $ref: "#/definitions/Category"
+ $ref: '#/definitions/Category'
name:
type: string
example: doggie
photoUrls:
type: array
+ xml:
+ name: photoUrl
+ wrapped: true
items:
type: string
tags:
type: array
+ xml:
+ name: tag
+ wrapped: true
items:
- $ref: "#/definitions/Tag"
+ $ref: '#/definitions/Tag'
status:
type: string
description: pet status in the store
- Tag:
+ enum:
+ - available
+ - pending
+ - sold
+ xml:
+ name: Pet
+ ApiResponse:
type: object
properties:
- id:
- type: integer
- format: int64
- name:
- type: string
- Order:
- type: object
- properties:
- id:
- type: integer
- format: int64
- petId:
- type: integer
- format: int64
- quantity:
+ code:
type: integer
format: int32
- shipDate:
+ type:
type: string
- format: date-time
- status:
+ message:
type: string
- description: Order Status
- complete:
- type: boolean
\ No newline at end of file
+externalDocs:
+ description: Find out more about Swagger
+ url: 'http://swagger.io'
diff --git a/modules/swagger-generator/pom.xml b/modules/swagger-generator/pom.xml
index 6210ed77f37..2d2b45d7892 100644
--- a/modules/swagger-generator/pom.xml
+++ b/modules/swagger-generator/pom.xml
@@ -4,7 +4,7 @@
io.swagger
swagger-codegen-project
- 2.1.6-SNAPSHOT
+ 2.1.6
../..
swagger-generator
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/model/GeneratorInput.java b/modules/swagger-generator/src/main/java/io/swagger/generator/model/GeneratorInput.java
index 5175ac3b60a..fabde1e3104 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/model/GeneratorInput.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/model/GeneratorInput.java
@@ -2,6 +2,7 @@ package io.swagger.generator.model;
import com.fasterxml.jackson.databind.JsonNode;
import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.AuthorizationValue;
import io.swagger.models.auth.SecuritySchemeDefinition;
import java.util.Map;
@@ -11,6 +12,15 @@ public class GeneratorInput {
private Map options;
private String swaggerUrl;
private SecuritySchemeDefinition auth;
+ private AuthorizationValue authorizationValue;
+
+ public AuthorizationValue getAuthorizationValue() {
+ return authorizationValue;
+ }
+
+ public void setAuthorizationValue(AuthorizationValue authorizationValue) {
+ this.authorizationValue = authorizationValue;
+ }
@ApiModelProperty(dataType = "Object")
public JsonNode getSpec() {
@@ -38,10 +48,12 @@ public class GeneratorInput {
this.swaggerUrl = url;
}
+ @Deprecated
public SecuritySchemeDefinition getSecurityDefinition() {
return auth;
}
+ @Deprecated
public void setSecurityDefinition(SecuritySchemeDefinition auth) {
this.auth = auth;
}
diff --git a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
index 0ecd2756fbe..fecd5706361 100644
--- a/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
+++ b/modules/swagger-generator/src/main/java/io/swagger/generator/online/Generator.java
@@ -1,22 +1,16 @@
package io.swagger.generator.online;
import com.fasterxml.jackson.databind.JsonNode;
-
-import io.swagger.codegen.CliOption;
-import io.swagger.codegen.ClientOptInput;
-import io.swagger.codegen.ClientOpts;
-import io.swagger.codegen.Codegen;
-import io.swagger.codegen.CodegenConfig;
-import io.swagger.codegen.CodegenConfigLoader;
+import io.swagger.codegen.*;
import io.swagger.generator.exception.ApiException;
import io.swagger.generator.exception.BadRequestException;
import io.swagger.generator.model.GeneratorInput;
import io.swagger.generator.model.InputOption;
import io.swagger.generator.util.ZipUtil;
import io.swagger.models.Swagger;
+import io.swagger.models.auth.AuthorizationValue;
import io.swagger.parser.SwaggerParser;
import io.swagger.util.Json;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -79,11 +73,24 @@ public class Generator {
Swagger swagger;
if (node == null) {
if (opts.getSwaggerUrl() != null) {
- swagger = new SwaggerParser().read(opts.getSwaggerUrl());
+ if(opts.getAuthorizationValue() != null) {
+ List authorizationValues = new ArrayList();
+ authorizationValues.add(opts.getAuthorizationValue());
+
+ swagger = new SwaggerParser().read(opts.getSwaggerUrl(), authorizationValues, true);
+ }
+ else {
+ swagger = new SwaggerParser().read(opts.getSwaggerUrl());
+ }
} else {
throw new BadRequestException("No swagger specification was supplied");
}
- } else {
+ } else if(opts.getAuthorizationValue() != null) {
+ List authorizationValues = new ArrayList();
+ authorizationValues.add(opts.getAuthorizationValue());
+ swagger = new SwaggerParser().read(node, authorizationValues, true);
+ }
+ else {
swagger = new SwaggerParser().read(node, true);
}
if (swagger == null) {
diff --git a/pom.xml b/pom.xml
index c308b2dfacb..9ac1890ea91 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
swagger-codegen-project
pom
swagger-codegen-project
- 2.1.6-SNAPSHOT
+ 2.1.6
https://github.com/swagger-api/swagger-codegen
scm:git:git@github.com:swagger-api/swagger-codegen.git
@@ -559,7 +559,7 @@
- 1.0.18
+ 1.0.19
2.11.1
2.3.4
1.5.8
@@ -570,7 +570,7 @@
2.4
1.7.12
3.2.1
- 1.9
+ 1.12
6.9.6
2.18.1
1.19
diff --git a/samples/client/petstore/akka-scala/pom.xml b/samples/client/petstore/akka-scala/pom.xml
index fa88207507e..b625621f58c 100644
--- a/samples/client/petstore/akka-scala/pom.xml
+++ b/samples/client/petstore/akka-scala/pom.xml
@@ -217,7 +217,7 @@
2.3.9
1.2
2.2
- 1.5.7
+ 1.5.8
1.0.0
4.8.1
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala
index c8c0d2454e4..6703ffa4837 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/EnumsSerializers.scala
@@ -1,3 +1,8 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.api
import io.swagger.client.model._
@@ -7,8 +12,8 @@ import scala.reflect.ClassTag
object EnumsSerializers {
def all = Seq[Serializer[_]]() :+
- new EnumNameSerializer(PetEnums.Status) :+
- new EnumNameSerializer(OrderEnums.Status)
+ new EnumNameSerializer(OrderEnums.Status) :+
+ new EnumNameSerializer(PetEnums.Status)
@@ -40,4 +45,4 @@ object EnumsSerializers {
}
}
-}
\ No newline at end of file
+}
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala
index 7decd51b03c..b59e7f912b4 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/PetApi.scala
@@ -1,6 +1,12 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.api
import io.swagger.client.model.Pet
+import io.swagger.client.model.ApiResponse
import java.io.File
import io.swagger.client.core._
import io.swagger.client.core.CollectionFormats._
@@ -8,22 +14,6 @@ import io.swagger.client.core.ApiKeyLocations._
object PetApi {
- /**
- *
- * Expected answers:
- * code 400 : (Invalid ID supplied)
- * code 404 : (Pet not found)
- * code 405 : (Validation exception)
- *
- * @param body Pet object that needs to be added to the store
- */
- def updatePet(body: Option[Pet] = None): ApiRequest[Unit] =
- ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json")
- .withBody(body)
- .withErrorResponse[Unit](400)
- .withErrorResponse[Unit](404)
- .withErrorResponse[Unit](405)
-
/**
*
* Expected answers:
@@ -31,79 +21,11 @@ object PetApi {
*
* @param body Pet object that needs to be added to the store
*/
- def addPet(body: Option[Pet] = None): ApiRequest[Unit] =
+ def addPet(body: Pet): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet", "application/json")
.withBody(body)
.withErrorResponse[Unit](405)
-
- /**
- * Multiple status values can be provided with comma seperated strings
- *
- * Expected answers:
- * code 200 : Seq[Pet] (successful operation)
- * code 400 : (Invalid status value)
- *
- * @param status Status values that need to be considered for filter
- */
- def findPetsByStatus(status: Seq[String]): ApiRequest[Seq[Pet]] =
- ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByStatus", "application/json")
- .withQueryParam("status", ArrayValues(status, MULTI))
- .withSuccessResponse[Seq[Pet]](200)
- .withErrorResponse[Unit](400)
-
- /**
- * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
- *
- * Expected answers:
- * code 200 : Seq[Pet] (successful operation)
- * code 400 : (Invalid tag value)
- *
- * @param tags Tags to filter by
- */
- def findPetsByTags(tags: Seq[String]): ApiRequest[Seq[Pet]] =
- ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByTags", "application/json")
- .withQueryParam("tags", ArrayValues(tags, MULTI))
- .withSuccessResponse[Seq[Pet]](200)
- .withErrorResponse[Unit](400)
-
- /**
- * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- *
- * Expected answers:
- * code 200 : Pet (successful operation)
- * code 400 : (Invalid ID supplied)
- * code 404 : (Pet not found)
- *
- * Available security schemes:
- * api_key (apiKey)
- *
- * @param petId ID of pet that needs to be fetched
- */
- def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Pet] =
- ApiRequest[Pet](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json")
- .withApiKey(apiKey, "api_key", HEADER)
- .withPathParam("petId", petId)
- .withSuccessResponse[Pet](200)
- .withErrorResponse[Unit](400)
- .withErrorResponse[Unit](404)
-
- /**
- *
- * Expected answers:
- * code 405 : (Invalid input)
- *
- * @param petId ID of pet that needs to be updated
- * @param name Updated name of the pet
- * @param status Updated status of the pet
- */
- def updatePetWithForm(petId: String, name: Option[String] = None, status: Option[String] = None): ApiRequest[Unit] =
- ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/x-www-form-urlencoded")
- .withFormParam("name", name)
- .withFormParam("status", status)
- .withPathParam("petId", petId)
- .withErrorResponse[Unit](405)
-
- /**
+ /**
*
* Expected answers:
* code 400 : (Invalid pet value)
@@ -116,24 +38,100 @@ object PetApi {
.withPathParam("petId", petId)
.withHeaderParam("api_key", apiKey)
.withErrorResponse[Unit](400)
-
- /**
+ /**
+ * Multiple status values can be provided with comma separated strings
*
* Expected answers:
- * code 0 : (successful operation)
+ * code 200 : Seq[Pet] (successful operation)
+ * code 400 : (Invalid status value)
+ *
+ * @param status Status values that need to be considered for filter
+ */
+ def findPetsByStatus(status: Seq[String]): ApiRequest[Seq[Pet]] =
+ ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByStatus", "application/json")
+ .withQueryParam("status", ArrayValues(status, CSV))
+ .withSuccessResponse[Seq[Pet]](200)
+ .withErrorResponse[Unit](400)
+ /**
+ * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ *
+ * Expected answers:
+ * code 200 : Seq[Pet] (successful operation)
+ * code 400 : (Invalid tag value)
+ *
+ * @param tags Tags to filter by
+ */
+ def findPetsByTags(tags: Seq[String]): ApiRequest[Seq[Pet]] =
+ ApiRequest[Seq[Pet]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/findByTags", "application/json")
+ .withQueryParam("tags", ArrayValues(tags, CSV))
+ .withSuccessResponse[Seq[Pet]](200)
+ .withErrorResponse[Unit](400)
+ /**
+ * Returns a single pet
+ *
+ * Expected answers:
+ * code 200 : Pet (successful operation)
+ * code 400 : (Invalid ID supplied)
+ * code 404 : (Pet not found)
+ *
+ * Available security schemes:
+ * api_key (apiKey)
+ *
+ * @param petId ID of pet to return
+ */
+ def getPetById(petId: Long)(implicit apiKey: ApiKeyValue): ApiRequest[Pet] =
+ ApiRequest[Pet](ApiMethods.GET, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/json")
+ .withApiKey(apiKey, "api_key", HEADER)
+ .withPathParam("petId", petId)
+ .withSuccessResponse[Pet](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+ /**
+ *
+ * Expected answers:
+ * code 400 : (Invalid ID supplied)
+ * code 404 : (Pet not found)
+ * code 405 : (Validation exception)
+ *
+ * @param body Pet object that needs to be added to the store
+ */
+ def updatePet(body: Pet): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/pet", "application/json")
+ .withBody(body)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+ .withErrorResponse[Unit](405)
+ /**
+ *
+ * Expected answers:
+ * code 405 : (Invalid input)
+ *
+ * @param petId ID of pet that needs to be updated
+ * @param name Updated name of the pet
+ * @param status Updated status of the pet
+ */
+ def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}", "application/x-www-form-urlencoded")
+ .withFormParam("name", name)
+ .withFormParam("status", status)
+ .withPathParam("petId", petId)
+ .withErrorResponse[Unit](405)
+ /**
+ *
+ * Expected answers:
+ * code 200 : ApiResponse (successful operation)
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
- def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): ApiRequest[Unit] =
- ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data")
+ def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): ApiRequest[ApiResponse] =
+ ApiRequest[ApiResponse](ApiMethods.POST, "http://petstore.swagger.io/v2", "/pet/{petId}/uploadImage", "multipart/form-data")
.withFormParam("additionalMetadata", additionalMetadata)
.withFormParam("file", file)
.withPathParam("petId", petId)
- .withDefaultSuccessResponse[Unit]
+ .withSuccessResponse[ApiResponse](200)
-
}
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala
index f3ab28da05f..3ecb7ad9dae 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/StoreApi.scala
@@ -1,3 +1,8 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.api
import io.swagger.client.model.Order
@@ -7,51 +12,6 @@ import io.swagger.client.core.ApiKeyLocations._
object StoreApi {
- /**
- * Returns a map of status codes to quantities
- *
- * Expected answers:
- * code 200 : Map[String, Int] (successful operation)
- *
- * Available security schemes:
- * api_key (apiKey)
- */
- def getInventory()(implicit apiKey: ApiKeyValue): ApiRequest[Map[String, Int]] =
- ApiRequest[Map[String, Int]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/inventory", "application/json")
- .withApiKey(apiKey, "api_key", HEADER)
- .withSuccessResponse[Map[String, Int]](200)
-
- /**
- *
- * Expected answers:
- * code 200 : Order (successful operation)
- * code 400 : (Invalid Order)
- *
- * @param body order placed for purchasing the pet
- */
- def placeOrder(body: Option[Order] = None): ApiRequest[Order] =
- ApiRequest[Order](ApiMethods.POST, "http://petstore.swagger.io/v2", "/store/order", "application/json")
- .withBody(body)
- .withSuccessResponse[Order](200)
- .withErrorResponse[Unit](400)
-
- /**
- * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- *
- * Expected answers:
- * code 200 : Order (successful operation)
- * code 400 : (Invalid ID supplied)
- * code 404 : (Order not found)
- *
- * @param orderId ID of pet that needs to be fetched
- */
- def getOrderById(orderId: String): ApiRequest[Order] =
- ApiRequest[Order](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json")
- .withPathParam("orderId", orderId)
- .withSuccessResponse[Order](200)
- .withErrorResponse[Unit](400)
- .withErrorResponse[Unit](404)
-
/**
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
*
@@ -66,8 +26,49 @@ object StoreApi {
.withPathParam("orderId", orderId)
.withErrorResponse[Unit](400)
.withErrorResponse[Unit](404)
+ /**
+ * Returns a map of status codes to quantities
+ *
+ * Expected answers:
+ * code 200 : Map[String, Int] (successful operation)
+ *
+ * Available security schemes:
+ * api_key (apiKey)
+ */
+ def getInventory()(implicit apiKey: ApiKeyValue): ApiRequest[Map[String, Int]] =
+ ApiRequest[Map[String, Int]](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/inventory", "application/json")
+ .withApiKey(apiKey, "api_key", HEADER)
+ .withSuccessResponse[Map[String, Int]](200)
+ /**
+ * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ *
+ * Expected answers:
+ * code 200 : Order (successful operation)
+ * code 400 : (Invalid ID supplied)
+ * code 404 : (Order not found)
+ *
+ * @param orderId ID of pet that needs to be fetched
+ */
+ def getOrderById(orderId: Long): ApiRequest[Order] =
+ ApiRequest[Order](ApiMethods.GET, "http://petstore.swagger.io/v2", "/store/order/{orderId}", "application/json")
+ .withPathParam("orderId", orderId)
+ .withSuccessResponse[Order](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+ /**
+ *
+ * Expected answers:
+ * code 200 : Order (successful operation)
+ * code 400 : (Invalid Order)
+ *
+ * @param body order placed for purchasing the pet
+ */
+ def placeOrder(body: Order): ApiRequest[Order] =
+ ApiRequest[Order](ApiMethods.POST, "http://petstore.swagger.io/v2", "/store/order", "application/json")
+ .withBody(body)
+ .withSuccessResponse[Order](200)
+ .withErrorResponse[Unit](400)
-
}
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala
index b759a799e3d..642c76b8d8c 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/api/UserApi.scala
@@ -1,3 +1,8 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.api
import io.swagger.client.model.User
@@ -15,12 +20,11 @@ object UserApi {
*
* @param body Created user object
*/
- def createUser(body: Option[User] = None): ApiRequest[Unit] =
+ def createUser(body: User): ApiRequest[Unit] =
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user", "application/json")
.withBody(body)
.withDefaultSuccessResponse[Unit]
-
- /**
+ /**
*
* Expected answers:
* code 0 : (successful operation)
@@ -31,8 +35,7 @@ object UserApi {
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithArray", "application/json")
.withBody(body)
.withDefaultSuccessResponse[Unit]
-
- /**
+ /**
*
* Expected answers:
* code 0 : (successful operation)
@@ -43,66 +46,7 @@ object UserApi {
ApiRequest[Unit](ApiMethods.POST, "http://petstore.swagger.io/v2", "/user/createWithList", "application/json")
.withBody(body)
.withDefaultSuccessResponse[Unit]
-
- /**
- *
- * Expected answers:
- * code 200 : String (successful operation)
- * code 400 : (Invalid username/password supplied)
- *
- * @param username The user name for login
- * @param password The password for login in clear text
- */
- def loginUser(username: Option[String] = None, password: Option[String] = None): ApiRequest[String] =
- ApiRequest[String](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/login", "application/json")
- .withQueryParam("username", username)
- .withQueryParam("password", password)
- .withSuccessResponse[String](200)
- .withErrorResponse[Unit](400)
-
- /**
- *
- * Expected answers:
- * code 0 : (successful operation)
- */
- def logoutUser(): ApiRequest[Unit] =
- ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json")
- .withDefaultSuccessResponse[Unit]
-
- /**
- *
- * Expected answers:
- * code 200 : User (successful operation)
- * code 400 : (Invalid username supplied)
- * code 404 : (User not found)
- *
- * @param username The name that needs to be fetched. Use user1 for testing.
- */
- def getUserByName(username: String): ApiRequest[User] =
- ApiRequest[User](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
- .withPathParam("username", username)
- .withSuccessResponse[User](200)
- .withErrorResponse[Unit](400)
- .withErrorResponse[Unit](404)
-
- /**
- * This can only be done by the logged in user.
- *
- * Expected answers:
- * code 400 : (Invalid user supplied)
- * code 404 : (User not found)
- *
- * @param username name that need to be deleted
- * @param body Updated user object
- */
- def updateUser(username: String, body: Option[User] = None): ApiRequest[Unit] =
- ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
- .withBody(body)
- .withPathParam("username", username)
- .withErrorResponse[Unit](400)
- .withErrorResponse[Unit](404)
-
- /**
+ /**
* This can only be done by the logged in user.
*
* Expected answers:
@@ -116,8 +60,69 @@ object UserApi {
.withPathParam("username", username)
.withErrorResponse[Unit](400)
.withErrorResponse[Unit](404)
+ /**
+ *
+ * Expected answers:
+ * code 200 : User (successful operation)
+ * code 400 : (Invalid username supplied)
+ * code 404 : (User not found)
+ *
+ * @param username The name that needs to be fetched. Use user1 for testing.
+ */
+ def getUserByName(username: String): ApiRequest[User] =
+ ApiRequest[User](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
+ .withPathParam("username", username)
+ .withSuccessResponse[User](200)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
+ /**
+ *
+ * Expected answers:
+ * code 200 : String (successful operation)
+ * Headers :
+ * X-Rate-Limit - calls per hour allowed by the user
+ * X-Expires-After - date in UTC when toekn expires
+ * code 400 : (Invalid username/password supplied)
+ *
+ * @param username The user name for login
+ * @param password The password for login in clear text
+ */
+ def loginUser(username: String, password: String): ApiRequest[String] =
+ ApiRequest[String](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/login", "application/json")
+ .withQueryParam("username", username)
+ .withQueryParam("password", password)
+ .withSuccessResponse[String](200)
+ .withErrorResponse[Unit](400)
+
+ object LoginUserHeaders {
+ def `x-Rate-Limit`(r: ApiReturnWithHeaders) = r.getIntHeader("X-Rate-Limit")
+ def `x-Expires-After`(r: ApiReturnWithHeaders) = r.getDateTimeHeader("X-Expires-After")
+ }
+ /**
+ *
+ * Expected answers:
+ * code 0 : (successful operation)
+ */
+ def logoutUser(): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.GET, "http://petstore.swagger.io/v2", "/user/logout", "application/json")
+ .withDefaultSuccessResponse[Unit]
+ /**
+ * This can only be done by the logged in user.
+ *
+ * Expected answers:
+ * code 400 : (Invalid user supplied)
+ * code 404 : (User not found)
+ *
+ * @param username name that need to be deleted
+ * @param body Updated user object
+ */
+ def updateUser(username: String, body: User): ApiRequest[Unit] =
+ ApiRequest[Unit](ApiMethods.PUT, "http://petstore.swagger.io/v2", "/user/{username}", "application/json")
+ .withBody(body)
+ .withPathParam("username", username)
+ .withErrorResponse[Unit](400)
+ .withErrorResponse[Unit](404)
-
}
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala
index 3b11d866017..18505facbd8 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiInvoker.scala
@@ -1,3 +1,9 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
package io.swagger.client.core
import java.io.File
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala
index 0588193cfbe..dd424e55fca 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiRequest.scala
@@ -1,3 +1,8 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.core
sealed trait ResponseState
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala
index 3162fb9f6be..7f7b6c0d965 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/ApiSettings.scala
@@ -1,3 +1,8 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.core
import java.util.concurrent.TimeUnit
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala
index a096a994ea3..22db882ea8b 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/core/requests.scala
@@ -1,3 +1,8 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
package io.swagger.client.core
import java.io.File
@@ -8,6 +13,8 @@ sealed trait ApiReturnWithHeaders {
def headers: Map[String, String]
def header(name: String): Option[String] = headers.get(name)
def getStringHeader(name: String) = header(name)
+ // workaround: return date time header in string instead of datetime object
+ def getDateTimeHeader(name: String) = header(name)
def getIntHeader(name: String) = castedHeader(name, java.lang.Integer.parseInt)
def getLongHeader(name: String) = castedHeader(name, java.lang.Long.parseLong)
def getFloatHeader(name: String) = castedHeader(name, java.lang.Float.parseFloat)
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/ApiResponse.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/ApiResponse.scala
new file mode 100644
index 00000000000..31a9325c6f8
--- /dev/null
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/ApiResponse.scala
@@ -0,0 +1,19 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
+package io.swagger.client.model
+
+import io.swagger.client.core.ApiModel
+import org.joda.time.DateTime
+
+
+case class ApiResponse (
+ code: Option[Int],
+ `type`: Option[String],
+ message: Option[String])
+ extends ApiModel
+
+
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala
index af66bc14753..6d14fc12276 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Category.scala
@@ -1,3 +1,9 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
package io.swagger.client.model
import io.swagger.client.core.ApiModel
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala
index 83a40fb55d3..7ed7ae6109c 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Order.scala
@@ -1,3 +1,9 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
package io.swagger.client.model
import io.swagger.client.core.ApiModel
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala
index 8cd3c61cb60..0b8cf84d49a 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Pet.scala
@@ -1,3 +1,9 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
package io.swagger.client.model
import io.swagger.client.core.ApiModel
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala
index 58aabadabe0..5a4b2f412c7 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/Tag.scala
@@ -1,3 +1,9 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
package io.swagger.client.model
import io.swagger.client.core.ApiModel
diff --git a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala
index dd0bce1d8a7..2dc7325c465 100644
--- a/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala
+++ b/samples/client/petstore/akka-scala/src/main/scala/io/swagger/client/model/User.scala
@@ -1,3 +1,9 @@
+/**
+ * NOTE: This class is auto generated by the akka-scala (beta) swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen
+ * For any issue or feedback, please open a ticket via https://github.com/swagger-api/swagger-codegen/issues/new
+ */
+
package io.swagger.client.model
import io.swagger.client.core.ApiModel
diff --git a/samples/client/petstore/android/default/pom.xml b/samples/client/petstore/android/default/pom.xml
index f9c620b7528..afedf8f3027 100644
--- a/samples/client/petstore/android/default/pom.xml
+++ b/samples/client/petstore/android/default/pom.xml
@@ -110,7 +110,7 @@
io.swagger
swagger-annotations
- ${swagger-annotations-version}
+ ${swagger-core-version}
com.google.code.gson
@@ -145,7 +145,7 @@
- 1.5.4
+ 1.5.8
2.3.1
4.8.1
1.0.0
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java
index 49ce07a07ae..17ff327a8aa 100644
--- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/JsonUtil.java
@@ -35,10 +35,22 @@ public class JsonUtil {
public static Type getListTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
+ if ("Animal".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
+ if ("Cat".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken>(){}.getType();
}
+ if ("Dog".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
if ("InlineResponse200".equalsIgnoreCase(className)) {
return new TypeToken>(){}.getType();
}
@@ -81,10 +93,22 @@ public class JsonUtil {
public static Type getTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
+ if ("Animal".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
+ if ("Cat".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken(){}.getType();
}
+ if ("Dog".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
if ("InlineResponse200".equalsIgnoreCase(className)) {
return new TypeToken(){}.getType();
}
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java
index a28410fd0a9..848f1d2a6cc 100644
--- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/api/UserApi.java
@@ -258,7 +258,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 {
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Animal.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Animal.java
new file mode 100644
index 00000000000..6f956f69f9e
--- /dev/null
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Animal.java
@@ -0,0 +1,36 @@
+package io.swagger.client.model;
+
+
+import io.swagger.annotations.*;
+import com.google.gson.annotations.SerializedName;
+
+
+@ApiModel(description = "")
+public class Animal {
+
+ @SerializedName("className")
+ private String className = null;
+
+
+ /**
+ **/
+ @ApiModelProperty(required = true, value = "")
+ public String getClassName() {
+ return className;
+ }
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class Animal {\n");
+
+ sb.append(" className: ").append(className).append("\n");
+ sb.append("}\n");
+ return sb.toString();
+ }
+}
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Cat.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Cat.java
new file mode 100644
index 00000000000..b0cd7e96b43
--- /dev/null
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Cat.java
@@ -0,0 +1,51 @@
+package io.swagger.client.model;
+
+import io.swagger.client.model.Animal;
+
+import io.swagger.annotations.*;
+import com.google.gson.annotations.SerializedName;
+
+
+@ApiModel(description = "")
+public class Cat extends Animal {
+
+ @SerializedName("className")
+ private String className = null;
+ @SerializedName("declawed")
+ private Boolean declawed = null;
+
+
+ /**
+ **/
+ @ApiModelProperty(required = true, value = "")
+ public String getClassName() {
+ return className;
+ }
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ public Boolean getDeclawed() {
+ return declawed;
+ }
+ public void setDeclawed(Boolean declawed) {
+ this.declawed = declawed;
+ }
+
+
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class Cat {\n");
+ sb.append(" " + super.toString()).append("\n");
+ sb.append(" className: ").append(className).append("\n");
+ sb.append(" declawed: ").append(declawed).append("\n");
+ sb.append("}\n");
+ return sb.toString();
+ }
+}
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Dog.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Dog.java
new file mode 100644
index 00000000000..07b2df5488a
--- /dev/null
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Dog.java
@@ -0,0 +1,51 @@
+package io.swagger.client.model;
+
+import io.swagger.client.model.Animal;
+
+import io.swagger.annotations.*;
+import com.google.gson.annotations.SerializedName;
+
+
+@ApiModel(description = "")
+public class Dog extends Animal {
+
+ @SerializedName("className")
+ private String className = null;
+ @SerializedName("breed")
+ private String breed = null;
+
+
+ /**
+ **/
+ @ApiModelProperty(required = true, value = "")
+ public String getClassName() {
+ return className;
+ }
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ public String getBreed() {
+ return breed;
+ }
+ public void setBreed(String breed) {
+ this.breed = breed;
+ }
+
+
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class Dog {\n");
+ sb.append(" " + super.toString()).append("\n");
+ sb.append(" className: ").append(className).append("\n");
+ sb.append(" breed: ").append(breed).append("\n");
+ sb.append("}\n");
+ return sb.toString();
+ }
+}
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java
index c4fd8ce357d..303d160d764 100644
--- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/InlineResponse200.java
@@ -10,31 +10,42 @@ import com.google.gson.annotations.SerializedName;
@ApiModel(description = "")
public class InlineResponse200 {
- @SerializedName("tags")
- private List tags = null;
+ @SerializedName("photoUrls")
+ private List photoUrls = null;
+ @SerializedName("name")
+ private String name = null;
@SerializedName("id")
private Long id = null;
@SerializedName("category")
private Object category = null;
+ @SerializedName("tags")
+ private List tags = null;
public enum StatusEnum {
available, pending, sold,
};
@SerializedName("status")
private StatusEnum status = null;
- @SerializedName("name")
- private String name = null;
- @SerializedName("photoUrls")
- private List photoUrls = null;
/**
**/
@ApiModelProperty(value = "")
- public List getTags() {
- return tags;
+ public List getPhotoUrls() {
+ return photoUrls;
}
- public void setTags(List tags) {
- this.tags = tags;
+ public void setPhotoUrls(List photoUrls) {
+ this.photoUrls = photoUrls;
+ }
+
+
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
}
@@ -60,6 +71,17 @@ public class InlineResponse200 {
}
+ /**
+ **/
+ @ApiModelProperty(value = "")
+ public List getTags() {
+ return tags;
+ }
+ public void setTags(List tags) {
+ this.tags = tags;
+ }
+
+
/**
* pet status in the store
**/
@@ -72,40 +94,18 @@ public class InlineResponse200 {
}
- /**
- **/
- @ApiModelProperty(value = "")
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
-
-
- /**
- **/
- @ApiModelProperty(value = "")
- public List getPhotoUrls() {
- return photoUrls;
- }
- public void setPhotoUrls(List photoUrls) {
- this.photoUrls = photoUrls;
- }
-
-
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class InlineResponse200 {\n");
- sb.append(" tags: ").append(tags).append("\n");
+ sb.append(" photoUrls: ").append(photoUrls).append("\n");
+ sb.append(" name: ").append(name).append("\n");
sb.append(" id: ").append(id).append("\n");
sb.append(" category: ").append(category).append("\n");
+ sb.append(" tags: ").append(tags).append("\n");
sb.append(" status: ").append(status).append("\n");
- sb.append(" name: ").append(name).append("\n");
- sb.append(" photoUrls: ").append(photoUrls).append("\n");
sb.append("}\n");
return sb.toString();
}
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Model200Response.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Model200Response.java
index 4a6e58b2a5e..6d3c93d9799 100644
--- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Model200Response.java
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Model200Response.java
@@ -5,7 +5,10 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
-@ApiModel(description = "")
+/**
+ * Model for testing model name starting with number
+ **/
+@ApiModel(description = "Model for testing model name starting with number")
public class Model200Response {
@SerializedName("name")
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java
index 24763f3acb4..464b0cca25e 100644
--- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/ModelReturn.java
@@ -5,7 +5,10 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
-@ApiModel(description = "")
+/**
+ * Model for testing reserved words
+ **/
+@ApiModel(description = "Model for testing reserved words")
public class ModelReturn {
@SerializedName("return")
diff --git a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java
index 9763aca7b34..1b320fb26ea 100644
--- a/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java
+++ b/samples/client/petstore/android/default/src/main/java/io/swagger/client/model/Name.java
@@ -5,7 +5,10 @@ import io.swagger.annotations.*;
import com.google.gson.annotations.SerializedName;
-@ApiModel(description = "")
+/**
+ * Model for testing model name same as property name
+ **/
+@ApiModel(description = "Model for testing model name same as property name")
public class Name {
@SerializedName("name")
diff --git a/samples/client/petstore/android/volley/build.gradle b/samples/client/petstore/android/volley/build.gradle
index e678620cb00..f794267c737 100644
--- a/samples/client/petstore/android/volley/build.gradle
+++ b/samples/client/petstore/android/volley/build.gradle
@@ -6,10 +6,8 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
-
+ classpath 'com.android.tools.build:gradle:1.5.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
-
}
}
@@ -55,9 +53,10 @@ android {
ext {
swagger_annotations_version = "1.5.0"
gson_version = "2.3.1"
- httpclient_version = "4.3.3"
+ httpclient_version = "4.5.2"
+ httpcore_version = "4.4.4"
volley_version = "1.0.19"
- junit_version = "4.8.1"
+ junit_version = "4.12"
robolectric_version = "3.0"
concurrent_unit_version = "0.4.2"
}
@@ -65,7 +64,7 @@ ext {
dependencies {
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
compile "com.google.code.gson:gson:$gson_version"
- compile "org.apache.httpcomponents:httpcore:$httpclient_version"
+ compile "org.apache.httpcomponents:httpcore:$httpcore_version"
compile "org.apache.httpcomponents:httpmime:$httpclient_version"
compile "com.mcxiaoke.volley:library:${volley_version}@aar"
testCompile "junit:junit:$junit_version"
diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java
index 21ee5f36286..7ef69c6f0ab 100644
--- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java
+++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java
@@ -189,50 +189,14 @@ public class ApiInvoker {
// Setup authentications (key: authentication name, value: authentication).
INSTANCE.authentications = new HashMap();
-
-
- INSTANCE.authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));
-
-
-
-
-
- INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
-
-
-
-
-
-
- INSTANCE.authentications.put("test_http_basic", new HttpBasicAuth());
-
-
-
-
- INSTANCE.authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret"));
-
-
-
-
-
- INSTANCE.authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));
-
-
-
-
-
- INSTANCE.authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query"));
-
-
-
-
-
-
-
// TODO: comment out below as OAuth does not exist
//INSTANCE.authentications.put("petstore_auth", new OAuth());
-
-
+ INSTANCE.authentications.put("test_api_client_id", new ApiKeyAuth("header", "x-test_api_client_id"));
+ INSTANCE.authentications.put("test_api_client_secret", new ApiKeyAuth("header", "x-test_api_client_secret"));
+ INSTANCE.authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
+ INSTANCE.authentications.put("test_http_basic", new HttpBasicAuth());
+ INSTANCE.authentications.put("test_api_key_query", new ApiKeyAuth("query", "test_api_key_query"));
+ INSTANCE.authentications.put("test_api_key_header", new ApiKeyAuth("header", "test_api_key_header"));
// Prevent the authentications from being modified.
INSTANCE.authentications = Collections.unmodifiableMap(INSTANCE.authentications);
}
diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/JsonUtil.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/JsonUtil.java
index 49ce07a07ae..318c23f957d 100644
--- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/JsonUtil.java
+++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/JsonUtil.java
@@ -35,10 +35,26 @@ public class JsonUtil {
public static Type getListTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
+ if ("Animal".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
+ if ("Cat".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken>(){}.getType();
}
+ if ("Dog".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
+ if ("FormatTest".equalsIgnoreCase(className)) {
+ return new TypeToken>(){}.getType();
+ }
+
if ("InlineResponse200".equalsIgnoreCase(className)) {
return new TypeToken>(){}.getType();
}
@@ -81,10 +97,26 @@ public class JsonUtil {
public static Type getTypeForDeserialization(Class cls) {
String className = cls.getSimpleName();
+ if ("Animal".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
+ if ("Cat".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
if ("Category".equalsIgnoreCase(className)) {
return new TypeToken(){}.getType();
}
+ if ("Dog".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
+ if ("FormatTest".equalsIgnoreCase(className)) {
+ return new TypeToken(){}.getType();
+ }
+
if ("InlineResponse200".equalsIgnoreCase(className)) {
return new TypeToken(){}.getType();
}
diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java
index b0a72ab7d8a..2f39cf7cab1 100644
--- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java
+++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/PetApi.java
@@ -45,7 +45,6 @@ public class PetApi {
return basePath;
}
-
/**
* Add a new pet to the store
*
@@ -66,9 +65,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/json","application/xml"
@@ -84,8 +81,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -102,7 +98,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -130,9 +129,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/json","application/xml"
@@ -148,8 +145,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -158,11 +154,7 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
-
responseListener.onResponse(localVarResponse);
-
-
}
}, new Response.ErrorListener() {
@Override
@@ -174,7 +166,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
*
@@ -186,7 +177,7 @@ public class PetApi {
// create path and map variables
- String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
+ String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
// query params
List queryParams = new ArrayList();
@@ -195,9 +186,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/json","application/xml"
@@ -213,8 +202,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -231,7 +219,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -250,7 +241,7 @@ public class PetApi {
// create path and map variables
- String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
+ String path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json");
// query params
List queryParams = new ArrayList();
@@ -259,9 +250,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/json","application/xml"
@@ -277,8 +266,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -287,11 +275,7 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
-
responseListener.onResponse(localVarResponse);
-
-
}
}, new Response.ErrorListener() {
@Override
@@ -303,7 +287,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Deletes a pet
*
@@ -331,11 +314,8 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
headerParams.put("api_key", ApiInvoker.parameterToString(apiKey));
-
String[] contentTypes = {
@@ -351,8 +331,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -369,7 +348,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -403,11 +385,8 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
headerParams.put("api_key", ApiInvoker.parameterToString(apiKey));
-
String[] contentTypes = {
@@ -423,8 +402,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -433,11 +411,7 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
-
responseListener.onResponse(localVarResponse);
-
-
}
}, new Response.ErrorListener() {
@Override
@@ -449,7 +423,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
@@ -470,11 +443,8 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
queryParams.addAll(ApiInvoker.parameterToPairs("multi", "status", status));
-
-
String[] contentTypes = {
@@ -490,8 +460,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -508,7 +477,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -536,11 +508,8 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
queryParams.addAll(ApiInvoker.parameterToPairs("multi", "status", status));
-
-
String[] contentTypes = {
@@ -556,8 +525,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -566,16 +534,11 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
try {
responseListener.onResponse((List) ApiInvoker.deserialize(localVarResponse, "array", Pet.class));
-
-
-
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
-
}
}, new Response.ErrorListener() {
@Override
@@ -587,7 +550,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Finds Pets by tags
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
@@ -608,11 +570,8 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
queryParams.addAll(ApiInvoker.parameterToPairs("multi", "tags", tags));
-
-
String[] contentTypes = {
@@ -628,8 +587,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -646,7 +604,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -674,11 +635,8 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
queryParams.addAll(ApiInvoker.parameterToPairs("multi", "tags", tags));
-
-
String[] contentTypes = {
@@ -694,8 +652,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -704,16 +661,11 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
try {
responseListener.onResponse((List) ApiInvoker.deserialize(localVarResponse, "array", Pet.class));
-
-
-
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
-
}
}, new Response.ErrorListener() {
@Override
@@ -725,7 +677,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Find pet by ID
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
@@ -752,9 +703,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -770,10 +719,9 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
- String[] authNames = new String[] { "api_key", "petstore_auth" };
+ String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
@@ -788,7 +736,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -822,9 +773,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -840,26 +789,20 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
- String[] authNames = new String[] { "api_key", "petstore_auth" };
+ String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
try {
responseListener.onResponse((Pet) ApiInvoker.deserialize(localVarResponse, "", Pet.class));
-
-
-
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
-
}
}, new Response.ErrorListener() {
@Override
@@ -871,7 +814,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
@@ -889,7 +831,7 @@ public class PetApi {
// create path and map variables
- String path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
+ String path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
List queryParams = new ArrayList();
@@ -898,9 +840,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -916,10 +856,9 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
- String[] authNames = new String[] { "api_key", "petstore_auth" };
+ String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
@@ -934,7 +873,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -959,7 +901,7 @@ public class PetApi {
// create path and map variables
- String path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
+ String path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
List queryParams = new ArrayList();
@@ -968,9 +910,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -986,26 +926,20 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
- String[] authNames = new String[] { "api_key", "petstore_auth" };
+ String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
try {
responseListener.onResponse((InlineResponse200) ApiInvoker.deserialize(localVarResponse, "", InlineResponse200.class));
-
-
-
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
-
}
}, new Response.ErrorListener() {
@Override
@@ -1017,7 +951,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Fake endpoint to test byte array return by 'Find pet by ID'
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
@@ -1035,7 +968,7 @@ public class PetApi {
// create path and map variables
- String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
+ String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
List queryParams = new ArrayList();
@@ -1044,9 +977,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -1062,10 +993,9 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
- String[] authNames = new String[] { "api_key", "petstore_auth" };
+ String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
String localVarResponse = apiInvoker.invokeAPI (basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames);
@@ -1080,7 +1010,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -1105,7 +1038,7 @@ public class PetApi {
// create path and map variables
- String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
+ String path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}", apiInvoker.escapeString(petId.toString()));
// query params
List queryParams = new ArrayList();
@@ -1114,9 +1047,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -1132,26 +1063,20 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
- String[] authNames = new String[] { "api_key", "petstore_auth" };
+ String[] authNames = new String[] { "petstore_auth", "api_key" };
try {
apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType, authNames,
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
try {
responseListener.onResponse((byte[]) ApiInvoker.deserialize(localVarResponse, "", byte[].class));
-
-
-
} catch (ApiException exception) {
errorListener.onErrorResponse(new VolleyError(exception));
}
-
}
}, new Response.ErrorListener() {
@Override
@@ -1163,7 +1088,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Update an existing pet
*
@@ -1184,9 +1108,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/json","application/xml"
@@ -1202,8 +1124,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -1220,7 +1141,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -1248,9 +1172,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/json","application/xml"
@@ -1266,8 +1188,7 @@ public class PetApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { "petstore_auth" };
@@ -1276,11 +1197,7 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
-
responseListener.onResponse(localVarResponse);
-
-
}
}, new Response.ErrorListener() {
@Override
@@ -1292,7 +1209,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* Updates a pet in the store with form data
*
@@ -1321,9 +1237,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/x-www-form-urlencoded"
@@ -1348,8 +1262,7 @@ public class PetApi {
} else {
// normal form params
formParams.put("name", ApiInvoker.parameterToString(name));
- formParams.put("status", ApiInvoker.parameterToString(status));
-
+formParams.put("status", ApiInvoker.parameterToString(status));
}
String[] authNames = new String[] { "petstore_auth" };
@@ -1367,7 +1280,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -1401,9 +1317,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"application/x-www-form-urlencoded"
@@ -1428,8 +1342,7 @@ public class PetApi {
} else {
// normal form params
formParams.put("name", ApiInvoker.parameterToString(name));
- formParams.put("status", ApiInvoker.parameterToString(status));
-
+formParams.put("status", ApiInvoker.parameterToString(status));
}
String[] authNames = new String[] { "petstore_auth" };
@@ -1439,11 +1352,7 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
-
responseListener.onResponse(localVarResponse);
-
-
}
}, new Response.ErrorListener() {
@Override
@@ -1455,7 +1364,6 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
/**
* uploads an image
*
@@ -1484,9 +1392,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"multipart/form-data"
@@ -1511,8 +1417,7 @@ public class PetApi {
} else {
// normal form params
formParams.put("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata));
-
-
+
}
String[] authNames = new String[] { "petstore_auth" };
@@ -1530,7 +1435,10 @@ public class PetApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -1564,9 +1472,7 @@ public class PetApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
"multipart/form-data"
@@ -1591,8 +1497,7 @@ public class PetApi {
} else {
// normal form params
formParams.put("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata));
-
-
+
}
String[] authNames = new String[] { "petstore_auth" };
@@ -1602,11 +1507,7 @@ public class PetApi {
new Response.Listener() {
@Override
public void onResponse(String localVarResponse) {
-
-
responseListener.onResponse(localVarResponse);
-
-
}
}, new Response.ErrorListener() {
@Override
@@ -1618,5 +1519,4 @@ public class PetApi {
errorListener.onErrorResponse(new VolleyError(ex));
}
}
-
}
diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java
index e0aa403200a..2d7b1e7683f 100644
--- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java
+++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/api/StoreApi.java
@@ -44,7 +44,6 @@ public class StoreApi {
return basePath;
}
-
/**
* Delete purchase order by ID
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
@@ -71,9 +70,7 @@ public class StoreApi {
// form params
Map formParams = new HashMap();
-
-
String[] contentTypes = {
@@ -89,8 +86,7 @@ public class StoreApi {
postBody = httpEntity;
} else {
// normal form params
-
- }
+ }
String[] authNames = new String[] { };
@@ -107,7 +103,10 @@ public class StoreApi {
throw ex;
} catch (ExecutionException ex) {
if(ex.getCause() instanceof VolleyError) {
- throw new ApiException(((VolleyError) ex.getCause()).networkResponse.statusCode, ((VolleyError) ex.getCause()).getMessage());
+ VolleyError volleyError = (VolleyError)ex.getCause();
+ if (volleyError.networkResponse != null) {
+ throw new ApiException(volleyError.networkResponse.statusCode, volleyError.getMessage());
+ }
}
throw ex;
} catch (TimeoutException ex) {
@@ -141,9 +140,7 @@ public class StoreApi {
// form params
Map formParams = new HashMap