forked from loafle/openapi-generator-original
[Swift 4] add compatibility for unwrapRequired config option (#229)
* Added support for unwrapRequired in Swift 4 * Update petstore generators for Swift.
This commit is contained in:
parent
4664c07034
commit
5b5fe3cad9
@ -4,3 +4,4 @@
|
||||
./bin/swift4-petstore-promisekit.sh
|
||||
./bin/swift4-petstore-rxswift.sh
|
||||
./bin/swift4-petstore-objcCompatible.sh
|
||||
./bin/swift4-petstore-unwrapRequired.sh
|
||||
|
7
bin/swift4-petstore-unwrapRequired.json
Normal file
7
bin/swift4-petstore-unwrapRequired.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"podSummary": "PetstoreClient",
|
||||
"podHomepage": "https://github.com/openapitools/openapi-generator",
|
||||
"podAuthors": "",
|
||||
"projectName": "PetstoreClient",
|
||||
"unwrapRequired": true
|
||||
}
|
32
bin/swift4-petstore-unwrapRequired.sh
Executable file
32
bin/swift4-petstore-unwrapRequired.sh
Executable file
@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift4 -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g swift4 -c ./bin/swift4-petstore-unwrapRequired.json -o samples/client/petstore/swift4/unwrapRequired $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -9,11 +9,11 @@ public struct {{classname}}: Codable {
|
||||
{{#allVars}}
|
||||
{{#isEnum}}
|
||||
{{#description}}/** {{description}} */
|
||||
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||
{{/description}}public var {{name}}: {{{datatypeWithEnum}}}{{#unwrapRequired}}?{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}
|
||||
{{/isEnum}}
|
||||
{{^isEnum}}
|
||||
{{#description}}/** {{description}} */
|
||||
{{/description}}public var {{name}}: {{{dataType}}}{{^required}}?{{/required}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#objcCompatible}}{{#vendorExtensions.x-swift-optional-scalar}}
|
||||
{{/description}}public var {{name}}: {{{datatype}}}{{#unwrapRequired}}?{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#objcCompatible}}{{#vendorExtensions.x-swift-optional-scalar}}
|
||||
public var {{name}}Num: NSNumber? {
|
||||
get {
|
||||
return {{name}}.map({ return NSNumber(value: $0) })
|
||||
@ -23,7 +23,7 @@ public struct {{classname}}: Codable {
|
||||
{{/allVars}}
|
||||
|
||||
{{#hasVars}}
|
||||
public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{^required}}?{{/required}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
|
||||
public init({{#allVars}}{{name}}: {{{datatypeWithEnum}}}{{#unwrapRequired}}?{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}?{{/required}}{{/unwrapRequired}}{{#hasMore}}, {{/hasMore}}{{/allVars}}) {
|
||||
{{#allVars}}
|
||||
self.{{name}} = {{name}}
|
||||
{{/allVars}}
|
||||
@ -52,7 +52,7 @@ public struct {{classname}}: Codable {
|
||||
var container = encoder.container(keyedBy: String.self)
|
||||
|
||||
{{#allVars}}
|
||||
try container.encode{{^required}}IfPresent{{/required}}({{{name}}}, forKey: "{{{baseName}}}")
|
||||
try container.encode{{#unwrapRequired}}IfPresent{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}IfPresent{{/required}}{{/unwrapRequired}}({{{name}}}, forKey: "{{{baseName}}}")
|
||||
{{/allVars}}
|
||||
try container.encodeMap(additionalProperties)
|
||||
}
|
||||
@ -63,7 +63,7 @@ public struct {{classname}}: Codable {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
{{#allVars}}
|
||||
{{name}} = try container.decode{{^required}}IfPresent{{/required}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}")
|
||||
{{name}} = try container.decode{{#unwrapRequired}}IfPresent{{/unwrapRequired}}{{^unwrapRequired}}{{^required}}IfPresent{{/required}}{{/unwrapRequired}}({{{datatypeWithEnum}}}.self, forKey: "{{{baseName}}}")
|
||||
{{/allVars}}
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
{{#allVars}}
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -26,9 +26,6 @@ open class AnotherFakeAPI: APIBase {
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -24,7 +24,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
@ -54,7 +53,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- examples: [{contentType=*/*, example={ }}]
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
@ -84,7 +82,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
@ -114,7 +111,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
@ -146,9 +142,6 @@ open class FakeAPI: APIBase {
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -28,9 +28,6 @@ open class FakeClassnameTags123API: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -113,58 +113,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -202,58 +150,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -291,58 +187,6 @@ open class PetAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
@ -460,11 +304,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}}]
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
|
@ -92,36 +92,6 @@ open class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
@ -155,36 +125,6 @@ open class StoreAPI: APIBase {
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
|
@ -150,44 +150,6 @@ open class UserAPI: APIBase {
|
||||
/**
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -43,9 +43,6 @@ open class AnotherFakeAPI: APIBase {
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -40,7 +40,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
@ -85,7 +84,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- examples: [{contentType=*/*, example={ }}]
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
@ -130,7 +128,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
@ -175,7 +172,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
@ -223,9 +219,6 @@ open class FakeAPI: APIBase {
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -45,9 +45,6 @@ open class FakeClassnameTags123API: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -163,58 +163,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -268,58 +216,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -373,58 +269,6 @@ open class PetAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
@ -594,11 +438,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}}]
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
|
@ -140,36 +140,6 @@ open class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
@ -219,36 +189,6 @@ open class StoreAPI: APIBase {
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
|
@ -231,44 +231,6 @@ open class UserAPI: APIBase {
|
||||
/**
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -45,9 +45,6 @@ open class AnotherFakeAPI: APIBase {
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -42,7 +42,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
@ -89,7 +88,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- examples: [{contentType=*/*, example={ }}]
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
@ -136,7 +134,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
@ -183,7 +180,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
@ -233,9 +229,6 @@ open class FakeAPI: APIBase {
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -47,9 +47,6 @@ open class FakeClassnameTags123API: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -169,58 +169,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -276,58 +224,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -383,58 +279,6 @@ open class PetAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
@ -610,11 +454,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}}]
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
|
@ -146,36 +146,6 @@ open class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
@ -227,36 +197,6 @@ open class StoreAPI: APIBase {
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
|
@ -241,44 +241,6 @@ open class UserAPI: APIBase {
|
||||
/**
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -26,9 +26,6 @@ open class AnotherFakeAPI: APIBase {
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -24,7 +24,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
@ -54,7 +53,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- examples: [{contentType=*/*, example={ }}]
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
@ -84,7 +82,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
@ -114,7 +111,6 @@ open class FakeAPI: APIBase {
|
||||
/**
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- examples: [{contentType=*/*, example=null}]
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
@ -146,9 +142,6 @@ open class FakeAPI: APIBase {
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -28,9 +28,6 @@ open class FakeClassnameTags123API: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- examples: [{contentType=application/json, example={
|
||||
"client" : "client"
|
||||
}}]
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
|
@ -113,58 +113,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -202,58 +150,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
@ -291,58 +187,6 @@ open class PetAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>}]
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
@ -460,11 +304,6 @@ open class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{contentType=application/json, example={
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
}}]
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
|
@ -92,36 +92,6 @@ open class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
@ -155,36 +125,6 @@ open class StoreAPI: APIBase {
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>}]
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
|
@ -150,44 +150,6 @@ open class UserAPI: APIBase {
|
||||
/**
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>}]
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
|
@ -1 +1 @@
|
||||
3.0.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -4,10 +4,10 @@ Pod::Spec.new do |s|
|
||||
s.osx.deployment_target = '10.11'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
s.version = '0.0.1'
|
||||
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||
s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' }
|
||||
s.authors = ''
|
||||
s.license = 'Proprietary'
|
||||
s.homepage = 'https://github.com/swagger-api/swagger-codegen'
|
||||
s.homepage = 'https://github.com/openapitools/openapi-generator'
|
||||
s.summary = 'PetstoreClient'
|
||||
s.source_files = 'PetstoreClient/Classes/**/*.swift'
|
||||
s.dependency 'Alamofire', '~> 4.5.0'
|
||||
|
@ -0,0 +1,65 @@
|
||||
// APIHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct APIHelper {
|
||||
public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
|
||||
let destination = source.reduce(into: [String: Any]()) { (result, item) in
|
||||
if let value = item.value {
|
||||
result[item.key] = value
|
||||
}
|
||||
}
|
||||
|
||||
if destination.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
|
||||
return source.reduce(into: [String: String]()) { (result, item) in
|
||||
if let collection = item.value as? Array<Any?> {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map{ "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
|
||||
guard let source = source else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return source.reduce(into: [String: Any](), { (result, item) in
|
||||
switch item.value {
|
||||
case let x as Bool:
|
||||
result[item.key] = x.description
|
||||
default:
|
||||
result[item.key] = item.value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
public static func mapValuesToQueryItems(_ source: [String:Any?]) -> [URLQueryItem]? {
|
||||
let destination = source.filter({ $0.value != nil}).reduce(into: [URLQueryItem]()) { (result, item) in
|
||||
if let collection = item.value as? Array<Any?> {
|
||||
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
} else if let value = item.value {
|
||||
result.append(URLQueryItem(name: item.key, value: "\(value)"))
|
||||
}
|
||||
}
|
||||
|
||||
if destination.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return destination
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
// APIs.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class PetstoreClientAPI {
|
||||
open static var basePath = "http://petstore.swagger.io:80/v2"
|
||||
open static var credential: URLCredential?
|
||||
open static var customHeaders: [String:String] = [:]
|
||||
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||
}
|
||||
|
||||
open class RequestBuilder<T> {
|
||||
var credential: URLCredential?
|
||||
var headers: [String:String]
|
||||
public let parameters: [String:Any]?
|
||||
public let isBody: Bool
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
public var onProgressReady: ((Progress) -> ())?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
self.isBody = isBody
|
||||
self.headers = headers
|
||||
|
||||
addHeaders(PetstoreClientAPI.customHeaders)
|
||||
}
|
||||
|
||||
open func addHeaders(_ aHeaders:[String:String]) {
|
||||
for (header, value) in aHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
}
|
||||
|
||||
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) { }
|
||||
|
||||
public func addHeader(name: String, value: String) -> Self {
|
||||
if !value.isEmpty {
|
||||
headers[name] = value
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
open func addCredential() -> Self {
|
||||
self.credential = PetstoreClientAPI.credential
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
public protocol RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
//
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
- parameter client: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testSpecialTags(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testSpecialTagsWithRequestBuilder(client: client).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testSpecialTagsWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
|
||||
let path = "/another-fake/dummy"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: client)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,499 @@
|
||||
//
|
||||
// FakeAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeAPI {
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?,_ error: Error?) -> Void)) {
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: Bool? = nil) -> RequestBuilder<Bool> {
|
||||
let path = "/fake/outer/boolean"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Bool>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize(outerComposite: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) {
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: outerComposite).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
|
||||
let path = "/fake/outer/composite"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: outerComposite)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?,_ error: Error?) -> Void)) {
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
open class func fakeOuterNumberSerializeWithRequestBuilder(body: Double? = nil) -> RequestBuilder<Double> {
|
||||
let path = "/fake/outer/number"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Double>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
open class func fakeOuterStringSerializeWithRequestBuilder(body: String? = nil) -> RequestBuilder<String> {
|
||||
let path = "/fake/outer/string"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter query: (query)
|
||||
- parameter user: (body)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithQueryParams(query: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
- PUT /fake/body-with-query-params
|
||||
- parameter query: (query)
|
||||
- parameter user: (body)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testBodyWithQueryParamsWithRequestBuilder(query: String, user: User) -> RequestBuilder<Void> {
|
||||
let path = "/fake/body-with-query-params"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"query": query
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
|
||||
- parameter client: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClientModel(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testClientModelWithRequestBuilder(client: client).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClientModelWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: client)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
- parameter number: (form) None
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
- POST /fake
|
||||
- Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
- BASIC:
|
||||
- type: http
|
||||
- name: http_basic_test
|
||||
- parameter number: (form) None
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"integer": integer?.encodeToJSON(),
|
||||
"int32": int32?.encodeToJSON(),
|
||||
"int64": int64?.encodeToJSON(),
|
||||
"number": number,
|
||||
"float": float,
|
||||
"double": double,
|
||||
"string": string,
|
||||
"pattern_without_delimiter": patternWithoutDelimiter,
|
||||
"byte": byte,
|
||||
"binary": binary,
|
||||
"date": date?.encodeToJSON(),
|
||||
"dateTime": dateTime?.encodeToJSON(),
|
||||
"password": password,
|
||||
"callback": callback
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumHeaderStringArray
|
||||
*/
|
||||
public enum EnumHeaderStringArray_testEnumParameters: String {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumHeaderString
|
||||
*/
|
||||
public enum EnumHeaderString_testEnumParameters: String {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryStringArray
|
||||
*/
|
||||
public enum EnumQueryStringArray_testEnumParameters: String {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryString
|
||||
*/
|
||||
public enum EnumQueryString_testEnumParameters: String {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryInteger
|
||||
*/
|
||||
public enum EnumQueryInteger_testEnumParameters: Int {
|
||||
case _1 = 1
|
||||
case number2 = -2
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryDouble
|
||||
*/
|
||||
public enum EnumQueryDouble_testEnumParameters: Double {
|
||||
case _11 = 1.1
|
||||
case number12 = -1.2
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumFormStringArray
|
||||
*/
|
||||
public enum EnumFormStringArray_testEnumParameters: String {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumFormString
|
||||
*/
|
||||
public enum EnumFormString_testEnumParameters: String {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
To test enum parameters
|
||||
|
||||
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
To test enum parameters
|
||||
- GET /fake
|
||||
- To test enum parameters
|
||||
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"enum_form_string_array": enumFormStringArray,
|
||||
"enum_form_string": enumFormString?.rawValue
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": enumQueryStringArray,
|
||||
"enum_query_string": enumQueryString?.rawValue,
|
||||
"enum_query_integer": enumQueryInteger?.rawValue,
|
||||
"enum_query_double": enumQueryDouble?.rawValue
|
||||
])
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"enum_header_string_array": enumHeaderStringArray,
|
||||
"enum_header_string": enumHeaderString?.rawValue
|
||||
]
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
|
||||
- parameter requestBody: (body) request body
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testInlineAdditionalProperties(requestBody: [String:String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(requestBody: requestBody).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
- POST /fake/inline-additionalProperties
|
||||
- parameter requestBody: (body) request body
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(requestBody: [String:String]) -> RequestBuilder<Void> {
|
||||
let path = "/fake/inline-additionalProperties"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: requestBody)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
- GET /fake/jsonFormData
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
|
||||
let path = "/fake/jsonFormData"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"param": param,
|
||||
"param2": param2
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
//
|
||||
// FakeClassnameTags123API.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeClassnameTags123API {
|
||||
/**
|
||||
To test class name in snake case
|
||||
|
||||
- parameter client: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClassname(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testClassnameWithRequestBuilder(client: client).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
To test class name in snake case
|
||||
- PATCH /fake_classname_test
|
||||
- To test class name in snake case
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClassnameWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake_classname_test"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: client)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,358 @@
|
||||
//
|
||||
// PetAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class PetAPI {
|
||||
/**
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func addPet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Add a new pet to the store
|
||||
- POST /pet
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func addPetWithRequestBuilder(pet: Pet) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: pet)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes a pet
|
||||
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Deletes a pet
|
||||
- DELETE /pet/{petId}
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
|
||||
var path = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"api_key": apiKey
|
||||
]
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter status
|
||||
*/
|
||||
public enum Status_findPetsByStatus: String {
|
||||
case available = "available"
|
||||
case pending = "pending"
|
||||
case sold = "sold"
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by status
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Finds Pets by status
|
||||
- GET /pet/findByStatus
|
||||
- Multiple status values can be provided with comma separated strings
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByStatus"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": status
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
- GET /pet/findByTags
|
||||
- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByTags"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": tags
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) {
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
- GET /pet/{petId}
|
||||
- Returns a single pet
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
|
||||
var path = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
- PUT /pet
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithRequestBuilder(pet: Pet) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: pet)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Updates a pet in the store with form data
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Updates a pet in the store with form data
|
||||
- POST /pet/{petId}
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
|
||||
var path = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"name": name,
|
||||
"status": status
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
uploads an image
|
||||
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
uploads an image
|
||||
- POST /pet/{petId}/uploadImage
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
|
||||
var path = "/pet/{petId}/uploadImage"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"additionalMetadata": additionalMetadata,
|
||||
"file": file
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
//
|
||||
// StoreAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class StoreAPI {
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
- DELETE /store/order/{order_id}
|
||||
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
|
||||
var path = "/store/order/{order_id}"
|
||||
let orderIdPreEscape = "\(orderId)"
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getInventory(completion: @escaping ((_ data: [String:Int]?,_ error: Error?) -> Void)) {
|
||||
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
- GET /store/inventory
|
||||
- Returns a map of status codes to quantities
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- returns: RequestBuilder<[String:Int]>
|
||||
*/
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
|
||||
let path = "/store/inventory"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
|
||||
var path = "/store/order/{order_id}"
|
||||
let orderIdPreEscape = "\(orderId)"
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func placeOrder(order: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
placeOrderWithRequestBuilder(order: order).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func placeOrderWithRequestBuilder(order: Order) -> RequestBuilder<Order> {
|
||||
let path = "/store/order"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: order)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,305 @@
|
||||
//
|
||||
// UserAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class UserAPI {
|
||||
/**
|
||||
Create user
|
||||
|
||||
- parameter user: (body) Created user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUser(user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUserWithRequestBuilder(user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create user
|
||||
- POST /user
|
||||
- This can only be done by the logged in user.
|
||||
- parameter user: (body) Created user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUserWithRequestBuilder(user: User) -> RequestBuilder<Void> {
|
||||
let path = "/user"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter user: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithArrayInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUsersWithArrayInputWithRequestBuilder(user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithArray
|
||||
- parameter user: (body) List of user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithArrayInputWithRequestBuilder(user: [User]) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithArray"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter user: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithListInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUsersWithListInputWithRequestBuilder(user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithList
|
||||
- parameter user: (body) List of user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithListInputWithRequestBuilder(user: [User]) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithList"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteUser(username: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Delete user
|
||||
- DELETE /user/{username}
|
||||
- This can only be done by the logged in user.
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(username)"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getUserByName(username: String, completion: @escaping ((_ data: User?,_ error: Error?) -> Void)) {
|
||||
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(username)"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs user into the system
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Logs user into the system
|
||||
- GET /user/login
|
||||
- responseHeaders: [X-Rate-Limit(Int), X-Expires-After(Date)]
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder<String> {
|
||||
let path = "/user/login"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"username": username,
|
||||
"password": password
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func logoutUser(completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
- GET /user/logout
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||
let path = "/user/logout"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Updated user
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter user: (body) Updated user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updateUser(username: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updateUserWithRequestBuilder(username: username, user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Updated user
|
||||
- PUT /user/{username}
|
||||
- This can only be done by the logged in user.
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter user: (body) Updated user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updateUserWithRequestBuilder(username: String, user: User) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(username)"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,413 @@
|
||||
// AlamofireImplementations.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
return AlamofireRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type {
|
||||
return AlamofireDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
|
||||
// Store manager to retain its reference
|
||||
private var managerStore: [String: Alamofire.SessionManager] = [:]
|
||||
|
||||
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the session
|
||||
configuration.
|
||||
*/
|
||||
open func createSessionManager() -> Alamofire.SessionManager {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
configuration.httpAdditionalHeaders = buildHeaders()
|
||||
return Alamofire.SessionManager(configuration: configuration)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the Content-Type
|
||||
that is given to an uploaded form part.
|
||||
|
||||
Return nil to use the default behavior (inferring the Content-Type from
|
||||
the file extension). Return the desired Content-Type otherwise.
|
||||
*/
|
||||
open func contentTypeForFormPart(fileURL: URL) -> String? {
|
||||
return nil
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the request
|
||||
configuration (e.g. to override the cache policy).
|
||||
*/
|
||||
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest {
|
||||
return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers)
|
||||
}
|
||||
|
||||
override open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
let managerId:String = UUID().uuidString
|
||||
// Create a new manager for each request to customize its request header
|
||||
let manager = createSessionManager()
|
||||
managerStore[managerId] = manager
|
||||
|
||||
let encoding:ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
|
||||
|
||||
let xMethod = Alamofire.HTTPMethod(rawValue: method)
|
||||
let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL }
|
||||
.map { $0.0 }
|
||||
|
||||
if fileKeys.count > 0 {
|
||||
manager.upload(multipartFormData: { mpForm in
|
||||
for (k, v) in self.parameters! {
|
||||
switch v {
|
||||
case let fileURL as URL:
|
||||
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
|
||||
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
|
||||
}
|
||||
else {
|
||||
mpForm.append(fileURL, withName: k)
|
||||
}
|
||||
case let string as String:
|
||||
mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k)
|
||||
case let number as NSNumber:
|
||||
mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k)
|
||||
default:
|
||||
fatalError("Unprocessable value \(v) with key \(k)")
|
||||
}
|
||||
}
|
||||
}, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in
|
||||
switch encodingResult {
|
||||
case .success(let upload, _, _):
|
||||
if let onProgressReady = self.onProgressReady {
|
||||
onProgressReady(upload.uploadProgress)
|
||||
}
|
||||
self.processRequest(request: upload, managerId, completion)
|
||||
case .failure(let encodingError):
|
||||
completion(nil, ErrorResponse.error(415, nil, encodingError))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let request = makeRequest(manager: manager, method: xMethod!, encoding: encoding, headers: headers)
|
||||
if let onProgressReady = self.onProgressReady {
|
||||
onProgressReady(request.progress)
|
||||
}
|
||||
processRequest(request: request, managerId, completion)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
if let credential = self.credential {
|
||||
request.authenticate(usingCredential: credential)
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
_ = managerStore.removeValue(forKey: managerId)
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
||||
switch T.self {
|
||||
case is String.Type:
|
||||
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if stringResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: stringResponse.response!,
|
||||
body: ((stringResponse.result.value ?? "") as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
case is URL.Type:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
do {
|
||||
|
||||
guard !dataResponse.result.isFailure else {
|
||||
throw DownloadException.responseFailed
|
||||
}
|
||||
|
||||
guard let data = dataResponse.data else {
|
||||
throw DownloadException.responseDataMissing
|
||||
}
|
||||
|
||||
guard let request = request.request else {
|
||||
throw DownloadException.requestMissing
|
||||
}
|
||||
|
||||
let fileManager = FileManager.default
|
||||
let urlRequest = try request.asURLRequest()
|
||||
let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
let requestURL = try self.getURL(from: urlRequest)
|
||||
|
||||
var requestPath = try self.getPath(from: requestURL)
|
||||
|
||||
if let headerFileName = self.getFileName(fromContentDisposition: dataResponse.response?.allHeaderFields["Content-Disposition"] as? String) {
|
||||
requestPath = requestPath.appending("/\(headerFileName)")
|
||||
}
|
||||
|
||||
let filePath = documentsDirectory.appendingPathComponent(requestPath)
|
||||
let directoryPath = filePath.deletingLastPathComponent().path
|
||||
|
||||
try fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: true, attributes: nil)
|
||||
try data.write(to: filePath, options: .atomic)
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: dataResponse.response!,
|
||||
body: (filePath as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
|
||||
} catch let requestParserError as DownloadException {
|
||||
completion(nil, ErrorResponse.error(400, dataResponse.data, requestParserError))
|
||||
} catch let error {
|
||||
completion(nil, ErrorResponse.error(400, dataResponse.data, error))
|
||||
}
|
||||
return
|
||||
})
|
||||
case is Void.Type:
|
||||
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if voidResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(voidResponse.response?.statusCode ?? 500, voidResponse.data, voidResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: voidResponse.response!,
|
||||
body: nil),
|
||||
nil
|
||||
)
|
||||
})
|
||||
default:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if dataResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: dataResponse.response!,
|
||||
body: (dataResponse.data as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
open func buildHeaders() -> [String: String] {
|
||||
var httpHeaders = SessionManager.defaultHTTPHeaders
|
||||
for (key, value) in self.headers {
|
||||
httpHeaders[key] = value
|
||||
}
|
||||
return httpHeaders
|
||||
}
|
||||
|
||||
fileprivate func getFileName(fromContentDisposition contentDisposition : String?) -> String? {
|
||||
|
||||
guard let contentDisposition = contentDisposition else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let items = contentDisposition.components(separatedBy: ";")
|
||||
|
||||
var filename : String? = nil
|
||||
|
||||
for contentItem in items {
|
||||
|
||||
let filenameKey = "filename="
|
||||
guard let range = contentItem.range(of: filenameKey) else {
|
||||
break
|
||||
}
|
||||
|
||||
filename = contentItem
|
||||
return filename?
|
||||
.replacingCharacters(in: range, with:"")
|
||||
.replacingOccurrences(of: "\"", with: "")
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
return filename
|
||||
|
||||
}
|
||||
|
||||
fileprivate func getPath(from url : URL) throws -> String {
|
||||
|
||||
guard var path = URLComponents(url: url, resolvingAgainstBaseURL: true)?.path else {
|
||||
throw DownloadException.requestMissingPath
|
||||
}
|
||||
|
||||
if path.hasPrefix("/") {
|
||||
path.remove(at: path.startIndex)
|
||||
}
|
||||
|
||||
return path
|
||||
|
||||
}
|
||||
|
||||
fileprivate func getURL(from urlRequest : URLRequest) throws -> URL {
|
||||
|
||||
guard let url = urlRequest.url else {
|
||||
throw DownloadException.requestMissingURL
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileprivate enum DownloadException : Error {
|
||||
case responseDataMissing
|
||||
case responseFailed
|
||||
case requestMissing
|
||||
case requestMissingPath
|
||||
case requestMissingURL
|
||||
}
|
||||
|
||||
public enum AlamofireDecodableRequestBuilderError: Error {
|
||||
case emptyDataResponse
|
||||
case nilHTTPResponse
|
||||
case jsonDecoding(DecodingError)
|
||||
case generalError(Error)
|
||||
}
|
||||
|
||||
open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilder<T> {
|
||||
|
||||
override fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
if let credential = self.credential {
|
||||
request.authenticate(usingCredential: credential)
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
_ = managerStore.removeValue(forKey: managerId)
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
||||
switch T.self {
|
||||
case is String.Type:
|
||||
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if stringResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: stringResponse.response!,
|
||||
body: ((stringResponse.result.value ?? "") as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
case is Void.Type:
|
||||
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if voidResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(voidResponse.response?.statusCode ?? 500, voidResponse.data, voidResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: voidResponse.response!,
|
||||
body: nil),
|
||||
nil
|
||||
)
|
||||
})
|
||||
case is Data.Type:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if dataResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: dataResponse.response!,
|
||||
body: (dataResponse.data as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
default:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse: DataResponse<Data>) in
|
||||
cleanupRequest()
|
||||
|
||||
guard dataResponse.result.isSuccess else {
|
||||
completion(nil, ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!))
|
||||
return
|
||||
}
|
||||
|
||||
guard let data = dataResponse.data, !data.isEmpty else {
|
||||
completion(nil, ErrorResponse.error(-1, nil, AlamofireDecodableRequestBuilderError.emptyDataResponse))
|
||||
return
|
||||
}
|
||||
|
||||
guard let httpResponse = dataResponse.response else {
|
||||
completion(nil, ErrorResponse.error(-2, nil, AlamofireDecodableRequestBuilderError.nilHTTPResponse))
|
||||
return
|
||||
}
|
||||
|
||||
var responseObj: Response<T>? = nil
|
||||
|
||||
let decodeResult: (decodableObj: T?, error: Error?) = CodableHelper.decode(T.self, from: data)
|
||||
if decodeResult.error == nil {
|
||||
responseObj = Response(response: httpResponse, body: decodeResult.decodableObj)
|
||||
}
|
||||
|
||||
completion(responseObj, decodeResult.error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
//
|
||||
// CodableHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public typealias EncodeResult = (data: Data?, error: Error?)
|
||||
|
||||
open class CodableHelper {
|
||||
|
||||
open static var dateformatter: DateFormatter?
|
||||
|
||||
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
|
||||
var returnedDecodable: T? = nil
|
||||
var returnedError: Error? = nil
|
||||
|
||||
let decoder = JSONDecoder()
|
||||
if let df = self.dateformatter {
|
||||
decoder.dateDecodingStrategy = .formatted(df)
|
||||
} else {
|
||||
decoder.dataDecodingStrategy = .base64
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar(identifier: .iso8601)
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
|
||||
decoder.dateDecodingStrategy = .formatted(formatter)
|
||||
}
|
||||
|
||||
do {
|
||||
returnedDecodable = try decoder.decode(type, from: data)
|
||||
} catch {
|
||||
returnedError = error
|
||||
}
|
||||
|
||||
return (returnedDecodable, returnedError)
|
||||
}
|
||||
|
||||
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T : Encodable {
|
||||
var returnedData: Data?
|
||||
var returnedError: Error? = nil
|
||||
|
||||
let encoder = JSONEncoder()
|
||||
if prettyPrint {
|
||||
encoder.outputFormatting = .prettyPrinted
|
||||
}
|
||||
encoder.dataEncodingStrategy = .base64
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar(identifier: .iso8601)
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
|
||||
encoder.dateEncodingStrategy = .formatted(formatter)
|
||||
|
||||
do {
|
||||
returnedData = try encoder.encode(value)
|
||||
} catch {
|
||||
returnedError = error
|
||||
}
|
||||
|
||||
return (returnedData, returnedError)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Configuration.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class Configuration {
|
||||
|
||||
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
|
||||
// You must set it prior to encoding any dates, and it will only be read once.
|
||||
open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
// Extensions.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
extension Bool: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension Float: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension Int: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension Int32: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return NSNumber(value: self as Int32) }
|
||||
}
|
||||
|
||||
extension Int64: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return NSNumber(value: self as Int64) }
|
||||
}
|
||||
|
||||
extension Double: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension String: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
private func encodeIfPossible<T>(_ object: T) -> Any {
|
||||
if let encodableObject = object as? JSONEncodable {
|
||||
return encodableObject.encodeToJSON()
|
||||
} else {
|
||||
return object as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension Array: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.map(encodeIfPossible)
|
||||
}
|
||||
}
|
||||
|
||||
extension Dictionary: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
var dictionary = [AnyHashable: Any]()
|
||||
for (key, value) in self {
|
||||
dictionary[key] = encodeIfPossible(value)
|
||||
}
|
||||
return dictionary as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension Data: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||
}
|
||||
}
|
||||
|
||||
private let dateFormatter: DateFormatter = {
|
||||
let fmt = DateFormatter()
|
||||
fmt.dateFormat = Configuration.dateFormat
|
||||
fmt.locale = Locale(identifier: "en_US_POSIX")
|
||||
return fmt
|
||||
}()
|
||||
|
||||
extension Date: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return dateFormatter.string(from: self) as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension UUID: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.uuidString
|
||||
}
|
||||
}
|
||||
|
||||
extension String: CodingKey {
|
||||
|
||||
public var stringValue: String {
|
||||
return self
|
||||
}
|
||||
|
||||
public init?(stringValue: String) {
|
||||
self.init(stringLiteral: stringValue)
|
||||
}
|
||||
|
||||
public var intValue: Int? {
|
||||
return nil
|
||||
}
|
||||
|
||||
public init?(intValue: Int) {
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension KeyedEncodingContainerProtocol {
|
||||
|
||||
public mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T : Encodable {
|
||||
var arrayContainer = nestedUnkeyedContainer(forKey: key)
|
||||
try arrayContainer.encode(contentsOf: values)
|
||||
}
|
||||
|
||||
public mutating func encodeArrayIfPresent<T>(_ values: [T]?, forKey key: Self.Key) throws where T : Encodable {
|
||||
if let values = values {
|
||||
try encodeArray(values, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encodeMap<T>(_ pairs: [Self.Key: T]) throws where T : Encodable {
|
||||
for (key, value) in pairs {
|
||||
try encode(value, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encodeMapIfPresent<T>(_ pairs: [Self.Key: T]?) throws where T : Encodable {
|
||||
if let pairs = pairs {
|
||||
try encodeMap(pairs)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension KeyedDecodingContainerProtocol {
|
||||
|
||||
public func decodeArray<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T : Decodable {
|
||||
var tmpArray = [T]()
|
||||
|
||||
var nestedContainer = try nestedUnkeyedContainer(forKey: key)
|
||||
while !nestedContainer.isAtEnd {
|
||||
let arrayValue = try nestedContainer.decode(T.self)
|
||||
tmpArray.append(arrayValue)
|
||||
}
|
||||
|
||||
return tmpArray
|
||||
}
|
||||
|
||||
public func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T : Decodable {
|
||||
var tmpArray: [T]? = nil
|
||||
|
||||
if contains(key) {
|
||||
tmpArray = try decodeArray(T.self, forKey: key)
|
||||
}
|
||||
|
||||
return tmpArray
|
||||
}
|
||||
|
||||
public func decodeMap<T>(_ type: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T : Decodable {
|
||||
var map: [Self.Key : T] = [:]
|
||||
|
||||
for key in allKeys {
|
||||
if !excludedKeys.contains(key) {
|
||||
let value = try decode(T.self, forKey: key)
|
||||
map[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,54 @@
|
||||
//
|
||||
// JSONDataEncoding.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
public struct JSONDataEncoding: ParameterEncoding {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private static let jsonDataKey = "jsonData"
|
||||
|
||||
// MARK: Encoding
|
||||
|
||||
/// Creates a URL request by encoding parameters and applying them onto an existing request.
|
||||
///
|
||||
/// - parameter urlRequest: The request to have parameters applied.
|
||||
/// - parameter parameters: The parameters to apply. This should have a single key/value
|
||||
/// pair with "jsonData" as the key and a Data object as the value.
|
||||
///
|
||||
/// - throws: An `Error` if the encoding process encounters an error.
|
||||
///
|
||||
/// - returns: The encoded request.
|
||||
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
|
||||
var urlRequest = try urlRequest.asURLRequest()
|
||||
|
||||
guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else {
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
|
||||
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
}
|
||||
|
||||
urlRequest.httpBody = jsonData
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
public static func encodingParameters(jsonData: Data?) -> Parameters? {
|
||||
var returnedParams: Parameters? = nil
|
||||
if let jsonData = jsonData, !jsonData.isEmpty {
|
||||
var params = Parameters()
|
||||
params[jsonDataKey] = jsonData
|
||||
returnedParams = params
|
||||
}
|
||||
return returnedParams
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
//
|
||||
// JSONEncodingHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
open class JSONEncodingHelper {
|
||||
|
||||
open class func encodingParameters<T:Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
|
||||
var params: Parameters? = nil
|
||||
|
||||
// Encode the Encodable object
|
||||
if let encodableObj = encodableObj {
|
||||
let encodeResult = CodableHelper.encode(encodableObj, prettyPrint: true)
|
||||
if encodeResult.error == nil {
|
||||
params = JSONDataEncoding.encodingParameters(jsonData: encodeResult.data)
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
open class func encodingParameters(forEncodableObject encodableObj: Any?) -> Parameters? {
|
||||
var params: Parameters? = nil
|
||||
|
||||
if let encodableObj = encodableObj {
|
||||
do {
|
||||
let data = try JSONSerialization.data(withJSONObject: encodableObj, options: .prettyPrinted)
|
||||
params = JSONDataEncoding.encodingParameters(jsonData: data)
|
||||
} catch {
|
||||
print(error)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
// Models.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol JSONEncodable {
|
||||
func encodeToJSON() -> Any
|
||||
}
|
||||
|
||||
public enum ErrorResponse : Error {
|
||||
case error(Int, Data?, Error)
|
||||
}
|
||||
|
||||
open class Response<T> {
|
||||
open let statusCode: Int
|
||||
open let header: [String: String]
|
||||
open let body: T?
|
||||
|
||||
public init(statusCode: Int, header: [String: String], body: T?) {
|
||||
self.statusCode = statusCode
|
||||
self.header = header
|
||||
self.body = body
|
||||
}
|
||||
|
||||
public convenience init(response: HTTPURLResponse, body: T?) {
|
||||
let rawHeader = response.allHeaderFields
|
||||
var header = [String:String]()
|
||||
for case let (key, value) as (String, String) in rawHeader {
|
||||
header[key] = value
|
||||
}
|
||||
self.init(statusCode: response.statusCode, header: header, body: body)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// AdditionalPropertiesClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct AdditionalPropertiesClass: Codable {
|
||||
|
||||
public var mapProperty: [String:String]?
|
||||
public var mapOfMapProperty: [String:[String:String]]?
|
||||
|
||||
public init(mapProperty: [String:String]?, mapOfMapProperty: [String:[String:String]]?) {
|
||||
self.mapProperty = mapProperty
|
||||
self.mapOfMapProperty = mapOfMapProperty
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapProperty = "map_property"
|
||||
case mapOfMapProperty = "map_of_map_property"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
//
|
||||
// Animal.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Animal: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String? = "red"
|
||||
|
||||
public init(className: String, color: String?) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
//
|
||||
// AnimalFarm.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public typealias AnimalFarm = [Animal]
|
@ -0,0 +1,31 @@
|
||||
//
|
||||
// ApiResponse.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ApiResponse: Codable {
|
||||
|
||||
public var code: Int?
|
||||
public var codeNum: NSNumber? {
|
||||
get {
|
||||
return code.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var type: String?
|
||||
public var message: String?
|
||||
|
||||
public init(code: Int?, type: String?, message: String?) {
|
||||
self.code = code
|
||||
self.type = type
|
||||
self.message = message
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// ArrayOfArrayOfNumberOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayArrayNumber: [[Double]]?
|
||||
|
||||
public init(arrayArrayNumber: [[Double]]?) {
|
||||
self.arrayArrayNumber = arrayArrayNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayArrayNumber = "ArrayArrayNumber"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// ArrayOfNumberOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayNumber: [Double]?
|
||||
|
||||
public init(arrayNumber: [Double]?) {
|
||||
self.arrayNumber = arrayNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayNumber = "ArrayNumber"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
//
|
||||
// ArrayTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ArrayTest: Codable {
|
||||
|
||||
public var arrayOfString: [String]?
|
||||
public var arrayArrayOfInteger: [[Int64]]?
|
||||
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||
|
||||
public init(arrayOfString: [String]?, arrayArrayOfInteger: [[Int64]]?, arrayArrayOfModel: [[ReadOnlyFirst]]?) {
|
||||
self.arrayOfString = arrayOfString
|
||||
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||
self.arrayArrayOfModel = arrayArrayOfModel
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayOfString = "array_of_string"
|
||||
case arrayArrayOfInteger = "array_array_of_integer"
|
||||
case arrayArrayOfModel = "array_array_of_model"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,42 @@
|
||||
//
|
||||
// Capitalization.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Capitalization: Codable {
|
||||
|
||||
public var smallCamel: String?
|
||||
public var capitalCamel: String?
|
||||
public var smallSnake: String?
|
||||
public var capitalSnake: String?
|
||||
public var sCAETHFlowPoints: String?
|
||||
/** Name of the pet */
|
||||
public var ATT_NAME: String?
|
||||
|
||||
public init(smallCamel: String?, capitalCamel: String?, smallSnake: String?, capitalSnake: String?, sCAETHFlowPoints: String?, ATT_NAME: String?) {
|
||||
self.smallCamel = smallCamel
|
||||
self.capitalCamel = capitalCamel
|
||||
self.smallSnake = smallSnake
|
||||
self.capitalSnake = capitalSnake
|
||||
self.sCAETHFlowPoints = sCAETHFlowPoints
|
||||
self.ATT_NAME = ATT_NAME
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case smallCamel
|
||||
case capitalCamel = "CapitalCamel"
|
||||
case smallSnake = "small_Snake"
|
||||
case capitalSnake = "Capital_Snake"
|
||||
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
|
||||
case ATT_NAME
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Cat.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Cat: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String? = "red"
|
||||
public var declawed: Bool?
|
||||
public var declawedNum: NSNumber? {
|
||||
get {
|
||||
return declawed.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(className: String, color: String?, declawed: Bool?) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
self.declawed = declawed
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Category.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Category: Codable {
|
||||
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var name: String?
|
||||
|
||||
public init(_id: Int64?, name: String?) {
|
||||
self._id = _id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
//
|
||||
// ClassModel.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing model with \"_class\" property */
|
||||
|
||||
public struct ClassModel: Codable {
|
||||
|
||||
public var _class: String?
|
||||
|
||||
public init(_class: String?) {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Client.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Client: Codable {
|
||||
|
||||
public var client: String?
|
||||
|
||||
public init(client: String?) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Dog.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Dog: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String? = "red"
|
||||
public var breed: String?
|
||||
|
||||
public init(className: String, color: String?, breed: String?) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
self.breed = breed
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// EnumArrays.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct EnumArrays: Codable {
|
||||
|
||||
public enum JustSymbol: String, Codable {
|
||||
case greaterThanOrEqualTo = ">="
|
||||
case dollar = "$"
|
||||
}
|
||||
public enum ArrayEnum: String, Codable {
|
||||
case fish = "fish"
|
||||
case crab = "crab"
|
||||
}
|
||||
public var justSymbol: JustSymbol?
|
||||
public var arrayEnum: [ArrayEnum]?
|
||||
|
||||
public init(justSymbol: JustSymbol?, arrayEnum: [ArrayEnum]?) {
|
||||
self.justSymbol = justSymbol
|
||||
self.arrayEnum = arrayEnum
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justSymbol = "just_symbol"
|
||||
case arrayEnum = "array_enum"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// EnumClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public enum EnumClass: String, Codable {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
//
|
||||
// EnumTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct EnumTest: Codable {
|
||||
|
||||
public enum EnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
case empty = ""
|
||||
}
|
||||
public enum EnumStringRequired: String, Codable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
case empty = ""
|
||||
}
|
||||
public enum EnumInteger: Int, Codable {
|
||||
case _1 = 1
|
||||
case number1 = -1
|
||||
}
|
||||
public enum EnumNumber: Double, Codable {
|
||||
case _11 = 1.1
|
||||
case number12 = -1.2
|
||||
}
|
||||
public var enumString: EnumString?
|
||||
public var enumStringRequired: EnumStringRequired
|
||||
public var enumInteger: EnumInteger?
|
||||
public var enumNumber: EnumNumber?
|
||||
public var outerEnum: OuterEnum?
|
||||
|
||||
public init(enumString: EnumString?, enumStringRequired: EnumStringRequired, enumInteger: EnumInteger?, enumNumber: EnumNumber?, outerEnum: OuterEnum?) {
|
||||
self.enumString = enumString
|
||||
self.enumStringRequired = enumStringRequired
|
||||
self.enumInteger = enumInteger
|
||||
self.enumNumber = enumNumber
|
||||
self.outerEnum = outerEnum
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case enumString = "enum_string"
|
||||
case enumStringRequired = "enum_string_required"
|
||||
case enumInteger = "enum_integer"
|
||||
case enumNumber = "enum_number"
|
||||
case outerEnum
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,76 @@
|
||||
//
|
||||
// FormatTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct FormatTest: Codable {
|
||||
|
||||
public var integer: Int?
|
||||
public var integerNum: NSNumber? {
|
||||
get {
|
||||
return integer.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var int32: Int?
|
||||
public var int32Num: NSNumber? {
|
||||
get {
|
||||
return int32.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var int64: Int64?
|
||||
public var int64Num: NSNumber? {
|
||||
get {
|
||||
return int64.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var number: Double
|
||||
public var numberNum: NSNumber? {
|
||||
get {
|
||||
return number.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var float: Float?
|
||||
public var floatNum: NSNumber? {
|
||||
get {
|
||||
return float.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var double: Double?
|
||||
public var doubleNum: NSNumber? {
|
||||
get {
|
||||
return double.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var string: String?
|
||||
public var byte: Data
|
||||
public var binary: URL?
|
||||
public var date: Date
|
||||
public var dateTime: Date?
|
||||
public var uuid: UUID?
|
||||
public var password: String
|
||||
|
||||
public init(integer: Int?, int32: Int?, int64: Int64?, number: Double, float: Float?, double: Double?, string: String?, byte: Data, binary: URL?, date: Date, dateTime: Date?, uuid: UUID?, password: String) {
|
||||
self.integer = integer
|
||||
self.int32 = int32
|
||||
self.int64 = int64
|
||||
self.number = number
|
||||
self.float = float
|
||||
self.double = double
|
||||
self.string = string
|
||||
self.byte = byte
|
||||
self.binary = binary
|
||||
self.date = date
|
||||
self.dateTime = dateTime
|
||||
self.uuid = uuid
|
||||
self.password = password
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
//
|
||||
// HasOnlyReadOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct HasOnlyReadOnly: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var foo: String?
|
||||
|
||||
public init(bar: String?, foo: String?) {
|
||||
self.bar = bar
|
||||
self.foo = foo
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// List.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct List: Codable {
|
||||
|
||||
public var _123list: String?
|
||||
|
||||
public init(_123list: String?) {
|
||||
self._123list = _123list
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _123list = "123-list"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// MapTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct MapTest: Codable {
|
||||
|
||||
public enum MapOfEnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
}
|
||||
public var mapMapOfString: [String:[String:String]]?
|
||||
public var mapOfEnumString: [String:String]?
|
||||
|
||||
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?) {
|
||||
self.mapMapOfString = mapMapOfString
|
||||
self.mapOfEnumString = mapOfEnumString
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapMapOfString = "map_map_of_string"
|
||||
case mapOfEnumString = "map_of_enum_string"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
//
|
||||
// MixedPropertiesAndAdditionalPropertiesClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
|
||||
public var uuid: UUID?
|
||||
public var dateTime: Date?
|
||||
public var map: [String:Animal]?
|
||||
|
||||
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
|
||||
self.uuid = uuid
|
||||
self.dateTime = dateTime
|
||||
self.map = map
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
//
|
||||
// Model200Response.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing model name starting with number */
|
||||
|
||||
public struct Model200Response: Codable {
|
||||
|
||||
public var name: Int?
|
||||
public var nameNum: NSNumber? {
|
||||
get {
|
||||
return name.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var _class: String?
|
||||
|
||||
public init(name: Int?, _class: String?) {
|
||||
self.name = name
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case _class = "class"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Name.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing model name same as property name */
|
||||
|
||||
public struct Name: Codable {
|
||||
|
||||
public var name: Int
|
||||
public var nameNum: NSNumber? {
|
||||
get {
|
||||
return name.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var snakeCase: Int?
|
||||
public var snakeCaseNum: NSNumber? {
|
||||
get {
|
||||
return snakeCase.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var property: String?
|
||||
public var _123number: Int?
|
||||
public var _123numberNum: NSNumber? {
|
||||
get {
|
||||
return _123number.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(name: Int, snakeCase: Int?, property: String?, _123number: Int?) {
|
||||
self.name = name
|
||||
self.snakeCase = snakeCase
|
||||
self.property = property
|
||||
self._123number = _123number
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case snakeCase = "snake_case"
|
||||
case property
|
||||
case _123number = "123Number"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
//
|
||||
// NumberOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct NumberOnly: Codable {
|
||||
|
||||
public var justNumber: Double?
|
||||
public var justNumberNum: NSNumber? {
|
||||
get {
|
||||
return justNumber.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(justNumber: Double?) {
|
||||
self.justNumber = justNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justNumber = "JustNumber"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
//
|
||||
// Order.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Order: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var petId: Int64?
|
||||
public var petIdNum: NSNumber? {
|
||||
get {
|
||||
return petId.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var quantity: Int?
|
||||
public var quantityNum: NSNumber? {
|
||||
get {
|
||||
return quantity.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var shipDate: Date?
|
||||
/** Order Status */
|
||||
public var status: Status?
|
||||
public var complete: Bool? = false
|
||||
public var completeNum: NSNumber? {
|
||||
get {
|
||||
return complete.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(_id: Int64?, petId: Int64?, quantity: Int?, shipDate: Date?, status: Status?, complete: Bool?) {
|
||||
self._id = _id
|
||||
self.petId = petId
|
||||
self.quantity = quantity
|
||||
self.shipDate = shipDate
|
||||
self.status = status
|
||||
self.complete = complete
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case petId
|
||||
case quantity
|
||||
case shipDate
|
||||
case status
|
||||
case complete
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
//
|
||||
// OuterComposite.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct OuterComposite: Codable {
|
||||
|
||||
public var myNumber: Double?
|
||||
public var myString: String?
|
||||
public var myBoolean: Bool?
|
||||
|
||||
public init(myNumber: Double?, myString: String?, myBoolean: Bool?) {
|
||||
self.myNumber = myNumber
|
||||
self.myString = myString
|
||||
self.myBoolean = myBoolean
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case myNumber = "my_number"
|
||||
case myString = "my_string"
|
||||
case myBoolean = "my_boolean"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// OuterEnum.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public enum OuterEnum: String, Codable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
//
|
||||
// Pet.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Pet: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
case available = "available"
|
||||
case pending = "pending"
|
||||
case sold = "sold"
|
||||
}
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var category: Category?
|
||||
public var name: String
|
||||
public var photoUrls: [String]
|
||||
public var tags: [Tag]?
|
||||
/** pet status in the store */
|
||||
public var status: Status?
|
||||
|
||||
public init(_id: Int64?, category: Category?, name: String, photoUrls: [String], tags: [Tag]?, status: Status?) {
|
||||
self._id = _id
|
||||
self.category = category
|
||||
self.name = name
|
||||
self.photoUrls = photoUrls
|
||||
self.tags = tags
|
||||
self.status = status
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case category
|
||||
case name
|
||||
case photoUrls
|
||||
case tags
|
||||
case status
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
//
|
||||
// ReadOnlyFirst.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ReadOnlyFirst: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var baz: String?
|
||||
|
||||
public init(bar: String?, baz: String?) {
|
||||
self.bar = bar
|
||||
self.baz = baz
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Return.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing reserved words */
|
||||
|
||||
public struct Return: Codable {
|
||||
|
||||
public var _return: Int?
|
||||
public var _returnNum: NSNumber? {
|
||||
get {
|
||||
return _return.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(_return: Int?) {
|
||||
self._return = _return
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _return = "return"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
//
|
||||
// SpecialModelName.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct SpecialModelName: Codable {
|
||||
|
||||
public var specialPropertyName: Int64?
|
||||
public var specialPropertyNameNum: NSNumber? {
|
||||
get {
|
||||
return specialPropertyName.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(specialPropertyName: Int64?) {
|
||||
self.specialPropertyName = specialPropertyName
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case specialPropertyName = "$special[property.name]"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Tag.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Tag: Codable {
|
||||
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var name: String?
|
||||
|
||||
public init(_id: Int64?, name: String?) {
|
||||
self._id = _id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case name
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
//
|
||||
// User.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct User: Codable {
|
||||
|
||||
public var _id: Int64?
|
||||
public var _idNum: NSNumber? {
|
||||
get {
|
||||
return _id.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
public var username: String?
|
||||
public var firstName: String?
|
||||
public var lastName: String?
|
||||
public var email: String?
|
||||
public var password: String?
|
||||
public var phone: String?
|
||||
/** User Status */
|
||||
public var userStatus: Int?
|
||||
public var userStatusNum: NSNumber? {
|
||||
get {
|
||||
return userStatus.map({ return NSNumber(value: $0) })
|
||||
}
|
||||
}
|
||||
|
||||
public init(_id: Int64?, username: String?, firstName: String?, lastName: String?, email: String?, password: String?, phone: String?, userStatus: Int?) {
|
||||
self._id = _id
|
||||
self.username = username
|
||||
self.firstName = firstName
|
||||
self.lastName = lastName
|
||||
self.email = email
|
||||
self.password = password
|
||||
self.phone = phone
|
||||
self.userStatus = userStatus
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _id = "id"
|
||||
case username
|
||||
case firstName
|
||||
case lastName
|
||||
case email
|
||||
case password
|
||||
case phone
|
||||
case userStatus
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
|
@ -1 +1 @@
|
||||
2.4.0-SNAPSHOT
|
||||
3.0.1-SNAPSHOT
|
@ -4,10 +4,10 @@ Pod::Spec.new do |s|
|
||||
s.osx.deployment_target = '10.11'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
s.version = '0.0.1'
|
||||
s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }
|
||||
s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' }
|
||||
s.authors = ''
|
||||
s.license = 'Proprietary'
|
||||
s.homepage = 'https://github.com/swagger-api/swagger-codegen'
|
||||
s.homepage = 'https://github.com/openapitools/openapi-generator'
|
||||
s.summary = 'PetstoreClient'
|
||||
s.source_files = 'PetstoreClient/Classes/**/*.swift'
|
||||
s.dependency 'PromiseKit/CorePromise', '~> 4.4.0'
|
||||
|
@ -0,0 +1,65 @@
|
||||
// APIHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct APIHelper {
|
||||
public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
|
||||
let destination = source.reduce(into: [String: Any]()) { (result, item) in
|
||||
if let value = item.value {
|
||||
result[item.key] = value
|
||||
}
|
||||
}
|
||||
|
||||
if destination.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
|
||||
return source.reduce(into: [String: String]()) { (result, item) in
|
||||
if let collection = item.value as? Array<Any?> {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map{ "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
|
||||
guard let source = source else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return source.reduce(into: [String: Any](), { (result, item) in
|
||||
switch item.value {
|
||||
case let x as Bool:
|
||||
result[item.key] = x.description
|
||||
default:
|
||||
result[item.key] = item.value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
public static func mapValuesToQueryItems(_ source: [String:Any?]) -> [URLQueryItem]? {
|
||||
let destination = source.filter({ $0.value != nil}).reduce(into: [URLQueryItem]()) { (result, item) in
|
||||
if let collection = item.value as? Array<Any?> {
|
||||
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
} else if let value = item.value {
|
||||
result.append(URLQueryItem(name: item.key, value: "\(value)"))
|
||||
}
|
||||
}
|
||||
|
||||
if destination.isEmpty {
|
||||
return nil
|
||||
}
|
||||
return destination
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
// APIs.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class PetstoreClientAPI {
|
||||
open static var basePath = "http://petstore.swagger.io:80/v2"
|
||||
open static var credential: URLCredential?
|
||||
open static var customHeaders: [String:String] = [:]
|
||||
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||
}
|
||||
|
||||
open class RequestBuilder<T> {
|
||||
var credential: URLCredential?
|
||||
var headers: [String:String]
|
||||
public let parameters: [String:Any]?
|
||||
public let isBody: Bool
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
public var onProgressReady: ((Progress) -> ())?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
self.isBody = isBody
|
||||
self.headers = headers
|
||||
|
||||
addHeaders(PetstoreClientAPI.customHeaders)
|
||||
}
|
||||
|
||||
open func addHeaders(_ aHeaders:[String:String]) {
|
||||
for (header, value) in aHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
}
|
||||
|
||||
open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) { }
|
||||
|
||||
public func addHeader(name: String, value: String) -> Self {
|
||||
if !value.isEmpty {
|
||||
headers[name] = value
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
open func addCredential() -> Self {
|
||||
self.credential = PetstoreClientAPI.credential
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
public protocol RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
//
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
- parameter client: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testSpecialTags(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testSpecialTagsWithRequestBuilder(client: client).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
- parameter client: (body) client model
|
||||
- returns: Promise<Client>
|
||||
*/
|
||||
open class func testSpecialTags( client: Client) -> Promise<Client> {
|
||||
let deferred = Promise<Client>.pending()
|
||||
testSpecialTags(client: client) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testSpecialTagsWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
|
||||
let path = "/another-fake/dummy"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: client)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,687 @@
|
||||
//
|
||||
// FakeAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class FakeAPI {
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?,_ error: Error?) -> Void)) {
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: Promise<Bool>
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize( body: Bool? = nil) -> Promise<Bool> {
|
||||
let deferred = Promise<Bool>.pending()
|
||||
fakeOuterBooleanSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
- POST /fake/outer/boolean
|
||||
- Test serialization of outer boolean types
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- returns: RequestBuilder<Bool>
|
||||
*/
|
||||
open class func fakeOuterBooleanSerializeWithRequestBuilder(body: Bool? = nil) -> RequestBuilder<Bool> {
|
||||
let path = "/fake/outer/boolean"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Bool>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize(outerComposite: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) {
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: outerComposite).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: Promise<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize( outerComposite: OuterComposite? = nil) -> Promise<OuterComposite> {
|
||||
let deferred = Promise<OuterComposite>.pending()
|
||||
fakeOuterCompositeSerialize(outerComposite: outerComposite) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- parameter outerComposite: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerializeWithRequestBuilder(outerComposite: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
|
||||
let path = "/fake/outer/composite"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: outerComposite)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?,_ error: Error?) -> Void)) {
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: Promise<Double>
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize( body: Double? = nil) -> Promise<Double> {
|
||||
let deferred = Promise<Double>.pending()
|
||||
fakeOuterNumberSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
- POST /fake/outer/number
|
||||
- Test serialization of outer number types
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- returns: RequestBuilder<Double>
|
||||
*/
|
||||
open class func fakeOuterNumberSerializeWithRequestBuilder(body: Double? = nil) -> RequestBuilder<Double> {
|
||||
let path = "/fake/outer/number"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Double>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: Promise<String>
|
||||
*/
|
||||
open class func fakeOuterStringSerialize( body: String? = nil) -> Promise<String> {
|
||||
let deferred = Promise<String>.pending()
|
||||
fakeOuterStringSerialize(body: body) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
- POST /fake/outer/string
|
||||
- Test serialization of outer string types
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
open class func fakeOuterStringSerializeWithRequestBuilder(body: String? = nil) -> RequestBuilder<String> {
|
||||
let path = "/fake/outer/string"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter query: (query)
|
||||
- parameter user: (body)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithQueryParams(query: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter query: (query)
|
||||
- parameter user: (body)
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testBodyWithQueryParams( query: String, user: User) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testBodyWithQueryParams(query: query, user: user) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
- PUT /fake/body-with-query-params
|
||||
- parameter query: (query)
|
||||
- parameter user: (body)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testBodyWithQueryParamsWithRequestBuilder(query: String, user: User) -> RequestBuilder<Void> {
|
||||
let path = "/fake/body-with-query-params"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"query": query
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
|
||||
- parameter client: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClientModel(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testClientModelWithRequestBuilder(client: client).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
|
||||
- parameter client: (body) client model
|
||||
- returns: Promise<Client>
|
||||
*/
|
||||
open class func testClientModel( client: Client) -> Promise<Client> {
|
||||
let deferred = Promise<Client>.pending()
|
||||
testClientModel(client: client) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClientModelWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: client)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
- parameter number: (form) None
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
|
||||
- parameter number: (form) None
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testEndpointParameters( number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testEndpointParameters(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
- POST /fake
|
||||
- Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
- BASIC:
|
||||
- type: http
|
||||
- name: http_basic_test
|
||||
- parameter number: (form) None
|
||||
- parameter double: (form) None
|
||||
- parameter patternWithoutDelimiter: (form) None
|
||||
- parameter byte: (form) None
|
||||
- parameter integer: (form) None (optional)
|
||||
- parameter int32: (form) None (optional)
|
||||
- parameter int64: (form) None (optional)
|
||||
- parameter float: (form) None (optional)
|
||||
- parameter string: (form) None (optional)
|
||||
- parameter binary: (form) None (optional)
|
||||
- parameter date: (form) None (optional)
|
||||
- parameter dateTime: (form) None (optional)
|
||||
- parameter password: (form) None (optional)
|
||||
- parameter callback: (form) None (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"integer": integer?.encodeToJSON(),
|
||||
"int32": int32?.encodeToJSON(),
|
||||
"int64": int64?.encodeToJSON(),
|
||||
"number": number,
|
||||
"float": float,
|
||||
"double": double,
|
||||
"string": string,
|
||||
"pattern_without_delimiter": patternWithoutDelimiter,
|
||||
"byte": byte,
|
||||
"binary": binary,
|
||||
"date": date?.encodeToJSON(),
|
||||
"dateTime": dateTime?.encodeToJSON(),
|
||||
"password": password,
|
||||
"callback": callback
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumHeaderStringArray
|
||||
*/
|
||||
public enum EnumHeaderStringArray_testEnumParameters: String {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumHeaderString
|
||||
*/
|
||||
public enum EnumHeaderString_testEnumParameters: String {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryStringArray
|
||||
*/
|
||||
public enum EnumQueryStringArray_testEnumParameters: String {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryString
|
||||
*/
|
||||
public enum EnumQueryString_testEnumParameters: String {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryInteger
|
||||
*/
|
||||
public enum EnumQueryInteger_testEnumParameters: Int {
|
||||
case _1 = 1
|
||||
case number2 = -2
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryDouble
|
||||
*/
|
||||
public enum EnumQueryDouble_testEnumParameters: Double {
|
||||
case _11 = 1.1
|
||||
case number12 = -1.2
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumFormStringArray
|
||||
*/
|
||||
public enum EnumFormStringArray_testEnumParameters: String {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumFormString
|
||||
*/
|
||||
public enum EnumFormString_testEnumParameters: String {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
To test enum parameters
|
||||
|
||||
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
To test enum parameters
|
||||
|
||||
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testEnumParameters( enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testEnumParameters(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
To test enum parameters
|
||||
- GET /fake
|
||||
- To test enum parameters
|
||||
- parameter enumHeaderStringArray: (header) Header parameter enum test (string array) (optional)
|
||||
- parameter enumHeaderString: (header) Header parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryStringArray: (query) Query parameter enum test (string array) (optional)
|
||||
- parameter enumQueryString: (query) Query parameter enum test (string) (optional, default to "-efg")
|
||||
- parameter enumQueryInteger: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumQueryDouble: (query) Query parameter enum test (double) (optional)
|
||||
- parameter enumFormStringArray: (form) Form parameter enum test (string array) (optional, default to "$")
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to "-efg")
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"enum_form_string_array": enumFormStringArray,
|
||||
"enum_form_string": enumFormString?.rawValue
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": enumQueryStringArray,
|
||||
"enum_query_string": enumQueryString?.rawValue,
|
||||
"enum_query_integer": enumQueryInteger?.rawValue,
|
||||
"enum_query_double": enumQueryDouble?.rawValue
|
||||
])
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"enum_header_string_array": enumHeaderStringArray,
|
||||
"enum_header_string": enumHeaderString?.rawValue
|
||||
]
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
|
||||
- parameter requestBody: (body) request body
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testInlineAdditionalProperties(requestBody: [String:String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(requestBody: requestBody).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
|
||||
- parameter requestBody: (body) request body
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalProperties( requestBody: [String:String]) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testInlineAdditionalProperties(requestBody: requestBody) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
- POST /fake/inline-additionalProperties
|
||||
- parameter requestBody: (body) request body
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(requestBody: [String:String]) -> RequestBuilder<Void> {
|
||||
let path = "/fake/inline-additionalProperties"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: requestBody)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testJsonFormData( param: String, param2: String) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testJsonFormData(param: param, param2: param2) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
- GET /fake/jsonFormData
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
|
||||
let path = "/fake/jsonFormData"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"param": param,
|
||||
"param2": param2
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
//
|
||||
// FakeClassnameTags123API.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class FakeClassnameTags123API {
|
||||
/**
|
||||
To test class name in snake case
|
||||
|
||||
- parameter client: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClassname(client: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
testClassnameWithRequestBuilder(client: client).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
To test class name in snake case
|
||||
|
||||
- parameter client: (body) client model
|
||||
- returns: Promise<Client>
|
||||
*/
|
||||
open class func testClassname( client: Client) -> Promise<Client> {
|
||||
let deferred = Promise<Client>.pending()
|
||||
testClassname(client: client) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
To test class name in snake case
|
||||
- PATCH /fake_classname_test
|
||||
- To test class name in snake case
|
||||
- API Key:
|
||||
- type: apiKey api_key_query (QUERY)
|
||||
- name: api_key_query
|
||||
- parameter client: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClassnameWithRequestBuilder(client: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake_classname_test"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: client)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,500 @@
|
||||
//
|
||||
// PetAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class PetAPI {
|
||||
/**
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func addPet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func addPet( pet: Pet) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
addPet(pet: pet) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Add a new pet to the store
|
||||
- POST /pet
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func addPetWithRequestBuilder(pet: Pet) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: pet)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes a pet
|
||||
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes a pet
|
||||
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func deletePet( petId: Int64, apiKey: String? = nil) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
deletePet(petId: petId, apiKey: apiKey) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes a pet
|
||||
- DELETE /pet/{petId}
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deletePetWithRequestBuilder(petId: Int64, apiKey: String? = nil) -> RequestBuilder<Void> {
|
||||
var path = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"api_key": apiKey
|
||||
]
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter status
|
||||
*/
|
||||
public enum Status_findPetsByStatus: String {
|
||||
case available = "available"
|
||||
case pending = "pending"
|
||||
case sold = "sold"
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by status
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by status
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: Promise<[Pet]>
|
||||
*/
|
||||
open class func findPetsByStatus( status: [String]) -> Promise<[Pet]> {
|
||||
let deferred = Promise<[Pet]>.pending()
|
||||
findPetsByStatus(status: status) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by status
|
||||
- GET /pet/findByStatus
|
||||
- Multiple status values can be provided with comma separated strings
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByStatus"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": status
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: Promise<[Pet]>
|
||||
*/
|
||||
open class func findPetsByTags( tags: [String]) -> Promise<[Pet]> {
|
||||
let deferred = Promise<[Pet]>.pending()
|
||||
findPetsByTags(tags: tags) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
- GET /pet/findByTags
|
||||
- Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- returns: RequestBuilder<[Pet]>
|
||||
*/
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByTags"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": tags
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) {
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: Promise<Pet>
|
||||
*/
|
||||
open class func getPetById( petId: Int64) -> Promise<Pet> {
|
||||
let deferred = Promise<Pet>.pending()
|
||||
getPetById(petId: petId) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
- GET /pet/{petId}
|
||||
- Returns a single pet
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- returns: RequestBuilder<Pet>
|
||||
*/
|
||||
open class func getPetByIdWithRequestBuilder(petId: Int64) -> RequestBuilder<Pet> {
|
||||
var path = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePet(pet: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(pet: pet).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func updatePet( pet: Pet) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
updatePet(pet: pet) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
- PUT /pet
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter pet: (body) Pet object that needs to be added to the store
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithRequestBuilder(pet: Pet) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: pet)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Updates a pet in the store with form data
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Updates a pet in the store with form data
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func updatePetWithForm( petId: Int64, name: String? = nil, status: String? = nil) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
updatePetWithForm(petId: petId, name: name, status: status) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Updates a pet in the store with form data
|
||||
- POST /pet/{petId}
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet that needs to be updated
|
||||
- parameter name: (form) Updated name of the pet (optional)
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithFormWithRequestBuilder(petId: Int64, name: String? = nil, status: String? = nil) -> RequestBuilder<Void> {
|
||||
var path = "/pet/{petId}"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"name": name,
|
||||
"status": status
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
uploads an image
|
||||
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
uploads an image
|
||||
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- returns: Promise<ApiResponse>
|
||||
*/
|
||||
open class func uploadFile( petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> Promise<ApiResponse> {
|
||||
let deferred = Promise<ApiResponse>.pending()
|
||||
uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
uploads an image
|
||||
- POST /pet/{petId}/uploadImage
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequestBuilder(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil) -> RequestBuilder<ApiResponse> {
|
||||
var path = "/pet/{petId}/uploadImage"
|
||||
let petIdPreEscape = "\(petId)"
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
"additionalMetadata": additionalMetadata,
|
||||
"file": file
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
//
|
||||
// StoreAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class StoreAPI {
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func deleteOrder( orderId: String) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
deleteOrder(orderId: orderId) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
- DELETE /store/order/{order_id}
|
||||
- For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deleteOrderWithRequestBuilder(orderId: String) -> RequestBuilder<Void> {
|
||||
var path = "/store/order/{order_id}"
|
||||
let orderIdPreEscape = "\(orderId)"
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getInventory(completion: @escaping ((_ data: [String:Int]?,_ error: Error?) -> Void)) {
|
||||
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
|
||||
- returns: Promise<[String:Int]>
|
||||
*/
|
||||
open class func getInventory() -> Promise<[String:Int]> {
|
||||
let deferred = Promise<[String:Int]>.pending()
|
||||
getInventory() { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
- GET /store/inventory
|
||||
- Returns a map of status codes to quantities
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- returns: RequestBuilder<[String:Int]>
|
||||
*/
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
|
||||
let path = "/store/inventory"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: Promise<Order>
|
||||
*/
|
||||
open class func getOrderById( orderId: Int64) -> Promise<Order> {
|
||||
let deferred = Promise<Order>.pending()
|
||||
getOrderById(orderId: orderId) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{order_id}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func getOrderByIdWithRequestBuilder(orderId: Int64) -> RequestBuilder<Order> {
|
||||
var path = "/store/order/{order_id}"
|
||||
let orderIdPreEscape = "\(orderId)"
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func placeOrder(order: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
placeOrderWithRequestBuilder(order: order).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: Promise<Order>
|
||||
*/
|
||||
open class func placeOrder( order: Order) -> Promise<Order> {
|
||||
let deferred = Promise<Order>.pending()
|
||||
placeOrder(order: order) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- parameter order: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func placeOrderWithRequestBuilder(order: Order) -> RequestBuilder<Order> {
|
||||
let path = "/store/order"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: order)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,443 @@
|
||||
//
|
||||
// UserAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
|
||||
open class UserAPI {
|
||||
/**
|
||||
Create user
|
||||
|
||||
- parameter user: (body) Created user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUser(user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUserWithRequestBuilder(user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Create user
|
||||
|
||||
- parameter user: (body) Created user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func createUser( user: User) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
createUser(user: user) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Create user
|
||||
- POST /user
|
||||
- This can only be done by the logged in user.
|
||||
- parameter user: (body) Created user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUserWithRequestBuilder(user: User) -> RequestBuilder<Void> {
|
||||
let path = "/user"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter user: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithArrayInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUsersWithArrayInputWithRequestBuilder(user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter user: (body) List of user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func createUsersWithArrayInput( user: [User]) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
createUsersWithArrayInput(user: user) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithArray
|
||||
- parameter user: (body) List of user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithArrayInputWithRequestBuilder(user: [User]) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithArray"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter user: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithListInput(user: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUsersWithListInputWithRequestBuilder(user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter user: (body) List of user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func createUsersWithListInput( user: [User]) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
createUsersWithListInput(user: user) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithList
|
||||
- parameter user: (body) List of user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithListInputWithRequestBuilder(user: [User]) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithList"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteUser(username: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func deleteUser( username: String) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
deleteUser(username: username) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Delete user
|
||||
- DELETE /user/{username}
|
||||
- This can only be done by the logged in user.
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func deleteUserWithRequestBuilder(username: String) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(username)"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getUserByName(username: String, completion: @escaping ((_ data: User?,_ error: Error?) -> Void)) {
|
||||
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: Promise<User>
|
||||
*/
|
||||
open class func getUserByName( username: String) -> Promise<User> {
|
||||
let deferred = Promise<User>.pending()
|
||||
getUserByName(username: username) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- returns: RequestBuilder<User>
|
||||
*/
|
||||
open class func getUserByNameWithRequestBuilder(username: String) -> RequestBuilder<User> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(username)"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs user into the system
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Logs user into the system
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- returns: Promise<String>
|
||||
*/
|
||||
open class func loginUser( username: String, password: String) -> Promise<String> {
|
||||
let deferred = Promise<String>.pending()
|
||||
loginUser(username: username, password: password) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Logs user into the system
|
||||
- GET /user/login
|
||||
- responseHeaders: [X-Rate-Limit(Int), X-Expires-After(Date)]
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- returns: RequestBuilder<String>
|
||||
*/
|
||||
open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder<String> {
|
||||
let path = "/user/login"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"username": username,
|
||||
"password": password
|
||||
])
|
||||
|
||||
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func logoutUser(completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func logoutUser() -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
logoutUser() { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
- GET /user/logout
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||
let path = "/user/logout"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Updated user
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter user: (body) Updated user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updateUser(username: String, user: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updateUserWithRequestBuilder(username: username, user: user).execute { (response, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Updated user
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter user: (body) Updated user object
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func updateUser( username: String, user: User) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
updateUser(username: username, user: user) { data, error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill(data!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
Updated user
|
||||
- PUT /user/{username}
|
||||
- This can only be done by the logged in user.
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter user: (body) Updated user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updateUserWithRequestBuilder(username: String, user: User) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(username)"
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: user)
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,413 @@
|
||||
// AlamofireImplementations.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
return AlamofireRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type {
|
||||
return AlamofireDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
|
||||
// Store manager to retain its reference
|
||||
private var managerStore: [String: Alamofire.SessionManager] = [:]
|
||||
|
||||
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the session
|
||||
configuration.
|
||||
*/
|
||||
open func createSessionManager() -> Alamofire.SessionManager {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
configuration.httpAdditionalHeaders = buildHeaders()
|
||||
return Alamofire.SessionManager(configuration: configuration)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the Content-Type
|
||||
that is given to an uploaded form part.
|
||||
|
||||
Return nil to use the default behavior (inferring the Content-Type from
|
||||
the file extension). Return the desired Content-Type otherwise.
|
||||
*/
|
||||
open func contentTypeForFormPart(fileURL: URL) -> String? {
|
||||
return nil
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the request
|
||||
configuration (e.g. to override the cache policy).
|
||||
*/
|
||||
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest {
|
||||
return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers)
|
||||
}
|
||||
|
||||
override open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
let managerId:String = UUID().uuidString
|
||||
// Create a new manager for each request to customize its request header
|
||||
let manager = createSessionManager()
|
||||
managerStore[managerId] = manager
|
||||
|
||||
let encoding:ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
|
||||
|
||||
let xMethod = Alamofire.HTTPMethod(rawValue: method)
|
||||
let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL }
|
||||
.map { $0.0 }
|
||||
|
||||
if fileKeys.count > 0 {
|
||||
manager.upload(multipartFormData: { mpForm in
|
||||
for (k, v) in self.parameters! {
|
||||
switch v {
|
||||
case let fileURL as URL:
|
||||
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
|
||||
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
|
||||
}
|
||||
else {
|
||||
mpForm.append(fileURL, withName: k)
|
||||
}
|
||||
case let string as String:
|
||||
mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k)
|
||||
case let number as NSNumber:
|
||||
mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k)
|
||||
default:
|
||||
fatalError("Unprocessable value \(v) with key \(k)")
|
||||
}
|
||||
}
|
||||
}, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in
|
||||
switch encodingResult {
|
||||
case .success(let upload, _, _):
|
||||
if let onProgressReady = self.onProgressReady {
|
||||
onProgressReady(upload.uploadProgress)
|
||||
}
|
||||
self.processRequest(request: upload, managerId, completion)
|
||||
case .failure(let encodingError):
|
||||
completion(nil, ErrorResponse.error(415, nil, encodingError))
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let request = makeRequest(manager: manager, method: xMethod!, encoding: encoding, headers: headers)
|
||||
if let onProgressReady = self.onProgressReady {
|
||||
onProgressReady(request.progress)
|
||||
}
|
||||
processRequest(request: request, managerId, completion)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
if let credential = self.credential {
|
||||
request.authenticate(usingCredential: credential)
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
_ = managerStore.removeValue(forKey: managerId)
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
||||
switch T.self {
|
||||
case is String.Type:
|
||||
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if stringResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: stringResponse.response!,
|
||||
body: ((stringResponse.result.value ?? "") as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
case is URL.Type:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
do {
|
||||
|
||||
guard !dataResponse.result.isFailure else {
|
||||
throw DownloadException.responseFailed
|
||||
}
|
||||
|
||||
guard let data = dataResponse.data else {
|
||||
throw DownloadException.responseDataMissing
|
||||
}
|
||||
|
||||
guard let request = request.request else {
|
||||
throw DownloadException.requestMissing
|
||||
}
|
||||
|
||||
let fileManager = FileManager.default
|
||||
let urlRequest = try request.asURLRequest()
|
||||
let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
let requestURL = try self.getURL(from: urlRequest)
|
||||
|
||||
var requestPath = try self.getPath(from: requestURL)
|
||||
|
||||
if let headerFileName = self.getFileName(fromContentDisposition: dataResponse.response?.allHeaderFields["Content-Disposition"] as? String) {
|
||||
requestPath = requestPath.appending("/\(headerFileName)")
|
||||
}
|
||||
|
||||
let filePath = documentsDirectory.appendingPathComponent(requestPath)
|
||||
let directoryPath = filePath.deletingLastPathComponent().path
|
||||
|
||||
try fileManager.createDirectory(atPath: directoryPath, withIntermediateDirectories: true, attributes: nil)
|
||||
try data.write(to: filePath, options: .atomic)
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: dataResponse.response!,
|
||||
body: (filePath as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
|
||||
} catch let requestParserError as DownloadException {
|
||||
completion(nil, ErrorResponse.error(400, dataResponse.data, requestParserError))
|
||||
} catch let error {
|
||||
completion(nil, ErrorResponse.error(400, dataResponse.data, error))
|
||||
}
|
||||
return
|
||||
})
|
||||
case is Void.Type:
|
||||
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if voidResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(voidResponse.response?.statusCode ?? 500, voidResponse.data, voidResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: voidResponse.response!,
|
||||
body: nil),
|
||||
nil
|
||||
)
|
||||
})
|
||||
default:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if dataResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: dataResponse.response!,
|
||||
body: (dataResponse.data as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
open func buildHeaders() -> [String: String] {
|
||||
var httpHeaders = SessionManager.defaultHTTPHeaders
|
||||
for (key, value) in self.headers {
|
||||
httpHeaders[key] = value
|
||||
}
|
||||
return httpHeaders
|
||||
}
|
||||
|
||||
fileprivate func getFileName(fromContentDisposition contentDisposition : String?) -> String? {
|
||||
|
||||
guard let contentDisposition = contentDisposition else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let items = contentDisposition.components(separatedBy: ";")
|
||||
|
||||
var filename : String? = nil
|
||||
|
||||
for contentItem in items {
|
||||
|
||||
let filenameKey = "filename="
|
||||
guard let range = contentItem.range(of: filenameKey) else {
|
||||
break
|
||||
}
|
||||
|
||||
filename = contentItem
|
||||
return filename?
|
||||
.replacingCharacters(in: range, with:"")
|
||||
.replacingOccurrences(of: "\"", with: "")
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
|
||||
return filename
|
||||
|
||||
}
|
||||
|
||||
fileprivate func getPath(from url : URL) throws -> String {
|
||||
|
||||
guard var path = URLComponents(url: url, resolvingAgainstBaseURL: true)?.path else {
|
||||
throw DownloadException.requestMissingPath
|
||||
}
|
||||
|
||||
if path.hasPrefix("/") {
|
||||
path.remove(at: path.startIndex)
|
||||
}
|
||||
|
||||
return path
|
||||
|
||||
}
|
||||
|
||||
fileprivate func getURL(from urlRequest : URLRequest) throws -> URL {
|
||||
|
||||
guard let url = urlRequest.url else {
|
||||
throw DownloadException.requestMissingURL
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fileprivate enum DownloadException : Error {
|
||||
case responseDataMissing
|
||||
case responseFailed
|
||||
case requestMissing
|
||||
case requestMissingPath
|
||||
case requestMissingURL
|
||||
}
|
||||
|
||||
public enum AlamofireDecodableRequestBuilderError: Error {
|
||||
case emptyDataResponse
|
||||
case nilHTTPResponse
|
||||
case jsonDecoding(DecodingError)
|
||||
case generalError(Error)
|
||||
}
|
||||
|
||||
open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilder<T> {
|
||||
|
||||
override fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
if let credential = self.credential {
|
||||
request.authenticate(usingCredential: credential)
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
_ = managerStore.removeValue(forKey: managerId)
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
||||
switch T.self {
|
||||
case is String.Type:
|
||||
validatedRequest.responseString(completionHandler: { (stringResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if stringResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: stringResponse.response!,
|
||||
body: ((stringResponse.result.value ?? "") as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
case is Void.Type:
|
||||
validatedRequest.responseData(completionHandler: { (voidResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if voidResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(voidResponse.response?.statusCode ?? 500, voidResponse.data, voidResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: voidResponse.response!,
|
||||
body: nil),
|
||||
nil
|
||||
)
|
||||
})
|
||||
case is Data.Type:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if dataResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
completion(
|
||||
Response(
|
||||
response: dataResponse.response!,
|
||||
body: (dataResponse.data as! T)
|
||||
),
|
||||
nil
|
||||
)
|
||||
})
|
||||
default:
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse: DataResponse<Data>) in
|
||||
cleanupRequest()
|
||||
|
||||
guard dataResponse.result.isSuccess else {
|
||||
completion(nil, ErrorResponse.error(dataResponse.response?.statusCode ?? 500, dataResponse.data, dataResponse.result.error!))
|
||||
return
|
||||
}
|
||||
|
||||
guard let data = dataResponse.data, !data.isEmpty else {
|
||||
completion(nil, ErrorResponse.error(-1, nil, AlamofireDecodableRequestBuilderError.emptyDataResponse))
|
||||
return
|
||||
}
|
||||
|
||||
guard let httpResponse = dataResponse.response else {
|
||||
completion(nil, ErrorResponse.error(-2, nil, AlamofireDecodableRequestBuilderError.nilHTTPResponse))
|
||||
return
|
||||
}
|
||||
|
||||
var responseObj: Response<T>? = nil
|
||||
|
||||
let decodeResult: (decodableObj: T?, error: Error?) = CodableHelper.decode(T.self, from: data)
|
||||
if decodeResult.error == nil {
|
||||
responseObj = Response(response: httpResponse, body: decodeResult.decodableObj)
|
||||
}
|
||||
|
||||
completion(responseObj, decodeResult.error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
//
|
||||
// CodableHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public typealias EncodeResult = (data: Data?, error: Error?)
|
||||
|
||||
open class CodableHelper {
|
||||
|
||||
open static var dateformatter: DateFormatter?
|
||||
|
||||
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
|
||||
var returnedDecodable: T? = nil
|
||||
var returnedError: Error? = nil
|
||||
|
||||
let decoder = JSONDecoder()
|
||||
if let df = self.dateformatter {
|
||||
decoder.dateDecodingStrategy = .formatted(df)
|
||||
} else {
|
||||
decoder.dataDecodingStrategy = .base64
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar(identifier: .iso8601)
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
|
||||
decoder.dateDecodingStrategy = .formatted(formatter)
|
||||
}
|
||||
|
||||
do {
|
||||
returnedDecodable = try decoder.decode(type, from: data)
|
||||
} catch {
|
||||
returnedError = error
|
||||
}
|
||||
|
||||
return (returnedDecodable, returnedError)
|
||||
}
|
||||
|
||||
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T : Encodable {
|
||||
var returnedData: Data?
|
||||
var returnedError: Error? = nil
|
||||
|
||||
let encoder = JSONEncoder()
|
||||
if prettyPrint {
|
||||
encoder.outputFormatting = .prettyPrinted
|
||||
}
|
||||
encoder.dataEncodingStrategy = .base64
|
||||
let formatter = DateFormatter()
|
||||
formatter.calendar = Calendar(identifier: .iso8601)
|
||||
formatter.locale = Locale(identifier: "en_US_POSIX")
|
||||
formatter.timeZone = TimeZone(secondsFromGMT: 0)
|
||||
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
|
||||
encoder.dateEncodingStrategy = .formatted(formatter)
|
||||
|
||||
do {
|
||||
returnedData = try encoder.encode(value)
|
||||
} catch {
|
||||
returnedError = error
|
||||
}
|
||||
|
||||
return (returnedData, returnedError)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
// Configuration.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class Configuration {
|
||||
|
||||
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
|
||||
// You must set it prior to encoding any dates, and it will only be read once.
|
||||
open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||
|
||||
}
|
@ -0,0 +1,186 @@
|
||||
// Extensions.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
extension Bool: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension Float: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension Int: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension Int32: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return NSNumber(value: self as Int32) }
|
||||
}
|
||||
|
||||
extension Int64: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return NSNumber(value: self as Int64) }
|
||||
}
|
||||
|
||||
extension Double: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
extension String: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self as Any }
|
||||
}
|
||||
|
||||
private func encodeIfPossible<T>(_ object: T) -> Any {
|
||||
if let encodableObject = object as? JSONEncodable {
|
||||
return encodableObject.encodeToJSON()
|
||||
} else {
|
||||
return object as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension Array: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.map(encodeIfPossible)
|
||||
}
|
||||
}
|
||||
|
||||
extension Dictionary: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
var dictionary = [AnyHashable: Any]()
|
||||
for (key, value) in self {
|
||||
dictionary[key] = encodeIfPossible(value)
|
||||
}
|
||||
return dictionary as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension Data: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.base64EncodedString(options: Data.Base64EncodingOptions())
|
||||
}
|
||||
}
|
||||
|
||||
private let dateFormatter: DateFormatter = {
|
||||
let fmt = DateFormatter()
|
||||
fmt.dateFormat = Configuration.dateFormat
|
||||
fmt.locale = Locale(identifier: "en_US_POSIX")
|
||||
return fmt
|
||||
}()
|
||||
|
||||
extension Date: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return dateFormatter.string(from: self) as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension UUID: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.uuidString
|
||||
}
|
||||
}
|
||||
|
||||
extension String: CodingKey {
|
||||
|
||||
public var stringValue: String {
|
||||
return self
|
||||
}
|
||||
|
||||
public init?(stringValue: String) {
|
||||
self.init(stringLiteral: stringValue)
|
||||
}
|
||||
|
||||
public var intValue: Int? {
|
||||
return nil
|
||||
}
|
||||
|
||||
public init?(intValue: Int) {
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension KeyedEncodingContainerProtocol {
|
||||
|
||||
public mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T : Encodable {
|
||||
var arrayContainer = nestedUnkeyedContainer(forKey: key)
|
||||
try arrayContainer.encode(contentsOf: values)
|
||||
}
|
||||
|
||||
public mutating func encodeArrayIfPresent<T>(_ values: [T]?, forKey key: Self.Key) throws where T : Encodable {
|
||||
if let values = values {
|
||||
try encodeArray(values, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encodeMap<T>(_ pairs: [Self.Key: T]) throws where T : Encodable {
|
||||
for (key, value) in pairs {
|
||||
try encode(value, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encodeMapIfPresent<T>(_ pairs: [Self.Key: T]?) throws where T : Encodable {
|
||||
if let pairs = pairs {
|
||||
try encodeMap(pairs)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension KeyedDecodingContainerProtocol {
|
||||
|
||||
public func decodeArray<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T : Decodable {
|
||||
var tmpArray = [T]()
|
||||
|
||||
var nestedContainer = try nestedUnkeyedContainer(forKey: key)
|
||||
while !nestedContainer.isAtEnd {
|
||||
let arrayValue = try nestedContainer.decode(T.self)
|
||||
tmpArray.append(arrayValue)
|
||||
}
|
||||
|
||||
return tmpArray
|
||||
}
|
||||
|
||||
public func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T : Decodable {
|
||||
var tmpArray: [T]? = nil
|
||||
|
||||
if contains(key) {
|
||||
tmpArray = try decodeArray(T.self, forKey: key)
|
||||
}
|
||||
|
||||
return tmpArray
|
||||
}
|
||||
|
||||
public func decodeMap<T>(_ type: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T : Decodable {
|
||||
var map: [Self.Key : T] = [:]
|
||||
|
||||
for key in allKeys {
|
||||
if !excludedKeys.contains(key) {
|
||||
let value = try decode(T.self, forKey: key)
|
||||
map[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
return map
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension RequestBuilder {
|
||||
public func execute() -> Promise<Response<T>> {
|
||||
let deferred = Promise<Response<T>>.pending()
|
||||
self.execute { (response: Response<T>?, error: Error?) in
|
||||
if let response = response {
|
||||
deferred.fulfill(response)
|
||||
} else {
|
||||
deferred.reject(error!)
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
//
|
||||
// JSONDataEncoding.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
public struct JSONDataEncoding: ParameterEncoding {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private static let jsonDataKey = "jsonData"
|
||||
|
||||
// MARK: Encoding
|
||||
|
||||
/// Creates a URL request by encoding parameters and applying them onto an existing request.
|
||||
///
|
||||
/// - parameter urlRequest: The request to have parameters applied.
|
||||
/// - parameter parameters: The parameters to apply. This should have a single key/value
|
||||
/// pair with "jsonData" as the key and a Data object as the value.
|
||||
///
|
||||
/// - throws: An `Error` if the encoding process encounters an error.
|
||||
///
|
||||
/// - returns: The encoded request.
|
||||
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
|
||||
var urlRequest = try urlRequest.asURLRequest()
|
||||
|
||||
guard let jsonData = parameters?[JSONDataEncoding.jsonDataKey] as? Data, !jsonData.isEmpty else {
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
|
||||
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
}
|
||||
|
||||
urlRequest.httpBody = jsonData
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
public static func encodingParameters(jsonData: Data?) -> Parameters? {
|
||||
var returnedParams: Parameters? = nil
|
||||
if let jsonData = jsonData, !jsonData.isEmpty {
|
||||
var params = Parameters()
|
||||
params[jsonDataKey] = jsonData
|
||||
returnedParams = params
|
||||
}
|
||||
return returnedParams
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user