diff --git a/Docs/ConfigOptions.md b/Docs/ConfigOptions.md
index b3d5b57b..afba4307 100644
--- a/Docs/ConfigOptions.md
+++ b/Docs/ConfigOptions.md
@@ -96,6 +96,7 @@ Below you can find the complete documentation for all available options.
- [exclude](#pathsexclude)
- [include](#pathsinclude)
- [filenameTemplate](#pathsfilenametemplate)
+ - [useDataForMultipartFormDataRequestBody](#pathsusedataformultipartformdatarequestbody)
- [rename](#rename)
- [properties](#renameproperties)
- [parameters](#renameparameters)
@@ -961,6 +962,20 @@ paths:
+## paths.useDataForMultipartFormDataRequestBody
+
+**Type:** Bool
+**Default:** `true`
+
+If `false`, CreateAPI generates request body structures for "multipart/form-data" format just like it would for "application/json".
+Otherwise the `body` of the generated `Request` will use `Data`. The default value is `true`.
+
+When using Get and it's `APIClient`, because Multipart Form Data isn't supported from the `Request` `body` property, it is best to leave this option set to `true`.
+If however you have implemented your API Client, and you prefer to use structured `Codable` types to encode a Multipart Form Data request body, setting this value to `false` can be more convenient.
+You might also need to use the [`dataTypes`](#datatypes) option to customise the type used to represent `binary` data.
+
+
+
# Rename
diff --git a/Sources/CreateAPI/Generator/Generator+DataTypes.swift b/Sources/CreateAPI/Generator/Generator+DataTypes.swift
index 74379181..513fe9ea 100644
--- a/Sources/CreateAPI/Generator/Generator+DataTypes.swift
+++ b/Sources/CreateAPI/Generator/Generator+DataTypes.swift
@@ -7,6 +7,8 @@ extension Generator {
switch format {
case .byte:
return builtInType("Data", format: "byte", overrides: options.dataTypes.string)
+ case .binary:
+ return builtInType("Data", format: "binary", overrides: options.dataTypes.string)
case .date where options.useNaiveDate:
setNaiveDateNeeded()
return .builtin("NaiveDate")
@@ -20,7 +22,7 @@ extension Generator {
return builtInType("UUID", format: "uuid", overrides: options.dataTypes.string)
case .other(let format):
return builtInType("String", format: format, overrides: options.dataTypes.string)
- case .generic, .binary, .password:
+ case .generic, .password:
return .builtin("String")
}
}
diff --git a/Sources/CreateAPI/Generator/Generator+Paths.swift b/Sources/CreateAPI/Generator/Generator+Paths.swift
index da901517..b572712b 100644
--- a/Sources/CreateAPI/Generator/Generator+Paths.swift
+++ b/Sources/CreateAPI/Generator/Generator+Paths.swift
@@ -683,7 +683,17 @@ extension Generator {
return nil
}
- if let (content, contentType) = firstContent(for: [.json, .jsonapi, .other("application/scim+json"), .other("application/json"), .form]) {
+ var structuredRequestBodySupportedTypes: [OpenAPI.ContentType] = [
+ .json,
+ .jsonapi,
+ .other("application/scim+json"),
+ .other("application/json"),
+ .form
+ ]
+ if !options.paths.useDataForMultipartFormDataRequestBody {
+ structuredRequestBodySupportedTypes.append(.multipartForm)
+ }
+ if let (content, contentType) = firstContent(for: structuredRequestBodySupportedTypes) {
let schema: JSONSchema
switch content.schema {
case .a(let reference):
@@ -708,9 +718,6 @@ extension Generator {
}
return BodyType(type: property.type.name, nested: property.nested)
}
- if firstContent(for: [.multipartForm]) != nil {
- return BodyType("Data") // Currently isn't supported
- }
if firstContent(for: [.css, .csv, .form, .html, .javascript, .txt, .xml, .yaml, .anyText, .other("application/jwt"), .other("image/svg+xml"), .other("text/xml"), .other("plain/text")]) != nil {
return BodyType("String")
}
diff --git a/Sources/CreateOptions/ConfigOptions.swift b/Sources/CreateOptions/ConfigOptions.swift
index 041b97f0..7ea26c79 100644
--- a/Sources/CreateOptions/ConfigOptions.swift
+++ b/Sources/CreateOptions/ConfigOptions.swift
@@ -672,6 +672,14 @@ public struct ConfigOptions: ParsableConfiguration {
///
///
@Option public var filenameTemplate: String = "%0.swift"
+
+ /// If `false`, CreateAPI generates request body structures for "multipart/form-data" format just like it would for "application/json".
+ /// Otherwise the `body` of the generated `Request` will use `Data`. The default value is `true`.
+ ///
+ /// When using Get and it's `APIClient`, because Multipart Form Data isn't supported from the `Request` `body` property, it is best to leave this option set to `true`.
+ /// If however you have implemented your API Client, and you prefer to use structured `Codable` types to encode a Multipart Form Data request body, setting this value to `false` can be more convenient.
+ /// You might also need to use the [`dataTypes`](#datatypes) option to customise the type used to represent `binary` data.
+ @Option public var useDataForMultipartFormDataRequestBody: Bool = true
}
@Option public var rename: Rename
diff --git a/Tests/CreateAPITests/GenerateOptionsTests.swift b/Tests/CreateAPITests/GenerateOptionsTests.swift
index 2fe76fc0..c43dbdc4 100644
--- a/Tests/CreateAPITests/GenerateOptionsTests.swift
+++ b/Tests/CreateAPITests/GenerateOptionsTests.swift
@@ -388,6 +388,19 @@ final class GenerateOptionsTests: GenerateTestCase {
"""
)
}
+
+ func testEdgecasesMultipartFormdata() throws {
+ try snapshot(
+ spec: .edgecases,
+ name: "edgecases-multipart-formdata",
+ configuration: """
+ generate: ["paths"]
+ paths:
+ useDataForMultipartFormDataRequestBody: false
+ """
+ )
+ }
+
func testEdgecasesGenerateCodingKeys() throws {
try snapshot(
diff --git a/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Entities/FormatTest.swift
index 2c229758..604ae16c 100644
--- a/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ struct FormatTest: Codable {
var double: Double?
var string: String?
var byte: Data
- var binary: String?
+ var binary: Data?
var date: NaiveDate
var dateTime: Date?
var uuid: UUID?
var password: String
- init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift
index 823fb3e2..bf4c2d19 100644
--- a/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-change-access-control/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
var byte: Data
/// None
- var binary: String?
+ var binary: Data?
/// None
var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
var callback: String?
- init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Entities/FormatTest.swift
index abdee692..176c70a5 100644
--- a/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Paths/PathsFake.swift
index 848384c5..5ee6be2d 100644
--- a/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-coding-keys/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-data-types/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-data-types/Sources/Entities/FormatTest.swift
index 99d54e04..af8c8aba 100644
--- a/Tests/Support/Snapshots/edgecases-data-types/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-data-types/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: String
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: AnyJSON?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Double? = nil, int64: Int? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: String, binary: String? = nil, date: NaiveDate, dateTime: AnyJSON? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Double? = nil, int64: Int? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: String, binary: Data? = nil, date: NaiveDate, dateTime: AnyJSON? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(String.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(AnyJSON.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-data-types/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-data-types/Sources/Paths/PathsFake.swift
index 0ef152b7..baf1f6df 100644
--- a/Tests/Support/Snapshots/edgecases-data-types/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-data-types/Sources/Paths/PathsFake.swift
@@ -76,7 +76,7 @@ extension Paths {
/// None
public var byte: String
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -86,7 +86,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Double? = nil, int64: Int? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: String, binary: String? = nil, date: NaiveDate? = nil, dateTime: AnyJSON? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Double? = nil, int64: Int? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: String, binary: Data? = nil, date: NaiveDate? = nil, dateTime: AnyJSON? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-default/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-default/Sources/Entities/FormatTest.swift
index af140fcf..b85b0075 100644
--- a/Tests/Support/Snapshots/edgecases-default/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-default/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-default/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-default/Sources/Paths/PathsFake.swift
index 298a84c5..012b600d 100644
--- a/Tests/Support/Snapshots/edgecases-default/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-default/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Entities/FormatTest.swift
index af140fcf..b85b0075 100644
--- a/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Paths/PathsFake.swift
index 719296ba..7138dc37 100644
--- a/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-disable-acronyms/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Entities/FormatTest.swift
index af140fcf..b85b0075 100644
--- a/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Paths/PathsFake.swift
index 0b73cb63..ba82643c 100644
--- a/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-disable-enums/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Entities/FormatTest.swift
index 95f734bb..4ee90c2a 100644
--- a/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Paths/PathsFake.swift
index c529fb3e..74e8e466 100644
--- a/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-indent-with-two-width-spaces/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Extensions/Paths.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Extensions/Paths.swift
new file mode 100644
index 00000000..d7fbcc7c
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Extensions/Paths.swift
@@ -0,0 +1,10 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+public enum Paths {}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsFake.swift
new file mode 100644
index 00000000..d65912fa
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsFake.swift
@@ -0,0 +1,132 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths {
+ public static var fake: Fake {
+ Fake(path: "/fake")
+ }
+
+ public struct Fake {
+ /// Path: `/fake`
+ public let path: String
+
+ /// To test enum parameters
+ public func get(parameters: GetParameters? = nil) -> Request {
+ Request(path: path, method: "GET", query: parameters?.asQuery, id: "testEnumParameters")
+ }
+
+ public struct GetParameters {
+ public var enumQueryStringArray: [EnumQueryStringArray]?
+ public var enumQueryString: EnumQueryString?
+ public var enumQueryInteger: Int32?
+
+ public enum EnumQueryStringArray: String, Codable, CaseIterable {
+ case greaterThan = ">"
+ case dollar = "$"
+ }
+
+ public enum EnumQueryString: String, Codable, CaseIterable {
+ case abc = "_abc"
+ case minusefg = "-efg"
+ case xyz = "(xyz)"
+ }
+
+ public init(enumQueryStringArray: [EnumQueryStringArray]? = nil, enumQueryString: EnumQueryString? = nil, enumQueryInteger: Int32? = nil) {
+ self.enumQueryStringArray = enumQueryStringArray
+ self.enumQueryString = enumQueryString
+ self.enumQueryInteger = enumQueryInteger
+ }
+
+ public var asQuery: [(String, String?)] {
+ let encoder = URLQueryEncoder()
+ encoder.encode(enumQueryStringArray, forKey: "enum_query_string_array")
+ encoder.encode(enumQueryString, forKey: "enum_query_string")
+ encoder.encode(enumQueryInteger, forKey: "enum_query_integer")
+ return encoder.items
+ }
+ }
+
+ /// Fake endpoint for testing various parameters
+ public func post(_ body: PostRequest? = nil) -> Request {
+ Request(path: path, method: "POST", body: body.map(URLQueryEncoder.encode)?.percentEncodedQuery, id: "testEndpointParameters")
+ }
+
+ public struct PostRequest: Encodable {
+ /// None
+ public var integer: Int?
+ /// None
+ public var int32: Int32?
+ /// None
+ public var int64: Int64?
+ /// None
+ public var number: Double
+ /// None
+ public var float: Float?
+ /// None
+ public var double: Double
+ /// None
+ public var string: String?
+ /// None
+ public var patternWithoutDelimiter: String
+ /// None
+ public var byte: Data
+ /// None
+ public var binary: Data?
+ /// None
+ public var date: NaiveDate?
+ /// None
+ public var dateTime: Date?
+ /// None
+ public var password: String?
+ /// None
+ public var callback: String?
+
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ self.integer = integer
+ self.int32 = int32
+ self.int64 = int64
+ self.number = number
+ self.float = float
+ self.double = double
+ self.string = string
+ self.patternWithoutDelimiter = patternWithoutDelimiter
+ self.byte = byte
+ self.binary = binary
+ self.date = date
+ self.dateTime = dateTime
+ self.password = password
+ self.callback = callback
+ }
+
+ public var asQuery: [(String, String?)] {
+ let encoder = URLQueryEncoder()
+ encoder.encode(integer, forKey: "integer")
+ encoder.encode(int32, forKey: "int32")
+ encoder.encode(int64, forKey: "int64")
+ encoder.encode(number, forKey: "number")
+ encoder.encode(float, forKey: "float")
+ encoder.encode(double, forKey: "double")
+ encoder.encode(string, forKey: "string")
+ encoder.encode(patternWithoutDelimiter, forKey: "pattern_without_delimiter")
+ encoder.encode(byte, forKey: "byte")
+ encoder.encode(binary, forKey: "binary")
+ encoder.encode(date, forKey: "date")
+ encoder.encode(dateTime, forKey: "dateTime")
+ encoder.encode(password, forKey: "password")
+ encoder.encode(callback, forKey: "callback")
+ return encoder.items
+ }
+ }
+
+ /// To test "client" model
+ public func patch(_ body: edgecases_multipart_formdata.Client) -> Request {
+ Request(path: path, method: "PATCH", body: body, id: "testClientModel")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPet.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPet.swift
new file mode 100644
index 00000000..621f8d3f
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPet.swift
@@ -0,0 +1,29 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths {
+ public static var pet: Pet {
+ Pet(path: "/pet")
+ }
+
+ public struct Pet {
+ /// Path: `/pet`
+ public let path: String
+
+ /// Add a new pet to the store
+ public func post(_ body: edgecases_multipart_formdata.Pet) -> Request {
+ Request(path: path, method: "POST", body: body, id: "addPet")
+ }
+
+ /// Update an existing pet
+ public func put(_ body: edgecases_multipart_formdata.Pet) -> Request {
+ Request(path: path, method: "PUT", body: body, id: "updatePet")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByStatus.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByStatus.swift
new file mode 100644
index 00000000..9f9cfc09
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByStatus.swift
@@ -0,0 +1,38 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Pet {
+ public var findByStatus: FindByStatus {
+ FindByStatus(path: path + "/findByStatus")
+ }
+
+ public struct FindByStatus {
+ /// Path: `/pet/findByStatus`
+ public let path: String
+
+ /// Finds Pets by status
+ ///
+ /// Multiple status values can be provided with comma separated strings
+ public func get(status: [Status]) -> Request<[edgecases_multipart_formdata.Pet]> {
+ Request(path: path, method: "GET", query: makeGetQuery(status), id: "findPetsByStatus")
+ }
+
+ private func makeGetQuery(_ status: [Status]) -> [(String, String?)] {
+ let encoder = URLQueryEncoder()
+ encoder.encode(status, forKey: "status", explode: false)
+ return encoder.items
+ }
+
+ public enum Status: String, Codable, CaseIterable {
+ case available
+ case pending
+ case sold
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByStatus2.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByStatus2.swift
new file mode 100644
index 00000000..a555c6f4
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByStatus2.swift
@@ -0,0 +1,38 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Pet {
+ public var findByStatus2: FindByStatus2 {
+ FindByStatus2(path: path + "/findByStatus2")
+ }
+
+ public struct FindByStatus2 {
+ /// Path: `/pet/findByStatus2`
+ public let path: String
+
+ /// Finds Pets by status
+ ///
+ /// Multiple status values can be provided with comma separated strings
+ public func get(status: [Status]? = nil) -> Request<[edgecases_multipart_formdata.Pet]> {
+ Request(path: path, method: "GET", query: makeGetQuery(status), id: "findPetsByStatus2")
+ }
+
+ private func makeGetQuery(_ status: [Status]?) -> [(String, String?)] {
+ let encoder = URLQueryEncoder()
+ encoder.encode(status, forKey: "status")
+ return encoder.items
+ }
+
+ public enum Status: String, Codable, CaseIterable {
+ case available
+ case pending
+ case sold
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByTags.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByTags.swift
new file mode 100644
index 00000000..705622f6
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetFindByTags.swift
@@ -0,0 +1,32 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Pet {
+ public var findByTags: FindByTags {
+ FindByTags(path: path + "/findByTags")
+ }
+
+ public struct FindByTags {
+ /// Path: `/pet/findByTags`
+ public let path: String
+
+ /// Finds Pets by tags
+ ///
+ /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ public func get(tags: [String]) -> Request<[edgecases_multipart_formdata.Pet]> {
+ Request(path: path, method: "GET", query: makeGetQuery(tags), id: "findPetsByTags")
+ }
+
+ private func makeGetQuery(_ tags: [String]) -> [(String, String?)] {
+ let encoder = URLQueryEncoder()
+ encoder.encode(tags, forKey: "tags", explode: false)
+ return encoder.items
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetWithPetID.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetWithPetID.swift
new file mode 100644
index 00000000..5d35b86d
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetWithPetID.swift
@@ -0,0 +1,55 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Pet {
+ public func petID(_ petID: Int) -> WithPetID {
+ WithPetID(path: "\(path)/\(petID)")
+ }
+
+ public struct WithPetID {
+ /// Path: `/pet/{petId}`
+ public let path: String
+
+ /// Find pet by ID
+ ///
+ /// Returns a single pet
+ public var get: Request {
+ Request(path: path, method: "GET", id: "getPetById")
+ }
+
+ /// Updates a pet in the store with form data
+ public func post(_ body: PostRequest? = nil) -> Request {
+ Request(path: path, method: "POST", body: body.map(URLQueryEncoder.encode)?.percentEncodedQuery, id: "updatePetWithForm")
+ }
+
+ public struct PostRequest: Encodable {
+ /// Updated name of the pet
+ public var name: String?
+ /// Updated status of the pet
+ public var status: String?
+
+ public init(name: String? = nil, status: String? = nil) {
+ self.name = name
+ self.status = status
+ }
+
+ public var asQuery: [(String, String?)] {
+ let encoder = URLQueryEncoder()
+ encoder.encode(name, forKey: "name")
+ encoder.encode(status, forKey: "status")
+ return encoder.items
+ }
+ }
+
+ /// Deletes a pet
+ public var delete: Request {
+ Request(path: path, method: "DELETE", id: "deletePet")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetWithPetIDUploadImage.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetWithPetIDUploadImage.swift
new file mode 100644
index 00000000..e0cfd8d8
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsPetWithPetIDUploadImage.swift
@@ -0,0 +1,42 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Pet.WithPetID {
+ public var uploadImage: UploadImage {
+ UploadImage(path: path + "/uploadImage")
+ }
+
+ public struct UploadImage {
+ /// Path: `/pet/{petId}/uploadImage`
+ public let path: String
+
+ /// Uploads an image
+ public func post(_ body: PostRequest? = nil) -> Request {
+ Request(path: path, method: "POST", body: body, id: "uploadFile")
+ }
+
+ public struct PostRequest: Encodable {
+ /// Additional data to pass to server
+ public var additionalMetadata: String?
+ /// File to upload
+ public var file: Data?
+
+ public init(additionalMetadata: String? = nil, file: Data? = nil) {
+ self.additionalMetadata = additionalMetadata
+ self.file = file
+ }
+
+ public func encode(to encoder: Encoder) throws {
+ var values = encoder.container(keyedBy: StringCodingKey.self)
+ try values.encodeIfPresent(additionalMetadata, forKey: "additionalMetadata")
+ try values.encodeIfPresent(file, forKey: "file")
+ }
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStore.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStore.swift
new file mode 100644
index 00000000..23c01c9f
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStore.swift
@@ -0,0 +1,19 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths {
+ public static var store: Store {
+ Store(path: "/store")
+ }
+
+ public struct Store {
+ /// Path: `/store`
+ public let path: String
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreInventory.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreInventory.swift
new file mode 100644
index 00000000..7e2f1af8
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreInventory.swift
@@ -0,0 +1,26 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Store {
+ public var inventory: Inventory {
+ Inventory(path: path + "/inventory")
+ }
+
+ public struct Inventory {
+ /// Path: `/store/inventory`
+ public let path: String
+
+ /// Returns pet inventories by status
+ ///
+ /// Returns a map of status codes to quantities
+ public var get: Request<[String: Int32]> {
+ Request(path: path, method: "GET", id: "getInventory")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreOrder.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreOrder.swift
new file mode 100644
index 00000000..d2cc472f
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreOrder.swift
@@ -0,0 +1,24 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Store {
+ public var order: Order {
+ Order(path: path + "/order")
+ }
+
+ public struct Order {
+ /// Path: `/store/order`
+ public let path: String
+
+ /// Place an order for a pet
+ public func post(_ body: edgecases_multipart_formdata.Order) -> Request {
+ Request(path: path, method: "POST", body: body, id: "placeOrder")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreOrderWithOrder.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreOrderWithOrder.swift
new file mode 100644
index 00000000..81fb12f0
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsStoreOrderWithOrder.swift
@@ -0,0 +1,33 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.Store.Order {
+ public func orderID(_ orderID: Int) -> WithOrder {
+ WithOrder(path: "\(path)/order-\(orderID)")
+ }
+
+ public struct WithOrder {
+ /// Path: `/store/order/order-{order_id}`
+ public let path: String
+
+ /// Find purchase order by ID
+ ///
+ /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ public var get: Request {
+ Request(path: path, method: "GET", id: "getOrderById")
+ }
+
+ /// Delete purchase order by ID
+ ///
+ /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ public var delete: Request {
+ Request(path: path, method: "DELETE", id: "deleteOrder")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUser.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUser.swift
new file mode 100644
index 00000000..17ee1206
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUser.swift
@@ -0,0 +1,26 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths {
+ public static var user: User {
+ User(path: "/user")
+ }
+
+ public struct User {
+ /// Path: `/user`
+ public let path: String
+
+ /// Create user
+ ///
+ /// This can only be done by the logged in user.
+ public func post(_ body: edgecases_multipart_formdata.User) -> Request {
+ Request(path: path, method: "POST", body: body, id: "createUser")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserCreateWithArray.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserCreateWithArray.swift
new file mode 100644
index 00000000..af4d3d0d
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserCreateWithArray.swift
@@ -0,0 +1,24 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.User {
+ public var createWithArray: CreateWithArray {
+ CreateWithArray(path: path + "/createWithArray")
+ }
+
+ public struct CreateWithArray {
+ /// Path: `/user/createWithArray`
+ public let path: String
+
+ /// Creates list of users with given input array
+ public func post(_ body: [edgecases_multipart_formdata.User]) -> Request {
+ Request(path: path, method: "POST", body: body, id: "createUsersWithArrayInput")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserCreateWithList.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserCreateWithList.swift
new file mode 100644
index 00000000..bd86e363
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserCreateWithList.swift
@@ -0,0 +1,24 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.User {
+ public var createWithList: CreateWithList {
+ CreateWithList(path: path + "/createWithList")
+ }
+
+ public struct CreateWithList {
+ /// Path: `/user/createWithList`
+ public let path: String
+
+ /// Creates list of users with given input array
+ public func post(_ body: [edgecases_multipart_formdata.User]) -> Request {
+ Request(path: path, method: "POST", body: body, id: "createUsersWithListInput")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserLogin.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserLogin.swift
new file mode 100644
index 00000000..6019790c
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserLogin.swift
@@ -0,0 +1,32 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.User {
+ public var login: Login {
+ Login(path: path + "/login")
+ }
+
+ public struct Login {
+ /// Path: `/user/login`
+ public let path: String
+
+ /// Logs user into the system
+ public func get(username: String, password: String) -> Request {
+ Request(path: path, method: "GET", query: [("username", username), ("password", password)], id: "loginUser")
+ }
+
+ public enum GetResponseHeaders {
+ /// Calls per hour allowed by the user
+ @available(*, deprecated, message: "Deprecated")
+ public static let rateLimit = HTTPHeader(field: "X-Rate-Limit")
+ /// Date in UTC when toekn expires
+ public static let expiresAfter = HTTPHeader(field: "X-Expires-After")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserLogout.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserLogout.swift
new file mode 100644
index 00000000..bdc12f91
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserLogout.swift
@@ -0,0 +1,24 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.User {
+ public var logout: Logout {
+ Logout(path: path + "/logout")
+ }
+
+ public struct Logout {
+ /// Path: `/user/logout`
+ public let path: String
+
+ /// Logs out current logged in user session
+ public var get: Request {
+ Request(path: path, method: "GET", id: "logoutUser")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserWithUsername.swift b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserWithUsername.swift
new file mode 100644
index 00000000..0752de3e
--- /dev/null
+++ b/Tests/Support/Snapshots/edgecases-multipart-formdata/Paths/PathsUserWithUsername.swift
@@ -0,0 +1,38 @@
+// Generated by Create API
+// https://github.com/CreateAPI/CreateAPI
+
+import Foundation
+import NaiveDate
+import Get
+import HTTPHeaders
+import URLQueryEncoder
+
+extension Paths.User {
+ public func username(_ username: String) -> WithUsername {
+ WithUsername(path: "\(path)/\(username)")
+ }
+
+ public struct WithUsername {
+ /// Path: `/user/{username}`
+ public let path: String
+
+ /// Get user by user name
+ public var get: Request {
+ Request(path: path, method: "GET", id: "getUserByName")
+ }
+
+ /// Updated user
+ ///
+ /// This can only be done by the logged in user.
+ public func put(_ body: edgecases_multipart_formdata.User) -> Request {
+ Request(path: path, method: "PUT", body: body, id: "updateUser")
+ }
+
+ /// Delete user
+ ///
+ /// This can only be done by the logged in user.
+ public var delete: Request {
+ Request(path: path, method: "DELETE", id: "deleteUser")
+ }
+ }
+}
diff --git a/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Entities/FormatTest.swift
index af140fcf..b85b0075 100644
--- a/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Paths/PathsFake.swift
index 61eae4b8..b6614bba 100644
--- a/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-rename-properties/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-rename/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-rename/Sources/Entities/FormatTest.swift
index af140fcf..b85b0075 100644
--- a/Tests/Support/Snapshots/edgecases-rename/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-rename/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-rename/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-rename/Sources/Paths/PathsFake.swift
index 6d388244..0b951e42 100644
--- a/Tests/Support/Snapshots/edgecases-rename/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-rename/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-tabs/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-tabs/Sources/Entities/FormatTest.swift
index 746065f3..44c1888f 100644
--- a/Tests/Support/Snapshots/edgecases-tabs/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-tabs/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-tabs/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-tabs/Sources/Paths/PathsFake.swift
index 5f72abe0..5beca47c 100644
--- a/Tests/Support/Snapshots/edgecases-tabs/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-tabs/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64
diff --git a/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Entities/FormatTest.swift b/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Entities/FormatTest.swift
index af140fcf..b85b0075 100644
--- a/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Entities/FormatTest.swift
+++ b/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Entities/FormatTest.swift
@@ -13,13 +13,13 @@ public struct FormatTest: Codable {
public var double: Double?
public var string: String?
public var byte: Data
- public var binary: String?
+ public var binary: Data?
public var date: NaiveDate
public var dateTime: Date?
public var uuid: UUID?
public var password: String
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: String? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double? = nil, string: String? = nil, byte: Data, binary: Data? = nil, date: NaiveDate, dateTime: Date? = nil, uuid: UUID? = nil, password: String) {
self.integer = integer
self.int32 = int32
self.int64 = int64
@@ -45,7 +45,7 @@ public struct FormatTest: Codable {
self.double = try values.decodeIfPresent(Double.self, forKey: "double")
self.string = try values.decodeIfPresent(String.self, forKey: "string")
self.byte = try values.decode(Data.self, forKey: "byte")
- self.binary = try values.decodeIfPresent(String.self, forKey: "binary")
+ self.binary = try values.decodeIfPresent(Data.self, forKey: "binary")
self.date = try values.decode(NaiveDate.self, forKey: "date")
self.dateTime = try values.decodeIfPresent(Date.self, forKey: "dateTime")
self.uuid = try values.decodeIfPresent(UUID.self, forKey: "uuid")
diff --git a/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Paths/PathsFake.swift b/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Paths/PathsFake.swift
index 5a2396a4..e277128c 100644
--- a/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Paths/PathsFake.swift
+++ b/Tests/Support/Snapshots/edgecases-yaml-config/Sources/Paths/PathsFake.swift
@@ -77,7 +77,7 @@ extension Paths {
/// None
public var byte: Data
/// None
- public var binary: String?
+ public var binary: Data?
/// None
public var date: NaiveDate?
/// None
@@ -87,7 +87,7 @@ extension Paths {
/// None
public var callback: String?
- public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: String? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
+ public init(integer: Int? = nil, int32: Int32? = nil, int64: Int64? = nil, number: Double, float: Float? = nil, double: Double, string: String? = nil, patternWithoutDelimiter: String, byte: Data, binary: Data? = nil, date: NaiveDate? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) {
self.integer = integer
self.int32 = int32
self.int64 = int64