forked from loafle/openapi-generator-original
Add hashableModels to additional properties (#9495)
* Add hashableStruct * Revert "Remove x-swift-hashable" This reverts commit 18053af0016fdba13fd1e5df00ad86abee071283. * Add Hashable for x-swift-hashable * Add config yaml to test x-swift-hashable * Run ./bin/generate-samples.sh ./bin/configs/swift5* * Run ./bin/utils/export_docs_generators.sh * Run ./bin/generate-samples.sh ./bin/configs/swift5* * Verify setHashableStruct * Rename hashableStruct => hashableModels - Replace hashableStruct => hashableModels - Replace HashableStruct => HashableModels - Replace HASHABLE_STRUCT => HASHABLE_MODELS - Update docs * Refactor modelObject.mustache * Control equals and hash functions
This commit is contained in:
parent
f48311dac4
commit
0a34839567
11
bin/configs/swift5-x-swift-hashable.yaml
Normal file
11
bin/configs/swift5-x-swift-hashable.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
generatorName: swift5
|
||||
outputDir: samples/client/petstore/swift5/x-swift-hashable
|
||||
inputSpec: modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/swift5
|
||||
generateAliasAsModel: true
|
||||
additionalProperties:
|
||||
podAuthors: ""
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
hashableModels: false
|
@ -12,6 +12,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|
||||
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|
||||
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
|
||||
|generateModelAdditionalProperties|Generate model additional properties (default: true)| |true|
|
||||
|hashableModels|Make hashable models (default: true)| |true|
|
||||
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
|
||||
|legacyDiscriminatorBehavior|Set to false for generators with better support for discriminators. (Python, Java, Go, PowerShell, C#have this enabled by default).|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
|
||||
|lenientTypeCast|Accept and cast values for simple types (string->bool, string->int, int->string)| |false|
|
||||
|
@ -65,6 +65,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
public static final String SWIFT_PACKAGE_PATH = "swiftPackagePath";
|
||||
public static final String USE_BACKTICK_ESCAPES = "useBacktickEscapes";
|
||||
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES = "generateModelAdditionalProperties";
|
||||
public static final String HASHABLE_MODELS = "hashableModels";
|
||||
protected static final String LIBRARY_ALAMOFIRE = "alamofire";
|
||||
protected static final String LIBRARY_URLSESSION = "urlsession";
|
||||
protected static final String RESPONSE_LIBRARY_PROMISE_KIT = "PromiseKit";
|
||||
@ -82,6 +83,7 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
protected String swiftPackagePath = "Classes" + File.separator + "OpenAPIs";
|
||||
protected boolean useBacktickEscapes = false;
|
||||
protected boolean generateModelAdditionalProperties = true;
|
||||
protected boolean hashableModels = true;
|
||||
protected String[] responseAs = new String[0];
|
||||
protected String sourceFolder = swiftPackagePath;
|
||||
protected HashSet objcReservedWords;
|
||||
@ -279,6 +281,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
cliOptions.add(new CliOption(SWIFT_PACKAGE_PATH, "Set a custom source path instead of "
|
||||
+ projectName + File.separator + "Classes" + File.separator + "OpenAPIs" + "."));
|
||||
|
||||
cliOptions.add(new CliOption(HASHABLE_MODELS,
|
||||
"Make hashable models (default: true)")
|
||||
.defaultValue(Boolean.TRUE.toString()));
|
||||
|
||||
supportedLibraries.put(LIBRARY_URLSESSION, "[DEFAULT] HTTP client: URLSession");
|
||||
supportedLibraries.put(LIBRARY_ALAMOFIRE, "HTTP client: Alamofire");
|
||||
|
||||
@ -458,6 +464,11 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
additionalProperties.put(GENERATE_MODEL_ADDITIONAL_PROPERTIES, generateModelAdditionalProperties);
|
||||
|
||||
if (additionalProperties.containsKey(HASHABLE_MODELS)) {
|
||||
setHashableModels(convertPropertyToBooleanAndWriteBack(HASHABLE_MODELS));
|
||||
}
|
||||
additionalProperties.put(HASHABLE_MODELS, hashableModels);
|
||||
|
||||
setLenientTypeCast(convertPropertyToBooleanAndWriteBack(LENIENT_TYPE_CAST));
|
||||
|
||||
// make api and model doc path available in mustache template
|
||||
@ -828,7 +839,9 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
parentSchema = parentCodegenModel.parentSchema;
|
||||
}
|
||||
}
|
||||
|
||||
if (hashableModels) {
|
||||
codegenModel.vendorExtensions.put("x-swift-hashable", true);
|
||||
}
|
||||
return codegenModel;
|
||||
}
|
||||
|
||||
@ -876,6 +889,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
this.generateModelAdditionalProperties = generateModelAdditionalProperties;
|
||||
}
|
||||
|
||||
public void setHashableModels(boolean hashableModels) {
|
||||
this.hashableModels = hashableModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
// for string, array of string
|
||||
|
@ -1,4 +1,4 @@
|
||||
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{classname}}: Codable, Hashable {
|
||||
{{^objcCompatible}}{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} {{#useClasses}}final class{{/useClasses}}{{^useClasses}}struct{{/useClasses}} {{classname}}: Codable{{#vendorExtensions.x-swift-hashable}}, Hashable{{/vendorExtensions.x-swift-hashable}} {
|
||||
{{/objcCompatible}}{{#objcCompatible}}@objc {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, Codable {
|
||||
{{/objcCompatible}}
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
nonAdditionalPropertyKeys.insert("{{{baseName}}}")
|
||||
{{/allVars}}
|
||||
additionalProperties = try container.decodeMap({{{additionalPropertiesType}}}.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}{{/additionalPropertiesType}}{{/generateModelAdditionalProperties}}{{^objcCompatible}}{{#useClasses}}
|
||||
}{{/additionalPropertiesType}}{{/generateModelAdditionalProperties}}{{^objcCompatible}}{{#useClasses}}{{#vendorExtensions.x-swift-hashable}}
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static func == (lhs: {{classname}}, rhs: {{classname}}) -> Bool {
|
||||
{{#allVars}}
|
||||
@ -100,5 +100,5 @@
|
||||
hasher.combine({{{name}}}{{^required}}?{{/required}}.hashValue)
|
||||
{{/allVars}}
|
||||
{{#generateModelAdditionalProperties}}{{#additionalPropertiesType}}hasher.combine(additionalProperties.hashValue){{/additionalPropertiesType}}{{/generateModelAdditionalProperties}}
|
||||
}{{/useClasses}}{{/objcCompatible}}
|
||||
}{{/vendorExtensions.x-swift-hashable}}{{/useClasses}}{{/objcCompatible}}
|
||||
}
|
@ -48,6 +48,7 @@ public class Swift5OptionsProvider implements OptionsProvider {
|
||||
public static final String SWIFT_USE_API_NAMESPACE_VALUE = "swiftUseApiNamespace";
|
||||
public static final String USE_BACKTICKS_ESCAPES_VALUE = "false";
|
||||
public static final String GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE = "true";
|
||||
public static final String HASHABLE_MODELS_VALUE = "true";
|
||||
public static final String ALLOW_UNICODE_IDENTIFIERS_VALUE = "false";
|
||||
public static final String PREPEND_FORM_OR_BODY_PARAMETERS_VALUE = "true";
|
||||
public static final String LIBRARY_VALUE = "alamofire";
|
||||
@ -93,6 +94,7 @@ public class Swift5OptionsProvider implements OptionsProvider {
|
||||
.put(Swift5ClientCodegen.USE_SPM_FILE_STRUCTURE, USE_SPM_FILE_STRUCTURE_VALUE)
|
||||
.put(Swift5ClientCodegen.SWIFT_PACKAGE_PATH, SWIFT_PACKAGE_PATH_VALUE)
|
||||
.put(Swift5ClientCodegen.GENERATE_MODEL_ADDITIONAL_PROPERTIES, GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE)
|
||||
.put(Swift5ClientCodegen.HASHABLE_MODELS, HASHABLE_MODELS_VALUE)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -49,5 +49,6 @@ public class Swift5OptionsTest extends AbstractOptionsTest {
|
||||
verify(clientCodegen).setPrependFormOrBodyParameters(Boolean.valueOf(Swift5OptionsProvider.PREPEND_FORM_OR_BODY_PARAMETERS_VALUE));
|
||||
verify(clientCodegen).setReadonlyProperties(Boolean.parseBoolean(Swift5OptionsProvider.READONLY_PROPERTIES_VALUE));
|
||||
verify(clientCodegen).setGenerateModelAdditionalProperties(Boolean.parseBoolean(Swift5OptionsProvider.GENERATE_MODEL_ADDITIONAL_PROPERTIES_VALUE));
|
||||
verify(clientCodegen).setHashableModels(Boolean.parseBoolean(Swift5OptionsProvider.HASHABLE_MODELS_VALUE));
|
||||
}
|
||||
}
|
||||
|
@ -1086,6 +1086,7 @@ definitions:
|
||||
xml:
|
||||
name: Order
|
||||
Category:
|
||||
x-swift-hashable: true
|
||||
type: object
|
||||
required:
|
||||
- name
|
||||
|
63
samples/client/petstore/swift5/x-swift-hashable/.gitignore
vendored
Normal file
63
samples/client/petstore/swift5/x-swift-hashable/.gitignore
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
|
||||
## Other
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
*.xcuserstate
|
||||
*.xcscmblueprint
|
||||
|
||||
## Obj-C/Swift specific
|
||||
*.hmap
|
||||
*.ipa
|
||||
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
||||
# Swift Package Manager
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
|
||||
# Packages/
|
||||
.build/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# Pods/
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
# fastlane
|
||||
#
|
||||
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
|
||||
# screenshots whenever they are needed.
|
||||
# For more information about the recommended setup visit:
|
||||
# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md
|
||||
|
||||
fastlane/report.xml
|
||||
fastlane/screenshots
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,110 @@
|
||||
.gitignore
|
||||
Cartfile
|
||||
Package.swift
|
||||
PetstoreClient.podspec
|
||||
PetstoreClient/Classes/OpenAPIs/APIHelper.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs/AnotherFakeAPI.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs/FakeAPI.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs/FakeClassnameTags123API.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs/PetAPI.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs/StoreAPI.swift
|
||||
PetstoreClient/Classes/OpenAPIs/APIs/UserAPI.swift
|
||||
PetstoreClient/Classes/OpenAPIs/CodableHelper.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Configuration.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Extensions.swift
|
||||
PetstoreClient/Classes/OpenAPIs/JSONDataEncoding.swift
|
||||
PetstoreClient/Classes/OpenAPIs/JSONEncodingHelper.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/AdditionalPropertiesClass.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Animal.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/AnimalFarm.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/ApiResponse.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/ArrayOfArrayOfNumberOnly.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/ArrayOfNumberOnly.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/ArrayTest.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Capitalization.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Cat.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/CatAllOf.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Category.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/ClassModel.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Client.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Dog.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/DogAllOf.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/EnumArrays.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/EnumClass.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/EnumTest.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/File.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/FileSchemaTestClass.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/FormatTest.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/HasOnlyReadOnly.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/List.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/MapTest.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/MixedPropertiesAndAdditionalPropertiesClass.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Model200Response.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Name.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/NumberOnly.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Order.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/OuterComposite.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/OuterEnum.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Pet.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/ReadOnlyFirst.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Return.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/SpecialModelName.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/StringBooleanMap.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/Tag.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/TypeHolderDefault.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/TypeHolderExample.swift
|
||||
PetstoreClient/Classes/OpenAPIs/Models/User.swift
|
||||
PetstoreClient/Classes/OpenAPIs/OpenISO8601DateFormatter.swift
|
||||
PetstoreClient/Classes/OpenAPIs/SynchronizedDictionary.swift
|
||||
PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift
|
||||
README.md
|
||||
docs/AdditionalPropertiesClass.md
|
||||
docs/Animal.md
|
||||
docs/AnimalFarm.md
|
||||
docs/AnotherFakeAPI.md
|
||||
docs/ApiResponse.md
|
||||
docs/ArrayOfArrayOfNumberOnly.md
|
||||
docs/ArrayOfNumberOnly.md
|
||||
docs/ArrayTest.md
|
||||
docs/Capitalization.md
|
||||
docs/Cat.md
|
||||
docs/CatAllOf.md
|
||||
docs/Category.md
|
||||
docs/ClassModel.md
|
||||
docs/Client.md
|
||||
docs/Dog.md
|
||||
docs/DogAllOf.md
|
||||
docs/EnumArrays.md
|
||||
docs/EnumClass.md
|
||||
docs/EnumTest.md
|
||||
docs/FakeAPI.md
|
||||
docs/FakeClassnameTags123API.md
|
||||
docs/File.md
|
||||
docs/FileSchemaTestClass.md
|
||||
docs/FormatTest.md
|
||||
docs/HasOnlyReadOnly.md
|
||||
docs/List.md
|
||||
docs/MapTest.md
|
||||
docs/MixedPropertiesAndAdditionalPropertiesClass.md
|
||||
docs/Model200Response.md
|
||||
docs/Name.md
|
||||
docs/NumberOnly.md
|
||||
docs/Order.md
|
||||
docs/OuterComposite.md
|
||||
docs/OuterEnum.md
|
||||
docs/Pet.md
|
||||
docs/PetAPI.md
|
||||
docs/ReadOnlyFirst.md
|
||||
docs/Return.md
|
||||
docs/SpecialModelName.md
|
||||
docs/StoreAPI.md
|
||||
docs/StringBooleanMap.md
|
||||
docs/Tag.md
|
||||
docs/TypeHolderDefault.md
|
||||
docs/TypeHolderExample.md
|
||||
docs/User.md
|
||||
docs/UserAPI.md
|
||||
git_push.sh
|
||||
project.yml
|
@ -0,0 +1 @@
|
||||
5.2.0-SNAPSHOT
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
2
samples/client/petstore/swift5/x-swift-hashable/Cartfile
Normal file
2
samples/client/petstore/swift5/x-swift-hashable/Cartfile
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
github "Flight-School/AnyCodable" ~> 0.4.0
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"object": {
|
||||
"pins": [
|
||||
{
|
||||
"package": "AnyCodable",
|
||||
"repositoryURL": "https://github.com/Flight-School/AnyCodable",
|
||||
"state": {
|
||||
"branch": null,
|
||||
"revision": "38b05fc9f86501ef8018aa90cf3d83bd97f74067",
|
||||
"version": "0.4.0"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
// swift-tools-version:5.1
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "PetstoreClient",
|
||||
platforms: [
|
||||
.iOS(.v9),
|
||||
.macOS(.v10_11),
|
||||
.tvOS(.v9),
|
||||
.watchOS(.v3),
|
||||
],
|
||||
products: [
|
||||
// Products define the executables and libraries produced by a package, and make them visible to other packages.
|
||||
.library(
|
||||
name: "PetstoreClient",
|
||||
targets: ["PetstoreClient"]
|
||||
),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
.package(url: "https://github.com/Flight-School/AnyCodable", .exact("0.4.0")),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
.target(
|
||||
name: "PetstoreClient",
|
||||
dependencies: ["AnyCodable", ],
|
||||
path: "PetstoreClient/Classes"
|
||||
),
|
||||
]
|
||||
)
|
@ -0,0 +1,15 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'PetstoreClient'
|
||||
s.ios.deployment_target = '9.0'
|
||||
s.osx.deployment_target = '10.11'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
s.watchos.deployment_target = '3.0'
|
||||
s.version = '1.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/openapitools/openapi-generator'
|
||||
s.summary = 'PetstoreClient'
|
||||
s.source_files = 'PetstoreClient/Classes/**/*.swift'
|
||||
s.dependency 'AnyCodable-FlightSchool', '~> 0.4.0'
|
||||
end
|
@ -0,0 +1,71 @@
|
||||
// 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? [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 mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
|
||||
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? [Any?] {
|
||||
collection.filter { $0 != nil }.map { "\($0!)" }.forEach { value in
|
||||
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,62 @@
|
||||
// APIs.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class PetstoreClientAPI {
|
||||
public static var basePath = "http://petstore.swagger.io:80/v2"
|
||||
public static var credential: URLCredential?
|
||||
public static var customHeaders: [String: String] = [:]
|
||||
public static var requestBuilderFactory: RequestBuilderFactory = URLSessionRequestBuilderFactory()
|
||||
public static var apiResponseQueue: DispatchQueue = .main
|
||||
}
|
||||
|
||||
open class RequestBuilder<T> {
|
||||
var credential: URLCredential?
|
||||
var headers: [String: String]
|
||||
public let parameters: [String: Any]?
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
/// With the URLSession http client the request's progress only works on iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0.
|
||||
/// If you need to get the request's progress in older OS versions, please use Alamofire http client.
|
||||
public var onProgressReady: ((Progress) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:]) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
self.headers = headers
|
||||
|
||||
addHeaders(PetstoreClientAPI.customHeaders)
|
||||
}
|
||||
|
||||
open func addHeaders(_ aHeaders: [String: String]) {
|
||||
for (header, value) in aHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
}
|
||||
|
||||
open func execute(_ apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result<Response<T>, Error>) -> Void) { }
|
||||
|
||||
public func addHeader(name: String, value: String) -> Self {
|
||||
if !value.isEmpty {
|
||||
headers[name] = value
|
||||
}
|
||||
return self
|
||||
}
|
||||
|
||||
open func addCredential() -> 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,54 @@
|
||||
//
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func call123testSpecialTags(body: Client, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
call123testSpecialTagsWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
To test special tags
|
||||
- PATCH /another-fake/dummy
|
||||
- To test special tags and operation ID starting with number
|
||||
- parameter body: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func call123testSpecialTagsWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
let path = "/another-fake/dummy"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,684 @@
|
||||
//
|
||||
// FakeAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class FakeAPI {
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Bool?, _ error: Error?) -> Void)) {
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Bool>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: OuterComposite?, _ error: Error?) -> Void)) {
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- POST /fake/outer/composite
|
||||
- Test serialization of object with outer number type
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
- returns: RequestBuilder<OuterComposite>
|
||||
*/
|
||||
open class func fakeOuterCompositeSerializeWithRequestBuilder(body: OuterComposite? = nil) -> RequestBuilder<OuterComposite> {
|
||||
let path = "/fake/outer/composite"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<OuterComposite>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Double?, _ error: Error?) -> Void)) {
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Double>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter body: (body)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- PUT /fake/body-with-file-schema
|
||||
- For this test, the body for this request much reference a schema named `File`.
|
||||
- parameter body: (body)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testBodyWithFileSchemaWithRequestBuilder(body: FileSchemaTestClass) -> RequestBuilder<Void> {
|
||||
let path = "/fake/body-with-file-schema"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
- parameter query: (query)
|
||||
- parameter body: (body)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithQueryParams(query: String, body: User, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
- PUT /fake/body-with-query-params
|
||||
- parameter query: (query)
|
||||
- parameter body: (body)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testBodyWithQueryParamsWithRequestBuilder(query: String, body: User) -> RequestBuilder<Void> {
|
||||
let path = "/fake/body-with-query-params"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
var urlComponents = URLComponents(string: URLString)
|
||||
urlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"query": query.encodeToJSON(),
|
||||
])
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClientModel(body: Client, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
testClientModelWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
To test \"client\" model
|
||||
- PATCH /fake
|
||||
- To test \"client\" model
|
||||
- parameter body: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClientModelWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
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 apiResponseQueue: The queue on which api response is dispatched.
|
||||
- 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, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, 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(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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.encodeToJSON(),
|
||||
"float": float?.encodeToJSON(),
|
||||
"double": double.encodeToJSON(),
|
||||
"string": string?.encodeToJSON(),
|
||||
"pattern_without_delimiter": patternWithoutDelimiter.encodeToJSON(),
|
||||
"byte": byte.encodeToJSON(),
|
||||
"binary": binary?.encodeToJSON(),
|
||||
"date": date?.encodeToJSON(),
|
||||
"dateTime": dateTime?.encodeToJSON(),
|
||||
"password": password?.encodeToJSON(),
|
||||
"callback": callback?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumHeaderStringArray
|
||||
*/
|
||||
public enum EnumHeaderStringArray_testEnumParameters: String, CaseIterable {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumHeaderString
|
||||
*/
|
||||
public enum EnumHeaderString_testEnumParameters: String, CaseIterable {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryStringArray
|
||||
*/
|
||||
public enum EnumQueryStringArray_testEnumParameters: String, CaseIterable {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryString
|
||||
*/
|
||||
public enum EnumQueryString_testEnumParameters: String, CaseIterable {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryInteger
|
||||
*/
|
||||
public enum EnumQueryInteger_testEnumParameters: Int, CaseIterable {
|
||||
case _1 = 1
|
||||
case number2 = -2
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumQueryDouble
|
||||
*/
|
||||
public enum EnumQueryDouble_testEnumParameters: Double, CaseIterable {
|
||||
case _11 = 1.1
|
||||
case number12 = -1.2
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumFormStringArray
|
||||
*/
|
||||
public enum EnumFormStringArray_testEnumParameters: String, CaseIterable {
|
||||
case greaterThan = ">"
|
||||
case dollar = "$"
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter enumFormString
|
||||
*/
|
||||
public enum EnumFormString_testEnumParameters: String, CaseIterable {
|
||||
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 .dollar)
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .efg)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- 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, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, 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(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 .dollar)
|
||||
- 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?.encodeToJSON(),
|
||||
"enum_form_string": enumFormString?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
var urlComponents = URLComponents(string: URLString)
|
||||
urlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": enumQueryStringArray?.encodeToJSON(),
|
||||
"enum_query_string": enumQueryString?.encodeToJSON(),
|
||||
"enum_query_integer": enumQueryInteger?.encodeToJSON(),
|
||||
"enum_query_double": enumQueryDouble?.encodeToJSON(),
|
||||
])
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"enum_header_string_array": enumHeaderStringArray?.encodeToJSON(),
|
||||
"enum_header_string": enumHeaderString?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Fake endpoint to test group parameters (optional)
|
||||
|
||||
- parameter requiredStringGroup: (query) Required String in group parameters
|
||||
- parameter requiredBooleanGroup: (header) Required Boolean in group parameters
|
||||
- parameter requiredInt64Group: (query) Required Integer in group parameters
|
||||
- parameter stringGroup: (query) String in group parameters (optional)
|
||||
- parameter booleanGroup: (header) Boolean in group parameters (optional)
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Fake endpoint to test group parameters (optional)
|
||||
- DELETE /fake
|
||||
- Fake endpoint to test group parameters (optional)
|
||||
- parameter requiredStringGroup: (query) Required String in group parameters
|
||||
- parameter requiredBooleanGroup: (header) Required Boolean in group parameters
|
||||
- parameter requiredInt64Group: (query) Required Integer in group parameters
|
||||
- parameter stringGroup: (query) String in group parameters (optional)
|
||||
- parameter booleanGroup: (header) Boolean in group parameters (optional)
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testGroupParametersWithRequestBuilder(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var urlComponents = URLComponents(string: URLString)
|
||||
urlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"required_string_group": requiredStringGroup.encodeToJSON(),
|
||||
"required_int64_group": requiredInt64Group.encodeToJSON(),
|
||||
"string_group": stringGroup?.encodeToJSON(),
|
||||
"int64_group": int64Group?.encodeToJSON(),
|
||||
])
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"required_boolean_group": requiredBooleanGroup.encodeToJSON(),
|
||||
"boolean_group": booleanGroup?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
|
||||
- parameter param: (body) request body
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testInlineAdditionalProperties(param: [String: String], apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
- POST /fake/inline-additionalProperties
|
||||
- parameter param: (body) request body
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String: String]) -> RequestBuilder<Void> {
|
||||
let path = "/fake/inline-additionalProperties"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: param)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
|
||||
- parameter param: (form) field1
|
||||
- parameter param2: (form) field2
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testJsonFormData(param: String, param2: String, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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.encodeToJSON(),
|
||||
"param2": param2.encodeToJSON(),
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// FakeClassnameTags123API.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class FakeClassnameTags123API {
|
||||
/**
|
||||
To test class name in snake case
|
||||
|
||||
- parameter body: (body) client model
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClassname(body: Client, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
testClassnameWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 body: (body) client model
|
||||
- returns: RequestBuilder<Client>
|
||||
*/
|
||||
open class func testClassnameWithRequestBuilder(body: Client) -> RequestBuilder<Client> {
|
||||
let path = "/fake_classname_test"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PATCH", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,483 @@
|
||||
//
|
||||
// PetAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class PetAPI {
|
||||
/**
|
||||
Add a new pet to the store
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func addPet(body: Pet, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Add a new pet to the store
|
||||
- POST /pet
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func addPetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes a pet
|
||||
|
||||
- parameter petId: (path) Pet id to delete
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 = "\(APIHelper.mapValueToPathItem(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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"api_key": apiKey?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* enum for parameter status
|
||||
*/
|
||||
public enum Status_findPetsByStatus: String, CaseIterable {
|
||||
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 apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByStatus(status: [String], apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 urlComponents = URLComponents(string: URLString)
|
||||
urlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": status.encodeToJSON(),
|
||||
])
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Finds Pets by tags
|
||||
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
@available(*, deprecated, message: "This operation is deprecated.")
|
||||
open class func findPetsByTags(tags: [String], apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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]>
|
||||
*/
|
||||
@available(*, deprecated, message: "This operation is deprecated.")
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByTags"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var urlComponents = URLComponents(string: URLString)
|
||||
urlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": tags.encodeToJSON(),
|
||||
])
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<[Pet]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Find pet by ID
|
||||
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getPetById(petId: Int64, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Pet?, _ error: Error?) -> Void)) {
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 = "\(APIHelper.mapValueToPathItem(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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePet(body: Pet, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Update an existing pet
|
||||
- PUT /pet
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updatePetWithRequestBuilder(body: Pet) -> RequestBuilder<Void> {
|
||||
let path = "/pet"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
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 apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 = "\(APIHelper.mapValueToPathItem(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?.encodeToJSON(),
|
||||
"status": status?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
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 apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 = "\(APIHelper.mapValueToPathItem(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?.encodeToJSON(),
|
||||
"file": file?.encodeToJSON(),
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "multipart/form-data",
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
uploads an image (required)
|
||||
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter requiredFile: (form) file to upload
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
|
||||
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
uploads an image (required)
|
||||
- POST /fake/{petId}/uploadImageWithRequiredFile
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- parameter petId: (path) ID of pet to update
|
||||
- parameter requiredFile: (form) file to upload
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- returns: RequestBuilder<ApiResponse>
|
||||
*/
|
||||
open class func uploadFileWithRequiredFileWithRequestBuilder(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil) -> RequestBuilder<ApiResponse> {
|
||||
var path = "/fake/{petId}/uploadImageWithRequiredFile"
|
||||
let petIdPreEscape = "\(APIHelper.mapValueToPathItem(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?.encodeToJSON(),
|
||||
"requiredFile": requiredFile.encodeToJSON(),
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"Content-Type": "multipart/form-data",
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,189 @@
|
||||
//
|
||||
// StoreAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class StoreAPI {
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteOrder(orderId: String, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 = "\(APIHelper.mapValueToPathItem(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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns pet inventories by status
|
||||
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getInventory(apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: [String: Int]?, _ error: Error?) -> Void)) {
|
||||
getInventoryWithRequestBuilder().execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Find purchase order by ID
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getOrderById(orderId: Int64, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 = "\(APIHelper.mapValueToPathItem(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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func placeOrder(body: Order, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
|
||||
placeOrderWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- returns: RequestBuilder<Order>
|
||||
*/
|
||||
open class func placeOrderWithRequestBuilder(body: Order) -> RequestBuilder<Order> {
|
||||
let path = "/store/order"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,366 @@
|
||||
//
|
||||
// UserAPI.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class UserAPI {
|
||||
/**
|
||||
Create user
|
||||
|
||||
- parameter body: (body) Created user object
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUser(body: User, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createUserWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Create user
|
||||
- POST /user
|
||||
- This can only be done by the logged in user.
|
||||
- parameter body: (body) Created user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUserWithRequestBuilder(body: User) -> RequestBuilder<Void> {
|
||||
let path = "/user"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithArrayInput(body: [User], apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createUsersWithArrayInputWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithArray
|
||||
- parameter body: (body) List of user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithArrayInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithArray"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
|
||||
- parameter body: (body) List of user object
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithListInput(body: [User], apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createUsersWithListInputWithRequestBuilder(body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
completion(nil, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Creates list of users with given input array
|
||||
- POST /user/createWithList
|
||||
- parameter body: (body) List of user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func createUsersWithListInputWithRequestBuilder(body: [User]) -> RequestBuilder<Void> {
|
||||
let path = "/user/createWithList"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Delete user
|
||||
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteUser(username: String, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deleteUserWithRequestBuilder(username: username).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 = "\(APIHelper.mapValueToPathItem(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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "DELETE", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Get user by user name
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getUserByName(username: String, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: User?, _ error: Error?) -> Void)) {
|
||||
getUserByNameWithRequestBuilder(username: username).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 = "\(APIHelper.mapValueToPathItem(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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs user into the system
|
||||
|
||||
- parameter username: (query) The user name for login
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func loginUser(username: String, password: String, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
|
||||
loginUserWithRequestBuilder(username: username, password: password).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case let .success(response):
|
||||
completion(response.body, nil)
|
||||
case let .failure(error):
|
||||
completion(nil, 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 urlComponents = URLComponents(string: URLString)
|
||||
urlComponents?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"username": username.encodeToJSON(),
|
||||
"password": password.encodeToJSON(),
|
||||
])
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<String>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Logs out current logged in user session
|
||||
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func logoutUser(apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
logoutUserWithRequestBuilder().execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
Updated user
|
||||
|
||||
- parameter username: (path) name that need to be deleted
|
||||
- parameter body: (body) Updated user object
|
||||
- parameter apiResponseQueue: The queue on which api response is dispatched.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updateUser(username: String, body: User, apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updateUserWithRequestBuilder(username: username, body: body).execute(apiResponseQueue) { result -> Void in
|
||||
switch result {
|
||||
case .success:
|
||||
completion((), nil)
|
||||
case let .failure(error):
|
||||
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 body: (body) Updated user object
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func updateUserWithRequestBuilder(username: String, body: User) -> RequestBuilder<Void> {
|
||||
var path = "/user/{username}"
|
||||
let usernamePreEscape = "\(APIHelper.mapValueToPathItem(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: body)
|
||||
|
||||
let urlComponents = URLComponents(string: URLString)
|
||||
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
:
|
||||
]
|
||||
|
||||
let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
return requestBuilder.init(method: "PUT", URLString: (urlComponents?.string ?? URLString), parameters: parameters, headers: headerParameters)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
//
|
||||
// CodableHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class CodableHelper {
|
||||
private static var customDateFormatter: DateFormatter?
|
||||
private static var defaultDateFormatter: DateFormatter = OpenISO8601DateFormatter()
|
||||
|
||||
private static var customJSONDecoder: JSONDecoder?
|
||||
private static var defaultJSONDecoder: JSONDecoder = {
|
||||
let decoder = JSONDecoder()
|
||||
decoder.dateDecodingStrategy = .formatted(CodableHelper.dateFormatter)
|
||||
return decoder
|
||||
}()
|
||||
|
||||
private static var customJSONEncoder: JSONEncoder?
|
||||
private static var defaultJSONEncoder: JSONEncoder = {
|
||||
let encoder = JSONEncoder()
|
||||
encoder.dateEncodingStrategy = .formatted(CodableHelper.dateFormatter)
|
||||
encoder.outputFormatting = .prettyPrinted
|
||||
return encoder
|
||||
}()
|
||||
|
||||
public static var dateFormatter: DateFormatter {
|
||||
get { return customDateFormatter ?? defaultDateFormatter }
|
||||
set { customDateFormatter = newValue }
|
||||
}
|
||||
public static var jsonDecoder: JSONDecoder {
|
||||
get { return customJSONDecoder ?? defaultJSONDecoder }
|
||||
set { customJSONDecoder = newValue }
|
||||
}
|
||||
public static var jsonEncoder: JSONEncoder {
|
||||
get { return customJSONEncoder ?? defaultJSONEncoder }
|
||||
set { customJSONEncoder = newValue }
|
||||
}
|
||||
|
||||
open class func decode<T>(_ type: T.Type, from data: Data) -> Swift.Result<T, Error> where T: Decodable {
|
||||
return Swift.Result { try jsonDecoder.decode(type, from: data) }
|
||||
}
|
||||
|
||||
open class func encode<T>(_ value: T) -> Swift.Result<Data, Error> where T: Encodable {
|
||||
return Swift.Result { try jsonEncoder.encode(value) }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
// 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.
|
||||
@available(*, unavailable, message: "To set a different date format, use CodableHelper.dateFormatter instead.")
|
||||
public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||
}
|
@ -0,0 +1,227 @@
|
||||
// Extensions.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
extension RawRepresentable where RawValue: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self.rawValue 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 Set: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return Array(self).encodeToJSON()
|
||||
}
|
||||
}
|
||||
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
extension Date: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return CodableHelper.dateFormatter.string(from: self) as Any
|
||||
}
|
||||
}
|
||||
|
||||
extension URL: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
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]?
|
||||
|
||||
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 HTTPURLResponse {
|
||||
var isStatusCodeSuccessful: Bool {
|
||||
return Array(200 ..< 300).contains(statusCode)
|
||||
}
|
||||
}
|
||||
|
||||
extension AnyCodable: Hashable {
|
||||
public func hash(into hasher: inout Hasher) {
|
||||
switch value {
|
||||
case let value as Bool:
|
||||
hasher.combine(value)
|
||||
case let value as Int:
|
||||
hasher.combine(value)
|
||||
case let value as Int8:
|
||||
hasher.combine(value)
|
||||
case let value as Int16:
|
||||
hasher.combine(value)
|
||||
case let value as Int32:
|
||||
hasher.combine(value)
|
||||
case let value as Int64:
|
||||
hasher.combine(value)
|
||||
case let value as UInt:
|
||||
hasher.combine(value)
|
||||
case let value as UInt8:
|
||||
hasher.combine(value)
|
||||
case let value as UInt16:
|
||||
hasher.combine(value)
|
||||
case let value as UInt32:
|
||||
hasher.combine(value)
|
||||
case let value as UInt64:
|
||||
hasher.combine(value)
|
||||
case let value as Float:
|
||||
hasher.combine(value)
|
||||
case let value as Double:
|
||||
hasher.combine(value)
|
||||
case let value as String:
|
||||
hasher.combine(value)
|
||||
case let value as [String: AnyCodable]:
|
||||
hasher.combine(value)
|
||||
case let value as [AnyCodable]:
|
||||
hasher.combine(value)
|
||||
default:
|
||||
hasher.combine(0)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
//
|
||||
// JSONDataEncoding.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct JSONDataEncoding {
|
||||
|
||||
// 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: URLRequest, with parameters: [String: Any]?) -> URLRequest {
|
||||
var urlRequest = urlRequest
|
||||
|
||||
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?) -> [String: Any]? {
|
||||
var returnedParams: [String: Any]?
|
||||
if let jsonData = jsonData, !jsonData.isEmpty {
|
||||
var params: [String: Any] = [:]
|
||||
params[jsonDataKey] = jsonData
|
||||
returnedParams = params
|
||||
}
|
||||
return returnedParams
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
//
|
||||
// JSONEncodingHelper.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
open class JSONEncodingHelper {
|
||||
|
||||
open class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?) -> [String: Any]? {
|
||||
var params: [String: Any]?
|
||||
|
||||
// Encode the Encodable object
|
||||
if let encodableObj = encodableObj {
|
||||
let encodeResult = CodableHelper.encode(encodableObj)
|
||||
do {
|
||||
let data = try encodeResult.get()
|
||||
params = JSONDataEncoding.encodingParameters(jsonData: data)
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
open class func encodingParameters(forEncodableObject encodableObj: Any?) -> [String: Any]? {
|
||||
var params: [String: Any]?
|
||||
|
||||
if let encodableObj = encodableObj {
|
||||
do {
|
||||
let data = try JSONSerialization.data(withJSONObject: encodableObj, options: .prettyPrinted)
|
||||
params = JSONDataEncoding.encodingParameters(jsonData: data)
|
||||
} catch {
|
||||
print(error.localizedDescription)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
// 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?, URLResponse?, Error)
|
||||
}
|
||||
|
||||
public enum DownloadException: Error {
|
||||
case responseDataMissing
|
||||
case responseFailed
|
||||
case requestMissing
|
||||
case requestMissingPath
|
||||
case requestMissingURL
|
||||
}
|
||||
|
||||
public enum DecodableRequestBuilderError: Error {
|
||||
case emptyDataResponse
|
||||
case nilHTTPResponse
|
||||
case unsuccessfulHTTPStatusCode
|
||||
case jsonDecoding(DecodingError)
|
||||
case generalError(Error)
|
||||
}
|
||||
|
||||
open class Response<T> {
|
||||
public let statusCode: Int
|
||||
public let header: [String: String]
|
||||
public 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 (key, value) in rawHeader {
|
||||
if let key = key.base as? String, let value = value as? String {
|
||||
header[key] = value
|
||||
}
|
||||
}
|
||||
self.init(statusCode: response.statusCode, header: header, body: body)
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesAnyType.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesAnyType: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: AnyCodable] = [:]
|
||||
|
||||
public subscript(key: String) -> AnyCodable? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap(AnyCodable.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesArray.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesArray: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: [AnyCodable]] = [:]
|
||||
|
||||
public subscript(key: String) -> [AnyCodable]? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap([AnyCodable].self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesBoolean.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesBoolean: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: Bool] = [:]
|
||||
|
||||
public subscript(key: String) -> Bool? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap(Bool.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// AdditionalPropertiesClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesClass: Codable {
|
||||
|
||||
public var mapString: [String: String]?
|
||||
public var mapMapString: [String: [String: String]]?
|
||||
|
||||
public init(mapString: [String: String]? = nil, mapMapString: [String: [String: String]]? = nil) {
|
||||
self.mapString = mapString
|
||||
self.mapMapString = mapMapString
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case mapString = "map_string"
|
||||
case mapMapString = "map_map_string"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(mapString, forKey: .mapString)
|
||||
try container.encodeIfPresent(mapMapString, forKey: .mapMapString)
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesInteger.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesInteger: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: Int] = [:]
|
||||
|
||||
public subscript(key: String) -> Int? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap(Int.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesNumber.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesNumber: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: Double] = [:]
|
||||
|
||||
public subscript(key: String) -> Double? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap(Double.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesObject.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesObject: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: [String: AnyCodable]] = [:]
|
||||
|
||||
public subscript(key: String) -> [String: AnyCodable]? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap([String: AnyCodable].self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
//
|
||||
// AdditionalPropertiesString.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct AdditionalPropertiesString: Codable {
|
||||
|
||||
public var name: String?
|
||||
|
||||
public init(name: String? = nil) {
|
||||
self.name = name
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
}
|
||||
public var additionalProperties: [String: String] = [:]
|
||||
|
||||
public subscript(key: String) -> String? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
name = try container.decodeIfPresent(String.self, forKey: "name")
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
nonAdditionalPropertyKeys.insert("name")
|
||||
additionalProperties = try container.decodeMap(String.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Animal.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Animal: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String? = "red"
|
||||
|
||||
public init(className: String, color: String? = "red") {
|
||||
self.className = className
|
||||
self.color = color
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case className
|
||||
case color
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(className, forKey: .className)
|
||||
try container.encodeIfPresent(color, forKey: .color)
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
//
|
||||
// AnimalFarm.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public typealias AnimalFarm = [Animal]
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// ApiResponse.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct ApiResponse: Codable {
|
||||
|
||||
public var code: Int?
|
||||
public var type: String?
|
||||
public var message: String?
|
||||
|
||||
public init(code: Int? = nil, type: String? = nil, message: String? = nil) {
|
||||
self.code = code
|
||||
self.type = type
|
||||
self.message = message
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case code
|
||||
case type
|
||||
case message
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(code, forKey: .code)
|
||||
try container.encodeIfPresent(type, forKey: .type)
|
||||
try container.encodeIfPresent(message, forKey: .message)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// ArrayOfArrayOfNumberOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayArrayNumber: [[Double]]?
|
||||
|
||||
public init(arrayArrayNumber: [[Double]]? = nil) {
|
||||
self.arrayArrayNumber = arrayArrayNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case arrayArrayNumber = "ArrayArrayNumber"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(arrayArrayNumber, forKey: .arrayArrayNumber)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// ArrayOfNumberOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct ArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayNumber: [Double]?
|
||||
|
||||
public init(arrayNumber: [Double]? = nil) {
|
||||
self.arrayNumber = arrayNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case arrayNumber = "ArrayNumber"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(arrayNumber, forKey: .arrayNumber)
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// ArrayTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct ArrayTest: Codable {
|
||||
|
||||
public var arrayOfString: [String]?
|
||||
public var arrayArrayOfInteger: [[Int64]]?
|
||||
public var arrayArrayOfModel: [[ReadOnlyFirst]]?
|
||||
|
||||
public init(arrayOfString: [String]? = nil, arrayArrayOfInteger: [[Int64]]? = nil, arrayArrayOfModel: [[ReadOnlyFirst]]? = nil) {
|
||||
self.arrayOfString = arrayOfString
|
||||
self.arrayArrayOfInteger = arrayArrayOfInteger
|
||||
self.arrayArrayOfModel = arrayArrayOfModel
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case arrayOfString = "array_of_string"
|
||||
case arrayArrayOfInteger = "array_array_of_integer"
|
||||
case arrayArrayOfModel = "array_array_of_model"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(arrayOfString, forKey: .arrayOfString)
|
||||
try container.encodeIfPresent(arrayArrayOfInteger, forKey: .arrayArrayOfInteger)
|
||||
try container.encodeIfPresent(arrayArrayOfModel, forKey: .arrayArrayOfModel)
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// BigCat.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct BigCat: Codable {
|
||||
|
||||
public enum Kind: String, Codable, CaseIterable {
|
||||
case lions = "lions"
|
||||
case tigers = "tigers"
|
||||
case leopards = "leopards"
|
||||
case jaguars = "jaguars"
|
||||
}
|
||||
public var kind: Kind?
|
||||
|
||||
public init(kind: Kind? = nil) {
|
||||
self.kind = kind
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case kind
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(kind, forKey: .kind)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// BigCatAllOf.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct BigCatAllOf: Codable {
|
||||
|
||||
public enum Kind: String, Codable, CaseIterable {
|
||||
case lions = "lions"
|
||||
case tigers = "tigers"
|
||||
case leopards = "leopards"
|
||||
case jaguars = "jaguars"
|
||||
}
|
||||
public var kind: Kind?
|
||||
|
||||
public init(kind: Kind? = nil) {
|
||||
self.kind = kind
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case kind
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(kind, forKey: .kind)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
//
|
||||
// Capitalization.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
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? = nil, capitalCamel: String? = nil, smallSnake: String? = nil, capitalSnake: String? = nil, sCAETHFlowPoints: String? = nil, ATT_NAME: String? = nil) {
|
||||
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, CaseIterable {
|
||||
case smallCamel
|
||||
case capitalCamel = "CapitalCamel"
|
||||
case smallSnake = "small_Snake"
|
||||
case capitalSnake = "Capital_Snake"
|
||||
case sCAETHFlowPoints = "SCA_ETH_Flow_Points"
|
||||
case ATT_NAME
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(smallCamel, forKey: .smallCamel)
|
||||
try container.encodeIfPresent(capitalCamel, forKey: .capitalCamel)
|
||||
try container.encodeIfPresent(smallSnake, forKey: .smallSnake)
|
||||
try container.encodeIfPresent(capitalSnake, forKey: .capitalSnake)
|
||||
try container.encodeIfPresent(sCAETHFlowPoints, forKey: .sCAETHFlowPoints)
|
||||
try container.encodeIfPresent(ATT_NAME, forKey: .ATT_NAME)
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Cat.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Cat: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String? = "red"
|
||||
public var declawed: Bool?
|
||||
|
||||
public init(className: String, color: String? = "red", declawed: Bool? = nil) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
self.declawed = declawed
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case className
|
||||
case color
|
||||
case declawed
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(className, forKey: .className)
|
||||
try container.encodeIfPresent(color, forKey: .color)
|
||||
try container.encodeIfPresent(declawed, forKey: .declawed)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// CatAllOf.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct CatAllOf: Codable {
|
||||
|
||||
public var declawed: Bool?
|
||||
|
||||
public init(declawed: Bool? = nil) {
|
||||
self.declawed = declawed
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case declawed
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(declawed, forKey: .declawed)
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Category.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Category: Codable, Hashable {
|
||||
|
||||
public var id: Int64?
|
||||
public var name: String? = "default-name"
|
||||
|
||||
public init(id: Int64? = nil, name: String? = "default-name") {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case id
|
||||
case name
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(id, forKey: .id)
|
||||
try container.encode(name, forKey: .name)
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
//
|
||||
// ClassModel.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
/** Model for testing model with \"_class\" property */
|
||||
public struct ClassModel: Codable {
|
||||
|
||||
public var _class: String?
|
||||
|
||||
public init(_class: String? = nil) {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case _class
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(_class, forKey: ._class)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// Client.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Client: Codable {
|
||||
|
||||
public var client: String?
|
||||
|
||||
public init(client: String? = nil) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case client
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(client, forKey: .client)
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Dog.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Dog: Codable {
|
||||
|
||||
public var className: String
|
||||
public var color: String? = "red"
|
||||
public var breed: String?
|
||||
|
||||
public init(className: String, color: String? = "red", breed: String? = nil) {
|
||||
self.className = className
|
||||
self.color = color
|
||||
self.breed = breed
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case className
|
||||
case color
|
||||
case breed
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(className, forKey: .className)
|
||||
try container.encodeIfPresent(color, forKey: .color)
|
||||
try container.encodeIfPresent(breed, forKey: .breed)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// DogAllOf.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct DogAllOf: Codable {
|
||||
|
||||
public var breed: String?
|
||||
|
||||
public init(breed: String? = nil) {
|
||||
self.breed = breed
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case breed
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(breed, forKey: .breed)
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
//
|
||||
// EnumArrays.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct EnumArrays: Codable {
|
||||
|
||||
public enum JustSymbol: String, Codable, CaseIterable {
|
||||
case greaterThanOrEqualTo = ">="
|
||||
case dollar = "$"
|
||||
}
|
||||
public enum ArrayEnum: String, Codable, CaseIterable {
|
||||
case fish = "fish"
|
||||
case crab = "crab"
|
||||
}
|
||||
public var justSymbol: JustSymbol?
|
||||
public var arrayEnum: [ArrayEnum]?
|
||||
|
||||
public init(justSymbol: JustSymbol? = nil, arrayEnum: [ArrayEnum]? = nil) {
|
||||
self.justSymbol = justSymbol
|
||||
self.arrayEnum = arrayEnum
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case justSymbol = "just_symbol"
|
||||
case arrayEnum = "array_enum"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(justSymbol, forKey: .justSymbol)
|
||||
try container.encodeIfPresent(arrayEnum, forKey: .arrayEnum)
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// EnumClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public enum EnumClass: String, Codable, CaseIterable {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
case xyz = "(xyz)"
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
//
|
||||
// EnumTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct EnumTest: Codable {
|
||||
|
||||
public enum EnumString: String, Codable, CaseIterable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
case empty = ""
|
||||
}
|
||||
public enum EnumStringRequired: String, Codable, CaseIterable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
case empty = ""
|
||||
}
|
||||
public enum EnumInteger: Int, Codable, CaseIterable {
|
||||
case _1 = 1
|
||||
case number1 = -1
|
||||
}
|
||||
public enum EnumNumber: Double, Codable, CaseIterable {
|
||||
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? = nil, enumStringRequired: EnumStringRequired, enumInteger: EnumInteger? = nil, enumNumber: EnumNumber? = nil, outerEnum: OuterEnum? = nil) {
|
||||
self.enumString = enumString
|
||||
self.enumStringRequired = enumStringRequired
|
||||
self.enumInteger = enumInteger
|
||||
self.enumNumber = enumNumber
|
||||
self.outerEnum = outerEnum
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case enumString = "enum_string"
|
||||
case enumStringRequired = "enum_string_required"
|
||||
case enumInteger = "enum_integer"
|
||||
case enumNumber = "enum_number"
|
||||
case outerEnum
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(enumString, forKey: .enumString)
|
||||
try container.encode(enumStringRequired, forKey: .enumStringRequired)
|
||||
try container.encodeIfPresent(enumInteger, forKey: .enumInteger)
|
||||
try container.encodeIfPresent(enumNumber, forKey: .enumNumber)
|
||||
try container.encodeIfPresent(outerEnum, forKey: .outerEnum)
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
//
|
||||
// File.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
/** Must be named `File` for test. */
|
||||
public struct File: Codable {
|
||||
|
||||
/** Test capitalization */
|
||||
public var sourceURI: String?
|
||||
|
||||
public init(sourceURI: String? = nil) {
|
||||
self.sourceURI = sourceURI
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case sourceURI
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(sourceURI, forKey: .sourceURI)
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// FileSchemaTestClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct FileSchemaTestClass: Codable {
|
||||
|
||||
public var file: File?
|
||||
public var files: [File]?
|
||||
|
||||
public init(file: File? = nil, files: [File]? = nil) {
|
||||
self.file = file
|
||||
self.files = files
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case file
|
||||
case files
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(file, forKey: .file)
|
||||
try container.encodeIfPresent(files, forKey: .files)
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
//
|
||||
// FormatTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct FormatTest: Codable {
|
||||
|
||||
public var integer: Int?
|
||||
public var int32: Int?
|
||||
public var int64: Int64?
|
||||
public var number: Double
|
||||
public var float: Float?
|
||||
public var double: Double?
|
||||
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? = nil, int32: Int? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: URL? = nil, date: Date, dateTime: Date? = nil, uuid: UUID? = nil, 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
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case integer
|
||||
case int32
|
||||
case int64
|
||||
case number
|
||||
case float
|
||||
case double
|
||||
case string
|
||||
case byte
|
||||
case binary
|
||||
case date
|
||||
case dateTime
|
||||
case uuid
|
||||
case password
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(integer, forKey: .integer)
|
||||
try container.encodeIfPresent(int32, forKey: .int32)
|
||||
try container.encodeIfPresent(int64, forKey: .int64)
|
||||
try container.encode(number, forKey: .number)
|
||||
try container.encodeIfPresent(float, forKey: .float)
|
||||
try container.encodeIfPresent(double, forKey: .double)
|
||||
try container.encodeIfPresent(string, forKey: .string)
|
||||
try container.encode(byte, forKey: .byte)
|
||||
try container.encodeIfPresent(binary, forKey: .binary)
|
||||
try container.encode(date, forKey: .date)
|
||||
try container.encodeIfPresent(dateTime, forKey: .dateTime)
|
||||
try container.encodeIfPresent(uuid, forKey: .uuid)
|
||||
try container.encode(password, forKey: .password)
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// HasOnlyReadOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct HasOnlyReadOnly: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var foo: String?
|
||||
|
||||
public init(bar: String? = nil, foo: String? = nil) {
|
||||
self.bar = bar
|
||||
self.foo = foo
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case bar
|
||||
case foo
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(bar, forKey: .bar)
|
||||
try container.encodeIfPresent(foo, forKey: .foo)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// List.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct List: Codable {
|
||||
|
||||
public var _123list: String?
|
||||
|
||||
public init(_123list: String? = nil) {
|
||||
self._123list = _123list
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case _123list = "123-list"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(_123list, forKey: ._123list)
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
//
|
||||
// MapTest.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct MapTest: Codable {
|
||||
|
||||
public enum MapOfEnumString: String, Codable, CaseIterable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
}
|
||||
public var mapMapOfString: [String: [String: String]]?
|
||||
public var mapOfEnumString: [String: String]?
|
||||
public var directMap: [String: Bool]?
|
||||
public var indirectMap: StringBooleanMap?
|
||||
|
||||
public init(mapMapOfString: [String: [String: String]]? = nil, mapOfEnumString: [String: String]? = nil, directMap: [String: Bool]? = nil, indirectMap: StringBooleanMap? = nil) {
|
||||
self.mapMapOfString = mapMapOfString
|
||||
self.mapOfEnumString = mapOfEnumString
|
||||
self.directMap = directMap
|
||||
self.indirectMap = indirectMap
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case mapMapOfString = "map_map_of_string"
|
||||
case mapOfEnumString = "map_of_enum_string"
|
||||
case directMap = "direct_map"
|
||||
case indirectMap = "indirect_map"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(mapMapOfString, forKey: .mapMapOfString)
|
||||
try container.encodeIfPresent(mapOfEnumString, forKey: .mapOfEnumString)
|
||||
try container.encodeIfPresent(directMap, forKey: .directMap)
|
||||
try container.encodeIfPresent(indirectMap, forKey: .indirectMap)
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// MixedPropertiesAndAdditionalPropertiesClass.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
|
||||
public var uuid: UUID?
|
||||
public var dateTime: Date?
|
||||
public var map: [String: Animal]?
|
||||
|
||||
public init(uuid: UUID? = nil, dateTime: Date? = nil, map: [String: Animal]? = nil) {
|
||||
self.uuid = uuid
|
||||
self.dateTime = dateTime
|
||||
self.map = map
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case uuid
|
||||
case dateTime
|
||||
case map
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(uuid, forKey: .uuid)
|
||||
try container.encodeIfPresent(dateTime, forKey: .dateTime)
|
||||
try container.encodeIfPresent(map, forKey: .map)
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
//
|
||||
// Model200Response.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
/** Model for testing model name starting with number */
|
||||
public struct Model200Response: Codable {
|
||||
|
||||
public var name: Int?
|
||||
public var _class: String?
|
||||
|
||||
public init(name: Int? = nil, _class: String? = nil) {
|
||||
self.name = name
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
case _class = "class"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
try container.encodeIfPresent(_class, forKey: ._class)
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
//
|
||||
// Name.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
/** Model for testing model name same as property name */
|
||||
public struct Name: Codable {
|
||||
|
||||
public var name: Int
|
||||
public var snakeCase: Int?
|
||||
public var property: String?
|
||||
public var _123number: Int?
|
||||
|
||||
public init(name: Int, snakeCase: Int? = nil, property: String? = nil, _123number: Int? = nil) {
|
||||
self.name = name
|
||||
self.snakeCase = snakeCase
|
||||
self.property = property
|
||||
self._123number = _123number
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case name
|
||||
case snakeCase = "snake_case"
|
||||
case property
|
||||
case _123number = "123Number"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(name, forKey: .name)
|
||||
try container.encodeIfPresent(snakeCase, forKey: .snakeCase)
|
||||
try container.encodeIfPresent(property, forKey: .property)
|
||||
try container.encodeIfPresent(_123number, forKey: ._123number)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// NumberOnly.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct NumberOnly: Codable {
|
||||
|
||||
public var justNumber: Double?
|
||||
|
||||
public init(justNumber: Double? = nil) {
|
||||
self.justNumber = justNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case justNumber = "JustNumber"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(justNumber, forKey: .justNumber)
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
//
|
||||
// Order.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Order: Codable {
|
||||
|
||||
public enum Status: String, Codable, CaseIterable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var petId: Int64?
|
||||
public var quantity: Int?
|
||||
public var shipDate: Date?
|
||||
/** Order Status */
|
||||
public var status: Status?
|
||||
public var complete: Bool? = false
|
||||
|
||||
public init(id: Int64? = nil, petId: Int64? = nil, quantity: Int? = nil, shipDate: Date? = nil, status: Status? = nil, complete: Bool? = false) {
|
||||
self.id = id
|
||||
self.petId = petId
|
||||
self.quantity = quantity
|
||||
self.shipDate = shipDate
|
||||
self.status = status
|
||||
self.complete = complete
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case id
|
||||
case petId
|
||||
case quantity
|
||||
case shipDate
|
||||
case status
|
||||
case complete
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(id, forKey: .id)
|
||||
try container.encodeIfPresent(petId, forKey: .petId)
|
||||
try container.encodeIfPresent(quantity, forKey: .quantity)
|
||||
try container.encodeIfPresent(shipDate, forKey: .shipDate)
|
||||
try container.encodeIfPresent(status, forKey: .status)
|
||||
try container.encodeIfPresent(complete, forKey: .complete)
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
//
|
||||
// OuterComposite.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct OuterComposite: Codable {
|
||||
|
||||
public var myNumber: Double?
|
||||
public var myString: String?
|
||||
public var myBoolean: Bool?
|
||||
|
||||
public init(myNumber: Double? = nil, myString: String? = nil, myBoolean: Bool? = nil) {
|
||||
self.myNumber = myNumber
|
||||
self.myString = myString
|
||||
self.myBoolean = myBoolean
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case myNumber = "my_number"
|
||||
case myString = "my_string"
|
||||
case myBoolean = "my_boolean"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(myNumber, forKey: .myNumber)
|
||||
try container.encodeIfPresent(myString, forKey: .myString)
|
||||
try container.encodeIfPresent(myBoolean, forKey: .myBoolean)
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
//
|
||||
// OuterEnum.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public enum OuterEnum: String, Codable, CaseIterable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
//
|
||||
// Pet.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Pet: Codable, Hashable {
|
||||
|
||||
public enum Status: String, Codable, CaseIterable {
|
||||
case available = "available"
|
||||
case pending = "pending"
|
||||
case sold = "sold"
|
||||
}
|
||||
public var id: Int64?
|
||||
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? = nil, category: Category? = nil, name: String, photoUrls: [String], tags: [Tag]? = nil, status: Status? = nil) {
|
||||
self.id = id
|
||||
self.category = category
|
||||
self.name = name
|
||||
self.photoUrls = photoUrls
|
||||
self.tags = tags
|
||||
self.status = status
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case id
|
||||
case category
|
||||
case name
|
||||
case photoUrls
|
||||
case tags
|
||||
case status
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(id, forKey: .id)
|
||||
try container.encodeIfPresent(category, forKey: .category)
|
||||
try container.encode(name, forKey: .name)
|
||||
try container.encode(photoUrls, forKey: .photoUrls)
|
||||
try container.encodeIfPresent(tags, forKey: .tags)
|
||||
try container.encodeIfPresent(status, forKey: .status)
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// ReadOnlyFirst.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct ReadOnlyFirst: Codable {
|
||||
|
||||
public var bar: String?
|
||||
public var baz: String?
|
||||
|
||||
public init(bar: String? = nil, baz: String? = nil) {
|
||||
self.bar = bar
|
||||
self.baz = baz
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case bar
|
||||
case baz
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(bar, forKey: .bar)
|
||||
try container.encodeIfPresent(baz, forKey: .baz)
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
//
|
||||
// Return.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
/** Model for testing reserved words */
|
||||
public struct Return: Codable {
|
||||
|
||||
public var _return: Int?
|
||||
|
||||
public init(_return: Int? = nil) {
|
||||
self._return = _return
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case _return = "return"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(_return, forKey: ._return)
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
//
|
||||
// SpecialModelName.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct SpecialModelName: Codable {
|
||||
|
||||
public var specialPropertyName: Int64?
|
||||
|
||||
public init(specialPropertyName: Int64? = nil) {
|
||||
self.specialPropertyName = specialPropertyName
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case specialPropertyName = "$special[property.name]"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(specialPropertyName, forKey: .specialPropertyName)
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
//
|
||||
// StringBooleanMap.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct StringBooleanMap: Codable {
|
||||
|
||||
|
||||
public enum CodingKeys: CodingKey, CaseIterable {
|
||||
}
|
||||
|
||||
public var additionalProperties: [String: Bool] = [:]
|
||||
|
||||
public subscript(key: String) -> Bool? {
|
||||
get {
|
||||
if let value = additionalProperties[key] {
|
||||
return value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
set {
|
||||
additionalProperties[key] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
var additionalPropertiesContainer = encoder.container(keyedBy: String.self)
|
||||
try additionalPropertiesContainer.encodeMap(additionalProperties)
|
||||
}
|
||||
|
||||
// Decodable protocol methods
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: String.self)
|
||||
|
||||
var nonAdditionalPropertyKeys = Set<String>()
|
||||
additionalProperties = try container.decodeMap(Bool.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
//
|
||||
// Tag.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct Tag: Codable, Hashable {
|
||||
|
||||
public var id: Int64?
|
||||
public var name: String?
|
||||
|
||||
public init(id: Int64? = nil, name: String? = nil) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case id
|
||||
case name
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(id, forKey: .id)
|
||||
try container.encodeIfPresent(name, forKey: .name)
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
//
|
||||
// TypeHolderDefault.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct TypeHolderDefault: Codable {
|
||||
|
||||
public var stringItem: String = "what"
|
||||
public var numberItem: Double
|
||||
public var integerItem: Int
|
||||
public var boolItem: Bool = true
|
||||
public var arrayItem: [Int]
|
||||
|
||||
public init(stringItem: String = "what", numberItem: Double, integerItem: Int, boolItem: Bool = true, arrayItem: [Int]) {
|
||||
self.stringItem = stringItem
|
||||
self.numberItem = numberItem
|
||||
self.integerItem = integerItem
|
||||
self.boolItem = boolItem
|
||||
self.arrayItem = arrayItem
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case stringItem = "string_item"
|
||||
case numberItem = "number_item"
|
||||
case integerItem = "integer_item"
|
||||
case boolItem = "bool_item"
|
||||
case arrayItem = "array_item"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(stringItem, forKey: .stringItem)
|
||||
try container.encode(numberItem, forKey: .numberItem)
|
||||
try container.encode(integerItem, forKey: .integerItem)
|
||||
try container.encode(boolItem, forKey: .boolItem)
|
||||
try container.encode(arrayItem, forKey: .arrayItem)
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
//
|
||||
// TypeHolderExample.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct TypeHolderExample: Codable {
|
||||
|
||||
public var stringItem: String
|
||||
public var numberItem: Double
|
||||
public var integerItem: Int
|
||||
public var boolItem: Bool
|
||||
public var arrayItem: [Int]
|
||||
|
||||
public init(stringItem: String, numberItem: Double, integerItem: Int, boolItem: Bool, arrayItem: [Int]) {
|
||||
self.stringItem = stringItem
|
||||
self.numberItem = numberItem
|
||||
self.integerItem = integerItem
|
||||
self.boolItem = boolItem
|
||||
self.arrayItem = arrayItem
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case stringItem = "string_item"
|
||||
case numberItem = "number_item"
|
||||
case integerItem = "integer_item"
|
||||
case boolItem = "bool_item"
|
||||
case arrayItem = "array_item"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(stringItem, forKey: .stringItem)
|
||||
try container.encode(numberItem, forKey: .numberItem)
|
||||
try container.encode(integerItem, forKey: .integerItem)
|
||||
try container.encode(boolItem, forKey: .boolItem)
|
||||
try container.encode(arrayItem, forKey: .arrayItem)
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
//
|
||||
// User.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct User: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
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 init(id: Int64? = nil, username: String? = nil, firstName: String? = nil, lastName: String? = nil, email: String? = nil, password: String? = nil, phone: String? = nil, userStatus: Int? = nil) {
|
||||
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, CaseIterable {
|
||||
case id
|
||||
case username
|
||||
case firstName
|
||||
case lastName
|
||||
case email
|
||||
case password
|
||||
case phone
|
||||
case userStatus
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(id, forKey: .id)
|
||||
try container.encodeIfPresent(username, forKey: .username)
|
||||
try container.encodeIfPresent(firstName, forKey: .firstName)
|
||||
try container.encodeIfPresent(lastName, forKey: .lastName)
|
||||
try container.encodeIfPresent(email, forKey: .email)
|
||||
try container.encodeIfPresent(password, forKey: .password)
|
||||
try container.encodeIfPresent(phone, forKey: .phone)
|
||||
try container.encodeIfPresent(userStatus, forKey: .userStatus)
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
//
|
||||
// XmlItem.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import AnyCodable
|
||||
|
||||
public struct XmlItem: Codable {
|
||||
|
||||
public var attributeString: String?
|
||||
public var attributeNumber: Double?
|
||||
public var attributeInteger: Int?
|
||||
public var attributeBoolean: Bool?
|
||||
public var wrappedArray: [Int]?
|
||||
public var nameString: String?
|
||||
public var nameNumber: Double?
|
||||
public var nameInteger: Int?
|
||||
public var nameBoolean: Bool?
|
||||
public var nameArray: [Int]?
|
||||
public var nameWrappedArray: [Int]?
|
||||
public var prefixString: String?
|
||||
public var prefixNumber: Double?
|
||||
public var prefixInteger: Int?
|
||||
public var prefixBoolean: Bool?
|
||||
public var prefixArray: [Int]?
|
||||
public var prefixWrappedArray: [Int]?
|
||||
public var namespaceString: String?
|
||||
public var namespaceNumber: Double?
|
||||
public var namespaceInteger: Int?
|
||||
public var namespaceBoolean: Bool?
|
||||
public var namespaceArray: [Int]?
|
||||
public var namespaceWrappedArray: [Int]?
|
||||
public var prefixNsString: String?
|
||||
public var prefixNsNumber: Double?
|
||||
public var prefixNsInteger: Int?
|
||||
public var prefixNsBoolean: Bool?
|
||||
public var prefixNsArray: [Int]?
|
||||
public var prefixNsWrappedArray: [Int]?
|
||||
|
||||
public init(attributeString: String? = nil, attributeNumber: Double? = nil, attributeInteger: Int? = nil, attributeBoolean: Bool? = nil, wrappedArray: [Int]? = nil, nameString: String? = nil, nameNumber: Double? = nil, nameInteger: Int? = nil, nameBoolean: Bool? = nil, nameArray: [Int]? = nil, nameWrappedArray: [Int]? = nil, prefixString: String? = nil, prefixNumber: Double? = nil, prefixInteger: Int? = nil, prefixBoolean: Bool? = nil, prefixArray: [Int]? = nil, prefixWrappedArray: [Int]? = nil, namespaceString: String? = nil, namespaceNumber: Double? = nil, namespaceInteger: Int? = nil, namespaceBoolean: Bool? = nil, namespaceArray: [Int]? = nil, namespaceWrappedArray: [Int]? = nil, prefixNsString: String? = nil, prefixNsNumber: Double? = nil, prefixNsInteger: Int? = nil, prefixNsBoolean: Bool? = nil, prefixNsArray: [Int]? = nil, prefixNsWrappedArray: [Int]? = nil) {
|
||||
self.attributeString = attributeString
|
||||
self.attributeNumber = attributeNumber
|
||||
self.attributeInteger = attributeInteger
|
||||
self.attributeBoolean = attributeBoolean
|
||||
self.wrappedArray = wrappedArray
|
||||
self.nameString = nameString
|
||||
self.nameNumber = nameNumber
|
||||
self.nameInteger = nameInteger
|
||||
self.nameBoolean = nameBoolean
|
||||
self.nameArray = nameArray
|
||||
self.nameWrappedArray = nameWrappedArray
|
||||
self.prefixString = prefixString
|
||||
self.prefixNumber = prefixNumber
|
||||
self.prefixInteger = prefixInteger
|
||||
self.prefixBoolean = prefixBoolean
|
||||
self.prefixArray = prefixArray
|
||||
self.prefixWrappedArray = prefixWrappedArray
|
||||
self.namespaceString = namespaceString
|
||||
self.namespaceNumber = namespaceNumber
|
||||
self.namespaceInteger = namespaceInteger
|
||||
self.namespaceBoolean = namespaceBoolean
|
||||
self.namespaceArray = namespaceArray
|
||||
self.namespaceWrappedArray = namespaceWrappedArray
|
||||
self.prefixNsString = prefixNsString
|
||||
self.prefixNsNumber = prefixNsNumber
|
||||
self.prefixNsInteger = prefixNsInteger
|
||||
self.prefixNsBoolean = prefixNsBoolean
|
||||
self.prefixNsArray = prefixNsArray
|
||||
self.prefixNsWrappedArray = prefixNsWrappedArray
|
||||
}
|
||||
public enum CodingKeys: String, CodingKey, CaseIterable {
|
||||
case attributeString = "attribute_string"
|
||||
case attributeNumber = "attribute_number"
|
||||
case attributeInteger = "attribute_integer"
|
||||
case attributeBoolean = "attribute_boolean"
|
||||
case wrappedArray = "wrapped_array"
|
||||
case nameString = "name_string"
|
||||
case nameNumber = "name_number"
|
||||
case nameInteger = "name_integer"
|
||||
case nameBoolean = "name_boolean"
|
||||
case nameArray = "name_array"
|
||||
case nameWrappedArray = "name_wrapped_array"
|
||||
case prefixString = "prefix_string"
|
||||
case prefixNumber = "prefix_number"
|
||||
case prefixInteger = "prefix_integer"
|
||||
case prefixBoolean = "prefix_boolean"
|
||||
case prefixArray = "prefix_array"
|
||||
case prefixWrappedArray = "prefix_wrapped_array"
|
||||
case namespaceString = "namespace_string"
|
||||
case namespaceNumber = "namespace_number"
|
||||
case namespaceInteger = "namespace_integer"
|
||||
case namespaceBoolean = "namespace_boolean"
|
||||
case namespaceArray = "namespace_array"
|
||||
case namespaceWrappedArray = "namespace_wrapped_array"
|
||||
case prefixNsString = "prefix_ns_string"
|
||||
case prefixNsNumber = "prefix_ns_number"
|
||||
case prefixNsInteger = "prefix_ns_integer"
|
||||
case prefixNsBoolean = "prefix_ns_boolean"
|
||||
case prefixNsArray = "prefix_ns_array"
|
||||
case prefixNsWrappedArray = "prefix_ns_wrapped_array"
|
||||
}
|
||||
|
||||
// Encodable protocol methods
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(attributeString, forKey: .attributeString)
|
||||
try container.encodeIfPresent(attributeNumber, forKey: .attributeNumber)
|
||||
try container.encodeIfPresent(attributeInteger, forKey: .attributeInteger)
|
||||
try container.encodeIfPresent(attributeBoolean, forKey: .attributeBoolean)
|
||||
try container.encodeIfPresent(wrappedArray, forKey: .wrappedArray)
|
||||
try container.encodeIfPresent(nameString, forKey: .nameString)
|
||||
try container.encodeIfPresent(nameNumber, forKey: .nameNumber)
|
||||
try container.encodeIfPresent(nameInteger, forKey: .nameInteger)
|
||||
try container.encodeIfPresent(nameBoolean, forKey: .nameBoolean)
|
||||
try container.encodeIfPresent(nameArray, forKey: .nameArray)
|
||||
try container.encodeIfPresent(nameWrappedArray, forKey: .nameWrappedArray)
|
||||
try container.encodeIfPresent(prefixString, forKey: .prefixString)
|
||||
try container.encodeIfPresent(prefixNumber, forKey: .prefixNumber)
|
||||
try container.encodeIfPresent(prefixInteger, forKey: .prefixInteger)
|
||||
try container.encodeIfPresent(prefixBoolean, forKey: .prefixBoolean)
|
||||
try container.encodeIfPresent(prefixArray, forKey: .prefixArray)
|
||||
try container.encodeIfPresent(prefixWrappedArray, forKey: .prefixWrappedArray)
|
||||
try container.encodeIfPresent(namespaceString, forKey: .namespaceString)
|
||||
try container.encodeIfPresent(namespaceNumber, forKey: .namespaceNumber)
|
||||
try container.encodeIfPresent(namespaceInteger, forKey: .namespaceInteger)
|
||||
try container.encodeIfPresent(namespaceBoolean, forKey: .namespaceBoolean)
|
||||
try container.encodeIfPresent(namespaceArray, forKey: .namespaceArray)
|
||||
try container.encodeIfPresent(namespaceWrappedArray, forKey: .namespaceWrappedArray)
|
||||
try container.encodeIfPresent(prefixNsString, forKey: .prefixNsString)
|
||||
try container.encodeIfPresent(prefixNsNumber, forKey: .prefixNsNumber)
|
||||
try container.encodeIfPresent(prefixNsInteger, forKey: .prefixNsInteger)
|
||||
try container.encodeIfPresent(prefixNsBoolean, forKey: .prefixNsBoolean)
|
||||
try container.encodeIfPresent(prefixNsArray, forKey: .prefixNsArray)
|
||||
try container.encodeIfPresent(prefixNsWrappedArray, forKey: .prefixNsWrappedArray)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
//
|
||||
// OpenISO8601DateFormatter.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// https://stackoverflow.com/a/50281094/976628
|
||||
public class OpenISO8601DateFormatter: DateFormatter {
|
||||
static let withoutSeconds: DateFormatter = {
|
||||
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:ssZZZZZ"
|
||||
return formatter
|
||||
}()
|
||||
|
||||
private func setup() {
|
||||
calendar = Calendar(identifier: .iso8601)
|
||||
locale = Locale(identifier: "en_US_POSIX")
|
||||
timeZone = TimeZone(secondsFromGMT: 0)
|
||||
dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||
}
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
setup()
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
setup()
|
||||
}
|
||||
|
||||
override public func date(from string: String) -> Date? {
|
||||
if let result = super.date(from: string) {
|
||||
return result
|
||||
}
|
||||
return OpenISO8601DateFormatter.withoutSeconds.date(from: string)
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
// SynchronizedDictionary.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
internal struct SynchronizedDictionary<K: Hashable, V> {
|
||||
|
||||
private var dictionary = [K: V]()
|
||||
private let queue = DispatchQueue(
|
||||
label: "SynchronizedDictionary",
|
||||
qos: DispatchQoS.userInitiated,
|
||||
attributes: [DispatchQueue.Attributes.concurrent],
|
||||
autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit,
|
||||
target: nil
|
||||
)
|
||||
|
||||
internal subscript(key: K) -> V? {
|
||||
get {
|
||||
var value: V?
|
||||
|
||||
queue.sync {
|
||||
value = self.dictionary[key]
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
set {
|
||||
queue.sync(flags: DispatchWorkItemFlags.barrier) {
|
||||
self.dictionary[key] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,606 @@
|
||||
// URLSessionImplementations.swift
|
||||
//
|
||||
// Generated by openapi-generator
|
||||
// https://openapi-generator.tech
|
||||
//
|
||||
|
||||
import Foundation
|
||||
#if !os(macOS)
|
||||
import MobileCoreServices
|
||||
#endif
|
||||
|
||||
class URLSessionRequestBuilderFactory: RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type {
|
||||
return URLSessionRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
|
||||
return URLSessionDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
|
||||
// Store the URLSession to retain its reference
|
||||
private var urlSessionStore = SynchronizedDictionary<String, URLSession>()
|
||||
|
||||
open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
|
||||
/**
|
||||
May be assigned if you want to control the authentication challenges.
|
||||
*/
|
||||
public var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))?
|
||||
|
||||
/**
|
||||
May be assigned if you want to do any of those things:
|
||||
- control the task completion
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, headers: [String: String] = [:]) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, headers: headers)
|
||||
}
|
||||
|
||||
/**
|
||||
May be overridden by a subclass if you want to control the URLSession
|
||||
configuration.
|
||||
*/
|
||||
open func createURLSession() -> URLSession {
|
||||
let configuration = URLSessionConfiguration.default
|
||||
configuration.httpAdditionalHeaders = buildHeaders()
|
||||
let sessionDelegate = SessionDelegate()
|
||||
sessionDelegate.credential = credential
|
||||
sessionDelegate.taskDidReceiveChallenge = taskDidReceiveChallenge
|
||||
return URLSession(configuration: configuration, delegate: sessionDelegate, delegateQueue: nil)
|
||||
}
|
||||
|
||||
/**
|
||||
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 URLRequest
|
||||
configuration (e.g. to override the cache policy).
|
||||
*/
|
||||
open func createURLRequest(urlSession: URLSession, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) throws -> URLRequest {
|
||||
|
||||
guard let url = URL(string: URLString) else {
|
||||
throw DownloadException.requestMissingURL
|
||||
}
|
||||
|
||||
var originalRequest = URLRequest(url: url)
|
||||
|
||||
originalRequest.httpMethod = method.rawValue
|
||||
|
||||
headers.forEach { key, value in
|
||||
originalRequest.setValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
|
||||
buildHeaders().forEach { key, value in
|
||||
originalRequest.setValue(value, forHTTPHeaderField: key)
|
||||
}
|
||||
|
||||
let modifiedRequest = try encoding.encode(originalRequest, with: parameters)
|
||||
|
||||
return modifiedRequest
|
||||
}
|
||||
|
||||
override open func execute(_ apiResponseQueue: DispatchQueue = PetstoreClientAPI.apiResponseQueue, _ completion: @escaping (_ result: Swift.Result<Response<T>, Error>) -> Void) {
|
||||
let urlSessionId = UUID().uuidString
|
||||
// Create a new manager for each request to customize its request header
|
||||
let urlSession = createURLSession()
|
||||
urlSessionStore[urlSessionId] = urlSession
|
||||
|
||||
guard let xMethod = HTTPMethod(rawValue: method) else {
|
||||
fatalError("Unsuported Http method - \(method)")
|
||||
}
|
||||
|
||||
let encoding: ParameterEncoding
|
||||
|
||||
switch xMethod {
|
||||
case .get, .head:
|
||||
encoding = URLEncoding()
|
||||
|
||||
case .options, .post, .put, .patch, .delete, .trace, .connect:
|
||||
let contentType = headers["Content-Type"] ?? "application/json"
|
||||
|
||||
if contentType == "application/json" {
|
||||
encoding = JSONDataEncoding()
|
||||
} else if contentType == "multipart/form-data" {
|
||||
encoding = FormDataEncoding(contentTypeForFormPart: contentTypeForFormPart(fileURL:))
|
||||
} else if contentType == "application/x-www-form-urlencoded" {
|
||||
encoding = FormURLEncoding()
|
||||
} else {
|
||||
fatalError("Unsuported Media Type - \(contentType)")
|
||||
}
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
urlSessionStore[urlSessionId]?.finishTasksAndInvalidate()
|
||||
urlSessionStore[urlSessionId] = nil
|
||||
}
|
||||
|
||||
do {
|
||||
let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers)
|
||||
|
||||
let dataTask = urlSession.dataTask(with: request) { data, response, error in
|
||||
|
||||
if let taskCompletionShouldRetry = self.taskCompletionShouldRetry {
|
||||
|
||||
taskCompletionShouldRetry(data, response, error) { shouldRetry in
|
||||
|
||||
if shouldRetry {
|
||||
cleanupRequest()
|
||||
self.execute(apiResponseQueue, completion)
|
||||
} else {
|
||||
apiResponseQueue.async {
|
||||
self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion)
|
||||
cleanupRequest()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
apiResponseQueue.async {
|
||||
self.processRequestResponse(urlRequest: request, data: data, response: response, error: error, completion: completion)
|
||||
cleanupRequest()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if #available(iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0, *) {
|
||||
onProgressReady?(dataTask.progress)
|
||||
}
|
||||
|
||||
dataTask.resume()
|
||||
|
||||
} catch {
|
||||
apiResponseQueue.async {
|
||||
cleanupRequest()
|
||||
completion(.failure(ErrorResponse.error(415, nil, nil, error)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func processRequestResponse(urlRequest: URLRequest, data: Data?, response: URLResponse?, error: Error?, completion: @escaping (_ result: Swift.Result<Response<T>, Error>) -> Void) {
|
||||
|
||||
if let error = error {
|
||||
completion(.failure(ErrorResponse.error(-1, data, response, error)))
|
||||
return
|
||||
}
|
||||
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
completion(.failure(ErrorResponse.error(-2, data, response, DecodableRequestBuilderError.nilHTTPResponse)))
|
||||
return
|
||||
}
|
||||
|
||||
guard httpResponse.isStatusCodeSuccessful else {
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, DecodableRequestBuilderError.unsuccessfulHTTPStatusCode)))
|
||||
return
|
||||
}
|
||||
|
||||
switch T.self {
|
||||
case is String.Type:
|
||||
|
||||
let body = data.flatMap { String(data: $0, encoding: .utf8) } ?? ""
|
||||
|
||||
completion(.success(Response<T>(response: httpResponse, body: body as? T)))
|
||||
|
||||
case is URL.Type:
|
||||
do {
|
||||
|
||||
guard error == nil else {
|
||||
throw DownloadException.responseFailed
|
||||
}
|
||||
|
||||
guard let data = data else {
|
||||
throw DownloadException.responseDataMissing
|
||||
}
|
||||
|
||||
let fileManager = FileManager.default
|
||||
let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
|
||||
let requestURL = try getURL(from: urlRequest)
|
||||
|
||||
var requestPath = try getPath(from: requestURL)
|
||||
|
||||
if let headerFileName = getFileName(fromContentDisposition: httpResponse.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(.success(Response(response: httpResponse, body: filePath as? T)))
|
||||
|
||||
} catch let requestParserError as DownloadException {
|
||||
completion(.failure(ErrorResponse.error(400, data, response, requestParserError)))
|
||||
} catch {
|
||||
completion(.failure(ErrorResponse.error(400, data, response, error)))
|
||||
}
|
||||
|
||||
case is Void.Type:
|
||||
|
||||
completion(.success(Response(response: httpResponse, body: nil)))
|
||||
|
||||
default:
|
||||
|
||||
completion(.success(Response(response: httpResponse, body: data as? T)))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open func buildHeaders() -> [String: String] {
|
||||
var httpHeaders: [String: String] = [:]
|
||||
for (key, value) in headers {
|
||||
httpHeaders[key] = value
|
||||
}
|
||||
for (key, value) in PetstoreClientAPI.customHeaders {
|
||||
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?
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open class URLSessionDecodableRequestBuilder<T: Decodable>: URLSessionRequestBuilder<T> {
|
||||
override fileprivate func processRequestResponse(urlRequest: URLRequest, data: Data?, response: URLResponse?, error: Error?, completion: @escaping (_ result: Swift.Result<Response<T>, Error>) -> Void) {
|
||||
|
||||
if let error = error {
|
||||
completion(.failure(ErrorResponse.error(-1, data, response, error)))
|
||||
return
|
||||
}
|
||||
|
||||
guard let httpResponse = response as? HTTPURLResponse else {
|
||||
completion(.failure(ErrorResponse.error(-2, data, response, DecodableRequestBuilderError.nilHTTPResponse)))
|
||||
return
|
||||
}
|
||||
|
||||
guard httpResponse.isStatusCodeSuccessful else {
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, DecodableRequestBuilderError.unsuccessfulHTTPStatusCode)))
|
||||
return
|
||||
}
|
||||
|
||||
switch T.self {
|
||||
case is String.Type:
|
||||
|
||||
let body = data.flatMap { String(data: $0, encoding: .utf8) } ?? ""
|
||||
|
||||
completion(.success(Response<T>(response: httpResponse, body: body as? T)))
|
||||
|
||||
case is Void.Type:
|
||||
|
||||
completion(.success(Response(response: httpResponse, body: nil)))
|
||||
|
||||
case is Data.Type:
|
||||
|
||||
completion(.success(Response(response: httpResponse, body: data as? T)))
|
||||
|
||||
default:
|
||||
|
||||
guard let data = data, !data.isEmpty else {
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, nil, response, DecodableRequestBuilderError.emptyDataResponse)))
|
||||
return
|
||||
}
|
||||
|
||||
let decodeResult = CodableHelper.decode(T.self, from: data)
|
||||
|
||||
switch decodeResult {
|
||||
case let .success(decodableObj):
|
||||
completion(.success(Response(response: httpResponse, body: decodableObj)))
|
||||
case let .failure(error):
|
||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, data, response, error)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SessionDelegate: NSObject, URLSessionDelegate, URLSessionDataDelegate {
|
||||
|
||||
var credential: URLCredential?
|
||||
|
||||
var taskDidReceiveChallenge: ((URLSession, URLSessionTask, URLAuthenticationChallenge) -> (URLSession.AuthChallengeDisposition, URLCredential?))?
|
||||
|
||||
func urlSession(_ session: URLSession, task: URLSessionTask, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
|
||||
var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling
|
||||
|
||||
var credential: URLCredential?
|
||||
|
||||
if let taskDidReceiveChallenge = taskDidReceiveChallenge {
|
||||
(disposition, credential) = taskDidReceiveChallenge(session, task, challenge)
|
||||
} else {
|
||||
if challenge.previousFailureCount > 0 {
|
||||
disposition = .rejectProtectionSpace
|
||||
} else {
|
||||
credential = self.credential ?? session.configuration.urlCredentialStorage?.defaultCredential(for: challenge.protectionSpace)
|
||||
|
||||
if credential != nil {
|
||||
disposition = .useCredential
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
completionHandler(disposition, credential)
|
||||
}
|
||||
}
|
||||
|
||||
public enum HTTPMethod: String {
|
||||
case options = "OPTIONS"
|
||||
case get = "GET"
|
||||
case head = "HEAD"
|
||||
case post = "POST"
|
||||
case put = "PUT"
|
||||
case patch = "PATCH"
|
||||
case delete = "DELETE"
|
||||
case trace = "TRACE"
|
||||
case connect = "CONNECT"
|
||||
}
|
||||
|
||||
public protocol ParameterEncoding {
|
||||
func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest
|
||||
}
|
||||
|
||||
private class URLEncoding: ParameterEncoding {
|
||||
func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest {
|
||||
|
||||
var urlRequest = urlRequest
|
||||
|
||||
guard let parameters = parameters else { return urlRequest }
|
||||
|
||||
guard let url = urlRequest.url else {
|
||||
throw DownloadException.requestMissingURL
|
||||
}
|
||||
|
||||
if var urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false), !parameters.isEmpty {
|
||||
urlComponents.queryItems = APIHelper.mapValuesToQueryItems(parameters)
|
||||
urlRequest.url = urlComponents.url
|
||||
}
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
}
|
||||
|
||||
private class FormDataEncoding: ParameterEncoding {
|
||||
|
||||
let contentTypeForFormPart: (_ fileURL: URL) -> String?
|
||||
|
||||
init(contentTypeForFormPart: @escaping (_ fileURL: URL) -> String?) {
|
||||
self.contentTypeForFormPart = contentTypeForFormPart
|
||||
}
|
||||
|
||||
func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest {
|
||||
|
||||
var urlRequest = urlRequest
|
||||
|
||||
guard let parameters = parameters, !parameters.isEmpty else {
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
let boundary = "Boundary-\(UUID().uuidString)"
|
||||
|
||||
urlRequest.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
for (key, value) in parameters {
|
||||
switch value {
|
||||
case let fileURL as URL:
|
||||
|
||||
urlRequest = try configureFileUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
fileURL: fileURL
|
||||
)
|
||||
|
||||
case let string as String:
|
||||
|
||||
if let data = string.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
}
|
||||
|
||||
case let number as NSNumber:
|
||||
|
||||
if let data = number.stringValue.data(using: .utf8) {
|
||||
urlRequest = configureDataUploadRequest(
|
||||
urlRequest: urlRequest,
|
||||
boundary: boundary,
|
||||
name: key,
|
||||
data: data
|
||||
)
|
||||
}
|
||||
|
||||
default:
|
||||
fatalError("Unprocessable value \(value) with key \(key)")
|
||||
}
|
||||
}
|
||||
|
||||
var body = urlRequest.httpBody.orEmpty
|
||||
|
||||
body.append("\r\n--\(boundary)--\r\n")
|
||||
|
||||
urlRequest.httpBody = body
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
private func configureFileUploadRequest(urlRequest: URLRequest, boundary: String, name: String, fileURL: URL) throws -> URLRequest {
|
||||
|
||||
var urlRequest = urlRequest
|
||||
|
||||
var body = urlRequest.httpBody.orEmpty
|
||||
|
||||
let fileData = try Data(contentsOf: fileURL)
|
||||
|
||||
let mimetype = contentTypeForFormPart(fileURL) ?? mimeType(for: fileURL)
|
||||
|
||||
let fileName = fileURL.lastPathComponent
|
||||
|
||||
// If we already added something then we need an additional newline.
|
||||
if body.count > 0 {
|
||||
body.append("\r\n")
|
||||
}
|
||||
|
||||
// Value boundary.
|
||||
body.append("--\(boundary)\r\n")
|
||||
|
||||
// Value headers.
|
||||
body.append("Content-Disposition: form-data; name=\"\(name)\"; filename=\"\(fileName)\"\r\n")
|
||||
body.append("Content-Type: \(mimetype)\r\n")
|
||||
|
||||
// Separate headers and body.
|
||||
body.append("\r\n")
|
||||
|
||||
// The value data.
|
||||
body.append(fileData)
|
||||
|
||||
urlRequest.httpBody = body
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
|
||||
private func configureDataUploadRequest(urlRequest: URLRequest, boundary: String, name: String, data: Data) -> URLRequest {
|
||||
|
||||
var urlRequest = urlRequest
|
||||
|
||||
var body = urlRequest.httpBody.orEmpty
|
||||
|
||||
// If we already added something then we need an additional newline.
|
||||
if body.count > 0 {
|
||||
body.append("\r\n")
|
||||
}
|
||||
|
||||
// Value boundary.
|
||||
body.append("--\(boundary)\r\n")
|
||||
|
||||
// Value headers.
|
||||
body.append("Content-Disposition: form-data; name=\"\(name)\"\r\n")
|
||||
|
||||
// Separate headers and body.
|
||||
body.append("\r\n")
|
||||
|
||||
// The value data.
|
||||
body.append(data)
|
||||
|
||||
urlRequest.httpBody = body
|
||||
|
||||
return urlRequest
|
||||
|
||||
}
|
||||
|
||||
func mimeType(for url: URL) -> String {
|
||||
let pathExtension = url.pathExtension
|
||||
|
||||
if let uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, pathExtension as NSString, nil)?.takeRetainedValue() {
|
||||
if let mimetype = UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType)?.takeRetainedValue() {
|
||||
return mimetype as String
|
||||
}
|
||||
}
|
||||
return "application/octet-stream"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class FormURLEncoding: ParameterEncoding {
|
||||
func encode(_ urlRequest: URLRequest, with parameters: [String: Any]?) throws -> URLRequest {
|
||||
|
||||
var urlRequest = urlRequest
|
||||
|
||||
var requestBodyComponents = URLComponents()
|
||||
requestBodyComponents.queryItems = APIHelper.mapValuesToQueryItems(parameters ?? [:])
|
||||
|
||||
if urlRequest.value(forHTTPHeaderField: "Content-Type") == nil {
|
||||
urlRequest.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
|
||||
}
|
||||
|
||||
urlRequest.httpBody = requestBodyComponents.query?.data(using: .utf8)
|
||||
|
||||
return urlRequest
|
||||
}
|
||||
}
|
||||
|
||||
private extension Data {
|
||||
/// Append string to Data
|
||||
///
|
||||
/// Rather than littering my code with calls to `dataUsingEncoding` to convert strings to Data, and then add that data to the Data, this wraps it in a nice convenient little extension to Data. This converts using UTF-8.
|
||||
///
|
||||
/// - parameter string: The string to be added to the `Data`.
|
||||
|
||||
mutating func append(_ string: String) {
|
||||
if let data = string.data(using: .utf8) {
|
||||
append(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension Optional where Wrapped == Data {
|
||||
var orEmpty: Data {
|
||||
self ?? Data()
|
||||
}
|
||||
}
|
||||
|
||||
extension JSONDataEncoding: ParameterEncoding {}
|
141
samples/client/petstore/swift5/x-swift-hashable/README.md
Normal file
141
samples/client/petstore/swift5/x-swift-hashable/README.md
Normal file
@ -0,0 +1,141 @@
|
||||
# Swift5 API client for PetstoreClient
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
## Overview
|
||||
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client.
|
||||
|
||||
- API version: 1.0.0
|
||||
- Package version:
|
||||
- Build package: org.openapitools.codegen.languages.Swift5ClientCodegen
|
||||
|
||||
## Installation
|
||||
|
||||
### Carthage
|
||||
|
||||
Run `carthage update`
|
||||
|
||||
### CocoaPods
|
||||
|
||||
Run `pod install`
|
||||
|
||||
## Documentation for API Endpoints
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Class | Method | HTTP request | Description
|
||||
------------ | ------------- | ------------- | -------------
|
||||
*AnotherFakeAPI* | [**call123testSpecialTags**](docs/AnotherFakeAPI.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
*FakeAPI* | [**fakeOuterBooleanSerialize**](docs/FakeAPI.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
|
||||
*FakeAPI* | [**fakeOuterCompositeSerialize**](docs/FakeAPI.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
|
||||
*FakeAPI* | [**fakeOuterNumberSerialize**](docs/FakeAPI.md#fakeouternumberserialize) | **POST** /fake/outer/number |
|
||||
*FakeAPI* | [**fakeOuterStringSerialize**](docs/FakeAPI.md#fakeouterstringserialize) | **POST** /fake/outer/string |
|
||||
*FakeAPI* | [**testBodyWithFileSchema**](docs/FakeAPI.md#testbodywithfileschema) | **PUT** /fake/body-with-file-schema |
|
||||
*FakeAPI* | [**testBodyWithQueryParams**](docs/FakeAPI.md#testbodywithqueryparams) | **PUT** /fake/body-with-query-params |
|
||||
*FakeAPI* | [**testClientModel**](docs/FakeAPI.md#testclientmodel) | **PATCH** /fake | To test \"client\" model
|
||||
*FakeAPI* | [**testEndpointParameters**](docs/FakeAPI.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
|
||||
*FakeAPI* | [**testEnumParameters**](docs/FakeAPI.md#testenumparameters) | **GET** /fake | To test enum parameters
|
||||
*FakeAPI* | [**testGroupParameters**](docs/FakeAPI.md#testgroupparameters) | **DELETE** /fake | Fake endpoint to test group parameters (optional)
|
||||
*FakeAPI* | [**testInlineAdditionalProperties**](docs/FakeAPI.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
|
||||
*FakeAPI* | [**testJsonFormData**](docs/FakeAPI.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
|
||||
*FakeClassnameTags123API* | [**testClassname**](docs/FakeClassnameTags123API.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
|
||||
*PetAPI* | [**addPet**](docs/PetAPI.md#addpet) | **POST** /pet | Add a new pet to the store
|
||||
*PetAPI* | [**deletePet**](docs/PetAPI.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
|
||||
*PetAPI* | [**findPetsByStatus**](docs/PetAPI.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
|
||||
*PetAPI* | [**findPetsByTags**](docs/PetAPI.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
|
||||
*PetAPI* | [**getPetById**](docs/PetAPI.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
|
||||
*PetAPI* | [**updatePet**](docs/PetAPI.md#updatepet) | **PUT** /pet | Update an existing pet
|
||||
*PetAPI* | [**updatePetWithForm**](docs/PetAPI.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
|
||||
*PetAPI* | [**uploadFile**](docs/PetAPI.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
|
||||
*PetAPI* | [**uploadFileWithRequiredFile**](docs/PetAPI.md#uploadfilewithrequiredfile) | **POST** /fake/{petId}/uploadImageWithRequiredFile | uploads an image (required)
|
||||
*StoreAPI* | [**deleteOrder**](docs/StoreAPI.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
|
||||
*StoreAPI* | [**getInventory**](docs/StoreAPI.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
|
||||
*StoreAPI* | [**getOrderById**](docs/StoreAPI.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
|
||||
*StoreAPI* | [**placeOrder**](docs/StoreAPI.md#placeorder) | **POST** /store/order | Place an order for a pet
|
||||
*UserAPI* | [**createUser**](docs/UserAPI.md#createuser) | **POST** /user | Create user
|
||||
*UserAPI* | [**createUsersWithArrayInput**](docs/UserAPI.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
|
||||
*UserAPI* | [**createUsersWithListInput**](docs/UserAPI.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
|
||||
*UserAPI* | [**deleteUser**](docs/UserAPI.md#deleteuser) | **DELETE** /user/{username} | Delete user
|
||||
*UserAPI* | [**getUserByName**](docs/UserAPI.md#getuserbyname) | **GET** /user/{username} | Get user by user name
|
||||
*UserAPI* | [**loginUser**](docs/UserAPI.md#loginuser) | **GET** /user/login | Logs user into the system
|
||||
*UserAPI* | [**logoutUser**](docs/UserAPI.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
|
||||
*UserAPI* | [**updateUser**](docs/UserAPI.md#updateuser) | **PUT** /user/{username} | Updated user
|
||||
|
||||
|
||||
## Documentation For Models
|
||||
|
||||
- [AdditionalPropertiesClass](docs/AdditionalPropertiesClass.md)
|
||||
- [Animal](docs/Animal.md)
|
||||
- [AnimalFarm](docs/AnimalFarm.md)
|
||||
- [ApiResponse](docs/ApiResponse.md)
|
||||
- [ArrayOfArrayOfNumberOnly](docs/ArrayOfArrayOfNumberOnly.md)
|
||||
- [ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md)
|
||||
- [ArrayTest](docs/ArrayTest.md)
|
||||
- [Capitalization](docs/Capitalization.md)
|
||||
- [Cat](docs/Cat.md)
|
||||
- [CatAllOf](docs/CatAllOf.md)
|
||||
- [Category](docs/Category.md)
|
||||
- [ClassModel](docs/ClassModel.md)
|
||||
- [Client](docs/Client.md)
|
||||
- [Dog](docs/Dog.md)
|
||||
- [DogAllOf](docs/DogAllOf.md)
|
||||
- [EnumArrays](docs/EnumArrays.md)
|
||||
- [EnumClass](docs/EnumClass.md)
|
||||
- [EnumTest](docs/EnumTest.md)
|
||||
- [File](docs/File.md)
|
||||
- [FileSchemaTestClass](docs/FileSchemaTestClass.md)
|
||||
- [FormatTest](docs/FormatTest.md)
|
||||
- [HasOnlyReadOnly](docs/HasOnlyReadOnly.md)
|
||||
- [List](docs/List.md)
|
||||
- [MapTest](docs/MapTest.md)
|
||||
- [MixedPropertiesAndAdditionalPropertiesClass](docs/MixedPropertiesAndAdditionalPropertiesClass.md)
|
||||
- [Model200Response](docs/Model200Response.md)
|
||||
- [Name](docs/Name.md)
|
||||
- [NumberOnly](docs/NumberOnly.md)
|
||||
- [Order](docs/Order.md)
|
||||
- [OuterComposite](docs/OuterComposite.md)
|
||||
- [OuterEnum](docs/OuterEnum.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [ReadOnlyFirst](docs/ReadOnlyFirst.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [SpecialModelName](docs/SpecialModelName.md)
|
||||
- [StringBooleanMap](docs/StringBooleanMap.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeHolderDefault](docs/TypeHolderDefault.md)
|
||||
- [TypeHolderExample](docs/TypeHolderExample.md)
|
||||
- [User](docs/User.md)
|
||||
|
||||
|
||||
## Documentation For Authorization
|
||||
|
||||
|
||||
## api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
## api_key_query
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key_query
|
||||
- **Location**: URL query string
|
||||
|
||||
## http_basic_test
|
||||
|
||||
- **Type**: HTTP basic authentication
|
||||
|
||||
## petstore_auth
|
||||
|
||||
- **Type**: OAuth
|
||||
- **Flow**: implicit
|
||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||
- **Scopes**:
|
||||
- **write:pets**: modify pets in your account
|
||||
- **read:pets**: read your pets
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesAnyType
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesArray
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesBoolean
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# AdditionalPropertiesClass
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**mapString** | **[String: String]** | | [optional]
|
||||
**mapMapString** | [String: [String: String]] | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesInteger
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesNumber
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesObject
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# AdditionalPropertiesString
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**name** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Animal
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**className** | **String** | |
|
||||
**color** | **String** | | [optional] [default to "red"]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
# AnimalFarm
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
# AnotherFakeAPI
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io:80/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**call123testSpecialTags**](AnotherFakeAPI.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
|
||||
|
||||
|
||||
# **call123testSpecialTags**
|
||||
```swift
|
||||
open class func call123testSpecialTags(body: Client, completion: @escaping (_ data: Client?, _ error: Error?) -> Void)
|
||||
```
|
||||
|
||||
To test special tags
|
||||
|
||||
To test special tags and operation ID starting with number
|
||||
|
||||
### Example
|
||||
```swift
|
||||
// The following code samples are still beta. For any issue, please report via http://github.com/OpenAPITools/openapi-generator/issues/new
|
||||
import PetstoreClient
|
||||
|
||||
let body = Client(client: "client_example") // Client | client model
|
||||
|
||||
// To test special tags
|
||||
AnotherFakeAPI.call123testSpecialTags(body: body) { (response, error) in
|
||||
guard error == nil else {
|
||||
print(error)
|
||||
return
|
||||
}
|
||||
|
||||
if (response) {
|
||||
dump(response)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**body** | [**Client**](Client.md) | client model |
|
||||
|
||||
### Return type
|
||||
|
||||
[**Client**](Client.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: application/json
|
||||
- **Accept**: application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ApiResponse
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**code** | **Int** | | [optional]
|
||||
**type** | **String** | | [optional]
|
||||
**message** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ArrayOfArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayArrayNumber** | [[Double]] | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# ArrayOfNumberOnly
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayNumber** | **[Double]** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,12 @@
|
||||
# ArrayTest
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**arrayOfString** | **[String]** | | [optional]
|
||||
**arrayArrayOfInteger** | [[Int64]] | | [optional]
|
||||
**arrayArrayOfModel** | [[ReadOnlyFirst]] | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -0,0 +1,10 @@
|
||||
# BigCat
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**kind** | **String** | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
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