forked from loafle/openapi-generator-original
Merge pull request #2294 from wing328/swift_reserved_word
[Swift] improvements to model
This commit is contained in:
commit
78f1c7a601
@ -343,7 +343,7 @@ public class DefaultCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the capitalized file name of the model test
|
* Return the capitalized file name of the model
|
||||||
*
|
*
|
||||||
* @param name the model name
|
* @param name the model name
|
||||||
* @return the file name of the model
|
* @return the file name of the model
|
||||||
|
@ -85,6 +85,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
defaultIncludes = new HashSet<String>(
|
defaultIncludes = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"NSDate",
|
"NSDate",
|
||||||
|
"NSURL", // for file
|
||||||
"Array",
|
"Array",
|
||||||
"Dictionary",
|
"Dictionary",
|
||||||
"Set",
|
"Set",
|
||||||
@ -231,13 +232,57 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
String type = null;
|
String type = null;
|
||||||
if (typeMapping.containsKey(swaggerType)) {
|
if (typeMapping.containsKey(swaggerType)) {
|
||||||
type = typeMapping.get(swaggerType);
|
type = typeMapping.get(swaggerType);
|
||||||
if (languageSpecificPrimitives.contains(type))
|
if (languageSpecificPrimitives.contains(type) || defaultIncludes.contains(type))
|
||||||
return toModelName(type);
|
return type;
|
||||||
} else
|
} else
|
||||||
type = swaggerType;
|
type = swaggerType;
|
||||||
return toModelName(type);
|
return toModelName(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output the proper model name (capitalized)
|
||||||
|
*
|
||||||
|
* @param name the name of the model
|
||||||
|
* @return capitalized model name
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toModelName(String name) {
|
||||||
|
name = sanitizeName(name); // FIXME parameter should not be assigned. Also declare it as "final"
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelNameSuffix)) { // set model suffix
|
||||||
|
name = name + "_" + modelNameSuffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(modelNamePrefix)) { // set model prefix
|
||||||
|
name = modelNamePrefix + "_" + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
name = camelize(name);
|
||||||
|
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if (isReservedWord(name)) {
|
||||||
|
String modelName = "Object" + name;
|
||||||
|
LOGGER.warn(name + " (reserved word) cannot be used as model name. Renamed to " + modelName);
|
||||||
|
return modelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the capitalized file name of the model
|
||||||
|
*
|
||||||
|
* @param name the model name
|
||||||
|
* @return the file name of the model
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
// should be the same as the model name
|
||||||
|
return toModelName(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toDefaultValue(Property p) {
|
public String toDefaultValue(Property p) {
|
||||||
// nil
|
// nil
|
||||||
@ -304,17 +349,21 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toOperationId(String operationId) {
|
public String toOperationId(String operationId) {
|
||||||
// throw exception if method name is empty
|
operationId = camelize(sanitizeName(operationId), true);
|
||||||
|
|
||||||
|
// throw exception if method name is empty. This should not happen but keep the check just in case
|
||||||
if (StringUtils.isEmpty(operationId)) {
|
if (StringUtils.isEmpty(operationId)) {
|
||||||
throw new RuntimeException("Empty method name (operationId) not allowed");
|
throw new RuntimeException("Empty method name (operationId) not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// method name cannot use reserved keyword, e.g. return
|
// method name cannot use reserved keyword, e.g. return
|
||||||
if (isReservedWord(operationId)) {
|
if (isReservedWord(operationId)) {
|
||||||
throw new RuntimeException(operationId + " (reserved word) cannot be used as method name");
|
String newOperationId = camelize(("call_" + operationId), true);
|
||||||
|
LOGGER.warn(operationId + " (reserved word) cannot be used as method name. Renamed to " + newOperationId);
|
||||||
|
return newOperationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return camelize(sanitizeName(operationId), true);
|
return operationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -166,20 +166,20 @@ public class PetAPI: APIBase {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -188,21 +188,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -211,7 +211,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter status: (query) Status values that need to be considered for query
|
- parameter status: (query) Status values that need to be considered for query
|
||||||
|
|
||||||
@ -272,20 +272,20 @@ public class PetAPI: APIBase {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -294,21 +294,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
} ], contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
} ]}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -317,7 +317,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter tags: (query) Tags to filter by
|
- parameter tags: (query) Tags to filter by
|
||||||
|
|
||||||
@ -375,26 +375,26 @@ public class PetAPI: APIBase {
|
|||||||
|
|
||||||
- GET /pet/{petId}
|
- GET /pet/{petId}
|
||||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
- OAuth:
|
|
||||||
- type: oauth2
|
|
||||||
- name: petstore_auth
|
|
||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{contentType=application/json, example={
|
- OAuth:
|
||||||
"photoUrls" : [ "aeiou" ],
|
- type: oauth2
|
||||||
"name" : "doggie",
|
- name: petstore_auth
|
||||||
|
- examples: [{example={
|
||||||
|
"tags" : [ {
|
||||||
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
}, contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
}}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -403,21 +403,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"photoUrls" : [ "aeiou" ],
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"id" : 123456789,
|
||||||
|
"name" : "aeiou"
|
||||||
|
} ],
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"name" : "aeiou",
|
"id" : 123456789,
|
||||||
"id" : 123456789
|
"name" : "aeiou"
|
||||||
},
|
},
|
||||||
"tags" : [ {
|
"status" : "aeiou",
|
||||||
"name" : "aeiou",
|
"name" : "doggie",
|
||||||
"id" : 123456789
|
"photoUrls" : [ "aeiou" ]
|
||||||
} ],
|
}, contentType=application/json}, {example=<Pet>
|
||||||
"status" : "aeiou"
|
|
||||||
}}, {contentType=application/xml, example=<Pet>
|
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -426,7 +426,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>}]
|
</Pet>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
@ -678,14 +678,14 @@ public class PetAPI: APIBase {
|
|||||||
|
|
||||||
- GET /pet/{petId}?testing_byte_array=true
|
- GET /pet/{petId}?testing_byte_array=true
|
||||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
- OAuth:
|
|
||||||
- type: oauth2
|
|
||||||
- name: petstore_auth
|
|
||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}]
|
- OAuth:
|
||||||
- examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}]
|
- type: oauth2
|
||||||
|
- name: petstore_auth
|
||||||
|
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
|
||||||
|
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -55,36 +55,36 @@ public class StoreAPI: APIBase {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey x-test_api_client_secret
|
- type: apiKey x-test_api_client_secret
|
||||||
- name: test_api_client_secret
|
- name: test_api_client_secret
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
} ]}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
||||||
|
} ], contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example=[ {
|
- examples: [{example=[ {
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
} ]}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
||||||
|
} ], contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter status: (query) Status value that needs to be considered for query
|
- parameter status: (query) Status value that needs to be considered for query
|
||||||
|
|
||||||
@ -143,12 +143,12 @@ public class StoreAPI: APIBase {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"key" : 123
|
"key" : 123
|
||||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"key" : 123
|
"key" : 123
|
||||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||||
|
|
||||||
- returns: RequestBuilder<[String:Int]>
|
- returns: RequestBuilder<[String:Int]>
|
||||||
*/
|
*/
|
||||||
@ -208,36 +208,36 @@ public class StoreAPI: APIBase {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey x-test_api_client_secret
|
- type: apiKey x-test_api_client_secret
|
||||||
- name: test_api_client_secret
|
- name: test_api_client_secret
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter body: (body) order placed for purchasing the pet
|
- parameter body: (body) order placed for purchasing the pet
|
||||||
|
|
||||||
@ -292,42 +292,42 @@ public class StoreAPI: APIBase {
|
|||||||
|
|
||||||
- GET /store/order/{orderId}
|
- GET /store/order/{orderId}
|
||||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
- API Key:
|
|
||||||
- type: apiKey test_api_key_query (QUERY)
|
|
||||||
- name: test_api_key_query
|
|
||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey test_api_key_header
|
- type: apiKey test_api_key_header
|
||||||
- name: test_api_key_header
|
- name: test_api_key_header
|
||||||
- examples: [{contentType=application/json, example={
|
- API Key:
|
||||||
"petId" : 123456789,
|
- type: apiKey test_api_key_query (QUERY)
|
||||||
"quantity" : 123,
|
- name: test_api_key_query
|
||||||
|
- examples: [{example={
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"petId" : 123456789,
|
|
||||||
"quantity" : 123,
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+0000",
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
"complete" : true,
|
||||||
"status" : "aeiou"
|
"status" : "aeiou",
|
||||||
}}, {contentType=application/xml, example=<Order>
|
"quantity" : 123,
|
||||||
|
"shipDate" : "2000-01-23T04:56:07.000+0000"
|
||||||
|
}, contentType=application/json}, {example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>}]
|
</Order>, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -213,8 +213,8 @@ public class UserAPI: APIBase {
|
|||||||
|
|
||||||
- GET /user/login
|
- GET /user/login
|
||||||
-
|
-
|
||||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||||
|
|
||||||
- parameter username: (query) The user name for login
|
- parameter username: (query) The user name for login
|
||||||
- parameter password: (query) The password for login in clear text
|
- parameter password: (query) The password for login in clear text
|
||||||
@ -325,7 +325,7 @@ public class UserAPI: APIBase {
|
|||||||
|
|
||||||
- GET /user/{username}
|
- GET /user/{username}
|
||||||
-
|
-
|
||||||
- examples: [{contentType=application/json, example={
|
- examples: [{example={
|
||||||
"id" : 1,
|
"id" : 1,
|
||||||
"username" : "johnp",
|
"username" : "johnp",
|
||||||
"firstName" : "John",
|
"firstName" : "John",
|
||||||
@ -334,7 +334,7 @@ public class UserAPI: APIBase {
|
|||||||
"password" : "-secret-",
|
"password" : "-secret-",
|
||||||
"phone" : "0123456789",
|
"phone" : "0123456789",
|
||||||
"userStatus" : 0
|
"userStatus" : 0
|
||||||
}}]
|
}, contentType=application/json}]
|
||||||
|
|
||||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||||
|
|
||||||
|
@ -124,24 +124,6 @@ class Decoders {
|
|||||||
fatalError("formatter failed to parse \(source)")
|
fatalError("formatter failed to parse \(source)")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decoder for [Order]
|
|
||||||
Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in
|
|
||||||
return Decoders.decode(clazz: [Order].self, source: source)
|
|
||||||
}
|
|
||||||
// Decoder for Order
|
|
||||||
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
|
|
||||||
let sourceDictionary = source as! [NSObject:AnyObject]
|
|
||||||
let instance = Order()
|
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
|
|
||||||
instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"])
|
|
||||||
instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"])
|
|
||||||
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
|
|
||||||
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
|
|
||||||
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
|
|
||||||
return instance
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Decoder for [User]
|
// Decoder for [User]
|
||||||
Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in
|
Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in
|
||||||
return Decoders.decode(clazz: [User].self, source: source)
|
return Decoders.decode(clazz: [User].self, source: source)
|
||||||
@ -176,20 +158,6 @@ class Decoders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Decoder for [Tag]
|
|
||||||
Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in
|
|
||||||
return Decoders.decode(clazz: [Tag].self, source: source)
|
|
||||||
}
|
|
||||||
// Decoder for Tag
|
|
||||||
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
|
|
||||||
let sourceDictionary = source as! [NSObject:AnyObject]
|
|
||||||
let instance = Tag()
|
|
||||||
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
|
|
||||||
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
|
|
||||||
return instance
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Decoder for [Pet]
|
// Decoder for [Pet]
|
||||||
Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in
|
Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in
|
||||||
return Decoders.decode(clazz: [Pet].self, source: source)
|
return Decoders.decode(clazz: [Pet].self, source: source)
|
||||||
@ -207,6 +175,38 @@ class Decoders {
|
|||||||
return instance
|
return instance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Decoder for [Tag]
|
||||||
|
Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in
|
||||||
|
return Decoders.decode(clazz: [Tag].self, source: source)
|
||||||
|
}
|
||||||
|
// Decoder for Tag
|
||||||
|
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
|
||||||
|
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||||
|
let instance = Tag()
|
||||||
|
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
|
||||||
|
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
|
||||||
|
return instance
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Decoder for [Order]
|
||||||
|
Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in
|
||||||
|
return Decoders.decode(clazz: [Order].self, source: source)
|
||||||
|
}
|
||||||
|
// Decoder for Order
|
||||||
|
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
|
||||||
|
let sourceDictionary = source as! [NSObject:AnyObject]
|
||||||
|
let instance = Order()
|
||||||
|
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
|
||||||
|
instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"])
|
||||||
|
instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"])
|
||||||
|
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
|
||||||
|
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
|
||||||
|
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
|
||||||
|
return instance
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user