Merge remote-tracking branch 'origin/master' into 2.3.0

This commit is contained in:
wing328 2017-04-01 16:39:54 +08:00
commit bfa18a0ce8
18 changed files with 484 additions and 482 deletions

View File

@ -46,7 +46,6 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
protected boolean swiftUseApiNamespace; protected boolean swiftUseApiNamespace;
protected String[] responseAs = new String[0]; protected String[] responseAs = new String[0];
protected String sourceFolder = "Classes" + File.separator + "Swaggers"; protected String sourceFolder = "Classes" + File.separator + "Swaggers";
private static final Pattern PATH_PARAM_PATTERN = Pattern.compile("\\{[a-zA-Z_]+\\}");
@Override @Override
public CodegenType getTag() { public CodegenType getTag() {
@ -454,40 +453,6 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
return codegenModel; return codegenModel;
} }
@Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Model> definitions, Swagger swagger) {
path = normalizePath(path); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// issue 3914 - removed logic designed to remove any parameter of type HeaderParameter
return super.fromOperation(path, httpMethod, operation, definitions, swagger);
}
private static String normalizePath(String path) {
StringBuilder builder = new StringBuilder();
int cursor = 0;
Matcher matcher = PATH_PARAM_PATTERN.matcher(path);
boolean found = matcher.find();
while (found) {
String stringBeforeMatch = path.substring(cursor, matcher.start());
builder.append(stringBeforeMatch);
String group = matcher.group().substring(1, matcher.group().length() - 1);
group = camelize(group, true);
builder
.append("{")
.append(group)
.append("}");
cursor = matcher.end();
found = matcher.find();
}
String stringAfterMatch = path.substring(cursor);
builder.append(stringAfterMatch);
return builder.toString();
}
public void setProjectName(String projectName) { public void setProjectName(String projectName) {
this.projectName = projectName; this.projectName = projectName;
} }

View File

@ -1 +1 @@
"{{baseName}}": {{paramName}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}.rawValue{{/isContainer}}{{/isEnum}}{{#isDate}}{{^required}}?{{/required}}.encodeToJSON(){{/isDate}}{{#isDateTime}}{{^required}}?{{/required}}.encodeToJSON(){{/isDateTime}} "{{baseName}}": {{paramName}}{{^isEnum}}{{#isInteger}}{{^required}}?{{/required}}.encodeToJSON(){{/isInteger}}{{#isLong}}{{^required}}?{{/required}}.encodeToJSON(){{/isLong}}{{/isEnum}}{{#isEnum}}{{^isContainer}}{{^required}}?{{/required}}.rawValue{{/isContainer}}{{/isEnum}}{{#isDate}}{{^required}}?{{/required}}.encodeToJSON(){{/isDate}}{{#isDateTime}}{{^required}}?{{/required}}.encodeToJSON(){{/isDateTime}}

View File

@ -279,7 +279,7 @@ export enum {{classname}}ApiKeys {
} }
export class {{classname}} { export class {{classname}} {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -326,6 +326,14 @@ export class {{classname}} {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: {{classname}}ApiKeys, value: string) { public setApiKey(key: {{classname}}ApiKeys, value: string) {
this.authentications[{{classname}}ApiKeys[key]].apiKey = value; this.authentications[{{classname}}ApiKeys[key]].apiKey = value;
} }

View File

@ -324,7 +324,7 @@ paths:
$ref: '#/definitions/Order' $ref: '#/definitions/Order'
'400': '400':
description: Invalid Order description: Invalid Order
'/store/order/{orderId}': '/store/order/{order_id}':
get: get:
tags: tags:
- store - store
@ -335,7 +335,7 @@ paths:
- application/xml - application/xml
- application/json - application/json
parameters: parameters:
- name: orderId - name: order_id
in: path in: path
description: ID of pet that needs to be fetched description: ID of pet that needs to be fetched
required: true required: true
@ -362,7 +362,7 @@ paths:
- application/xml - application/xml
- application/json - application/json
parameters: parameters:
- name: orderId - name: order_id
in: path in: path
description: ID of the order that needs to be deleted description: ID of the order that needs to be deleted
required: true required: true

View File

@ -27,6 +27,7 @@ import java.io.InputStream;
{{^supportJava6}} {{^supportJava6}}
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
{{/supportJava6}} {{/supportJava6}}
{{#supportJava6}} {{#supportJava6}}
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
@ -581,7 +582,7 @@ public class ApiClient {
try { try {
File file = prepareDownloadFile(response); File file = prepareDownloadFile(response);
{{^supportJava6}} {{^supportJava6}}
Files.copy(response.readEntity(InputStream.class), file.toPath()); Files.copy(response.readEntity(InputStream.class), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
{{/supportJava6}} {{/supportJava6}}
{{#supportJava6}} {{#supportJava6}}
// Java6 falls back to commons.io for file copying // Java6 falls back to commons.io for file copying

View File

@ -4,9 +4,9 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet

View File

@ -49,8 +49,8 @@ public class StoreApi {
} }
// create path and map variables // create path and map variables
String localVarPath = "/store/order/{orderId}" String localVarPath = "/store/order/{order_id}"
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
@ -126,8 +126,8 @@ public class StoreApi {
} }
// create path and map variables // create path and map variables
String localVarPath = "/store/order/{orderId}" String localVarPath = "/store/order/{order_id}"
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();

View File

@ -4,9 +4,9 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID [**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status [**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID [**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet [**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet

View File

@ -49,8 +49,8 @@ public class StoreApi {
} }
// create path and map variables // create path and map variables
String localVarPath = "/store/order/{orderId}" String localVarPath = "/store/order/{order_id}"
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();
@ -126,8 +126,8 @@ public class StoreApi {
} }
// create path and map variables // create path and map variables
String localVarPath = "/store/order/{orderId}" String localVarPath = "/store/order/{order_id}"
.replaceAll("\\{" + "orderId" + "\\}", apiClient.escapeString(orderId.toString())); .replaceAll("\\{" + "order_id" + "\\}", apiClient.escapeString(orderId.toString()));
// query params // query params
List<Pair> localVarQueryParams = new ArrayList<Pair>(); List<Pair> localVarQueryParams = new ArrayList<Pair>();

View File

@ -249,7 +249,7 @@ open class FakeAPI: APIBase {
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
"enum_query_string_array": enumQueryStringArray, "enum_query_string_array": enumQueryStringArray,
"enum_query_string": enumQueryString?.rawValue, "enum_query_string": enumQueryString?.rawValue,
"enum_query_integer": enumQueryInteger?.encodeToJSON()?.rawValue "enum_query_integer": enumQueryInteger?.rawValue
]) ])
let nillableHeaders: [String: Any?] = [ let nillableHeaders: [String: Any?] = [

View File

@ -34,7 +34,7 @@ open class StoreAPI: APIBase {
*/ */
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> { open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{orderId}" var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil) path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil let parameters: [String:Any]? = nil
@ -138,7 +138,7 @@ open class StoreAPI: APIBase {
*/ */
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> { open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{orderId}" var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil) path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil let parameters: [String:Any]? = nil

View File

@ -321,7 +321,7 @@ open class FakeAPI: APIBase {
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
"enum_query_string_array": enumQueryStringArray, "enum_query_string_array": enumQueryStringArray,
"enum_query_string": enumQueryString?.rawValue, "enum_query_string": enumQueryString?.rawValue,
"enum_query_integer": enumQueryInteger?.encodeToJSON()?.rawValue "enum_query_integer": enumQueryInteger?.rawValue
]) ])
let nillableHeaders: [String: Any?] = [ let nillableHeaders: [String: Any?] = [

View File

@ -52,7 +52,7 @@ open class StoreAPI: APIBase {
*/ */
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> { open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{orderId}" var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil) path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil let parameters: [String:Any]? = nil
@ -189,7 +189,7 @@ open class StoreAPI: APIBase {
*/ */
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> { open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{orderId}" var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil) path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil let parameters: [String:Any]? = nil

View File

@ -327,7 +327,7 @@ open class FakeAPI: APIBase {
url?.queryItems = APIHelper.mapValuesToQueryItems(values:[ url?.queryItems = APIHelper.mapValuesToQueryItems(values:[
"enum_query_string_array": enumQueryStringArray, "enum_query_string_array": enumQueryStringArray,
"enum_query_string": enumQueryString?.rawValue, "enum_query_string": enumQueryString?.rawValue,
"enum_query_integer": enumQueryInteger?.encodeToJSON()?.rawValue "enum_query_integer": enumQueryInteger?.rawValue
]) ])
let nillableHeaders: [String: Any?] = [ let nillableHeaders: [String: Any?] = [

View File

@ -54,7 +54,7 @@ open class StoreAPI: APIBase {
*/ */
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> { open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
var path = "/store/order/{orderId}" var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil) path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil let parameters: [String:Any]? = nil
@ -195,7 +195,7 @@ open class StoreAPI: APIBase {
*/ */
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> { open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
var path = "/store/order/{orderId}" var path = "/store/order/{orderId}"
path = path.replacingOccurrences(of: "{orderId}", with: "\(orderId)", options: .literal, range: nil) path = path.replacingOccurrences(of: "{order_id}", with: "\(orderId)", options: .literal, range: nil)
let URLString = PetstoreClientAPI.basePath + path let URLString = PetstoreClientAPI.basePath + path
let parameters: [String:Any]? = nil let parameters: [String:Any]? = nil

View File

@ -427,7 +427,7 @@ export enum PetApiApiKeys {
} }
export class PetApi { export class PetApi {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -454,6 +454,14 @@ export class PetApi {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: PetApiApiKeys, value: string) { public setApiKey(key: PetApiApiKeys, value: string) {
this.authentications[PetApiApiKeys[key]].apiKey = value; this.authentications[PetApiApiKeys[key]].apiKey = value;
} }
@ -706,10 +714,10 @@ export class PetApi {
json: true, json: true,
}; };
this.authentications.petstore_auth.applyToRequest(requestOptions);
this.authentications.api_key.applyToRequest(requestOptions); this.authentications.api_key.applyToRequest(requestOptions);
this.authentications.petstore_auth.applyToRequest(requestOptions);
this.authentications.default.applyToRequest(requestOptions); this.authentications.default.applyToRequest(requestOptions);
if (Object.keys(formParams).length) { if (Object.keys(formParams).length) {
@ -921,7 +929,7 @@ export enum StoreApiApiKeys {
} }
export class StoreApi { export class StoreApi {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -948,6 +956,14 @@ export class StoreApi {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: StoreApiApiKeys, value: string) { public setApiKey(key: StoreApiApiKeys, value: string) {
this.authentications[StoreApiApiKeys[key]].apiKey = value; this.authentications[StoreApiApiKeys[key]].apiKey = value;
} }
@ -1166,7 +1182,7 @@ export enum UserApiApiKeys {
} }
export class UserApi { export class UserApi {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -1193,6 +1209,14 @@ export class UserApi {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: UserApiApiKeys, value: string) { public setApiKey(key: UserApiApiKeys, value: string) {
this.authentications[UserApiApiKeys[key]].apiKey = value; this.authentications[UserApiApiKeys[key]].apiKey = value;
} }

View File

@ -427,7 +427,7 @@ export enum PetApiApiKeys {
} }
export class PetApi { export class PetApi {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -454,6 +454,14 @@ export class PetApi {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: PetApiApiKeys, value: string) { public setApiKey(key: PetApiApiKeys, value: string) {
this.authentications[PetApiApiKeys[key]].apiKey = value; this.authentications[PetApiApiKeys[key]].apiKey = value;
} }
@ -706,10 +714,10 @@ export class PetApi {
json: true, json: true,
}; };
this.authentications.petstore_auth.applyToRequest(requestOptions);
this.authentications.api_key.applyToRequest(requestOptions); this.authentications.api_key.applyToRequest(requestOptions);
this.authentications.petstore_auth.applyToRequest(requestOptions);
this.authentications.default.applyToRequest(requestOptions); this.authentications.default.applyToRequest(requestOptions);
if (Object.keys(formParams).length) { if (Object.keys(formParams).length) {
@ -921,7 +929,7 @@ export enum StoreApiApiKeys {
} }
export class StoreApi { export class StoreApi {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -948,6 +956,14 @@ export class StoreApi {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: StoreApiApiKeys, value: string) { public setApiKey(key: StoreApiApiKeys, value: string) {
this.authentications[StoreApiApiKeys[key]].apiKey = value; this.authentications[StoreApiApiKeys[key]].apiKey = value;
} }
@ -1166,7 +1182,7 @@ export enum UserApiApiKeys {
} }
export class UserApi { export class UserApi {
protected basePath = defaultBasePath; protected _basePath = defaultBasePath;
protected defaultHeaders : any = {}; protected defaultHeaders : any = {};
protected _useQuerystring : boolean = false; protected _useQuerystring : boolean = false;
@ -1193,6 +1209,14 @@ export class UserApi {
this._useQuerystring = value; this._useQuerystring = value;
} }
set basePath(basePath: string) {
this._basePath = basePath;
}
get basePath() {
return this._basePath;
}
public setApiKey(key: UserApiApiKeys, value: string) { public setApiKey(key: UserApiApiKeys, value: string) {
this.authentications[UserApiApiKeys[key]].apiKey = value; this.authentications[UserApiApiKeys[key]].apiKey = value;
} }