Skip to content

Commit

Permalink
Move the option under paths section
Browse files Browse the repository at this point in the history
  • Loading branch information
ainame committed Nov 30, 2022
1 parent 6a4c1b5 commit 23d4a39
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
30 changes: 15 additions & 15 deletions Docs/ConfigOptions.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Sources/CreateAPI/Generator/Generator+Paths.swift
Expand Up @@ -690,7 +690,7 @@ extension Generator {
.other("application/json"),
.form
]
if !options.useDataForMultipartFormDataRequestBody {
if !options.paths.useDataForMultipartFormDataRequestBody {
structuredRequestBodySupportedTypes.append(.multipartForm)
}
if let (content, contentType) = firstContent(for: structuredRequestBodySupportedTypes) {
Expand Down
16 changes: 8 additions & 8 deletions Sources/CreateOptions/ConfigOptions.swift
Expand Up @@ -672,6 +672,14 @@ public struct ConfigOptions: ParsableConfiguration {
///
/// </details>
@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
Expand Down Expand Up @@ -712,14 +720,6 @@ public struct ConfigOptions: ParsableConfiguration {
/// Rename anonymous collection elements. By default, use a singularized form of the property name
@Option public var collectionElements: [String: String] = [:]
}

/// 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
}

// MARK: - Utilities
Expand Down
3 changes: 2 additions & 1 deletion Tests/CreateAPITests/GenerateOptionsTests.swift
Expand Up @@ -395,7 +395,8 @@ final class GenerateOptionsTests: GenerateTestCase {
name: "edgecases-multipart-formdata",
configuration: """
generate: ["paths"]
useDataForMultipartFormDataRequestBody: false
paths:
useDataForMultipartFormDataRequestBody: false
"""
)
}
Expand Down

0 comments on commit 23d4a39

Please sign in to comment.