Instance Methodswift-openapi-runtime 1.6.0OpenAPIRuntime
getResponseBodyAsMultipart(_:from:transforming:boundary:allowsUnknownParts:requiredExactlyOncePartNames:requiredAtLeastOncePartNames:atMostOncePartNames:zeroOrMoreTimesPartNames:decoding:)
Returns an async sequence of multipart parts parsed from the provided body stream.
Converter+Client.swift:381This declaration is gated by at least one @_spi attribute.
func getResponseBodyAsMultipart<C, Part>(_ type: MultipartBody<Part>.Type, from data: HTTPBody?, transforming transform: @escaping (MultipartBody<Part>) throws -> C, boundary: String, allowsUnknownParts: Bool, requiredExactlyOncePartNames: Set<String>, requiredAtLeastOncePartNames: Set<String>, atMostOncePartNames: Set<String>, zeroOrMoreTimesPartNames: Set<String>, decoding decoder: @escaping (MultipartRawPart) async throws -> Part) throws -> C where Part : Sendable
Parameters
- type
The type representing the type-safe multipart body.
- data
The HTTP body data to transform.
- transform
A closure that transforms the multipart body into the output type.
- boundary
The multipart boundary string.
- allowsUnknownParts
A Boolean value indicating whether parts with unknown names should be pass through. If
false
, encountering an unknown part throws an error whent the returned body sequence iterates it.- requiredExactlyOncePartNames
The list of part names that are required exactly once.
- requiredAtLeastOncePartNames
The list of part names that are required at least once.
- atMostOncePartNames
The list of part names that can appear at most once.
- zeroOrMoreTimesPartNames
The list of names that can appear any number of times.
- decoder
A closure that parses a raw part into a type-safe part.
Returns
A value of the output type.
Throws
If the transform closure throws.
Other members in extension
Type members
Show system interfaces (1)
Hide system interfaces
init(configuration: Configuration
) Creates a new converter with the behavior specified by the configuration.
Instance members
Show system interfaces (44)
Hide system interfaces
let configuration: Configuration
Configuration used to set up the converter.
func bestContentType(received: OpenAPIMIMEType?, options: [String]
) throws -> String Chooses the most appropriate content type for the provided received content type and a list of options.
func extractAcceptHeaderIfPresent<T>(in: HTTPFields
) throws -> [AcceptHeaderContentType<T>] Returns the “accept” header parsed into individual content types.
func extractContentDispositionNameAndFilename(in: HTTPFields
) throws -> (name: String?, filename: String?) Returns the name and file name parameter values from the
content-disposition
header field, if found.func extractContentTypeIfPresent(in: HTTPFields
) -> OpenAPIMIMEType? Returns the MIME type from the content-type header, if present.
func getOptionalHeaderFieldAsJSON<T>(in: HTTPFields, name: String, as: T.Type
) throws -> T? Attempts to retrieve an optional header field value and decodes it as JSON, returning it as the specified type.
func getOptionalHeaderFieldAsURI<T>(in: HTTPFields, name: String, as: T.Type
) throws -> T? Attempts to retrieve an optional header field value and decodes it as a URI component, returning it as the specified type.
func getOptionalQueryItemAsURI<T>(in: Substring?, style: ParameterStyle?, explode: Bool?, name: String, as: T.Type
) throws -> T? Retrieves and decodes an optional query item as a URI-encoded value of the specified type.
func getOptionalRequestBodyAsBinary<C>(HTTPBody.Type, from: HTTPBody?, transforming: (HTTPBody) -> C
) throws -> C? Retrieves and transforms an optional binary request body.
func getOptionalRequestBodyAsJSON<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C? Retrieves and decodes an optional JSON-encoded request body and transforms it to a different type.
func getOptionalRequestBodyAsURLEncodedForm<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C? Retrieves and transforms an optional URL-encoded form request body.
func getOptionalRequestBodyAsXML<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C? Retrieves and decodes an optional XML-encoded request body and transforms it to a different type.
func getPathParameterAsURI<T>(in: [String : Substring], name: String, as: T.Type
) throws -> T Retrieves and decodes a path parameter as a URI-encoded value of the specified type.
func getRequiredHeaderFieldAsJSON<T>(in: HTTPFields, name: String, as: T.Type
) throws -> T Retrieves a required header field value and decodes it as JSON, returning it as the specified type.
func getRequiredHeaderFieldAsURI<T>(in: HTTPFields, name: String, as: T.Type
) throws -> T Attempts to retrieve a required header field value and decodes it as a URI component, returning it as the specified type.
func getRequiredQueryItemAsURI<T>(in: Substring?, style: ParameterStyle?, explode: Bool?, name: String, as: T.Type
) throws -> T Retrieves and decodes a required query item as a URI-encoded value of the specified type.
func getRequiredRequestBodyAsBinary<C>(HTTPBody.Type, from: HTTPBody?, transforming: (HTTPBody) -> C
) throws -> C Retrieves and transforms a required binary request body.
func getRequiredRequestBodyAsJSON<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C Retrieves and decodes a required JSON-encoded request body and transforms it to a different type.
func getRequiredRequestBodyAsMultipart<C, Part>(MultipartBody<Part>.Type, from: HTTPBody?, transforming: @escaping (MultipartBody<Part>) throws -> C, boundary: String, allowsUnknownParts: Bool, requiredExactlyOncePartNames: Set<String>, requiredAtLeastOncePartNames: Set<String>, atMostOncePartNames: Set<String>, zeroOrMoreTimesPartNames: Set<String>, decoding: @escaping (MultipartRawPart) async throws -> Part
) throws -> C Returns an async sequence of multipart parts parsed from the provided body stream.
func getRequiredRequestBodyAsURLEncodedForm<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C Retrieves and decodes the required request body as URL-encoded form data.
func getRequiredRequestBodyAsXML<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C Retrieves and decodes a required XML-encoded request body and transforms it to a different type.
func getResponseBodyAsBinary<C>(HTTPBody.Type, from: HTTPBody?, transforming: (HTTPBody) -> C
) throws -> C Retrieves the response body as binary data and transforms it into a specified type.
func getResponseBodyAsJSON<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C Retrieves the response body as JSON and transforms it into a specified type.
func getResponseBodyAsXML<T, C>(T.Type, from: HTTPBody?, transforming: (T) -> C
) async throws -> C Retrieves the response body as XML and transforms it into a specified type.
func renderedPath(template: String, parameters: [any Encodable]
) throws -> String Renders the path template with the specified parameters to construct a URI.
func setAcceptHeader<T>(in: inout HTTPFields, contentTypes: [AcceptHeaderContentType<T>]
) Sets the “accept” header according to the provided content types.
func setHeaderFieldAsJSON<T>(in: inout HTTPFields, name: String, value: T?
) throws Sets a header field with an optional value, encoding it as a JSON component if not nil.
func setHeaderFieldAsURI<T>(in: inout HTTPFields, name: String, value: T?
) throws Sets a header field with an optional value, encoding it as a URI component if not nil.
func setOptionalRequestBodyAsBinary(HTTPBody?, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody? Sets an optional request body as binary in the specified header fields and returns an
HTTPBody
.func setOptionalRequestBodyAsJSON<T>(T?, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody? Sets an optional request body as JSON in the specified header fields and returns an
HTTPBody
.func setOptionalRequestBodyAsURLEncodedForm<T>(T, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody? Sets an optional request body as URL-encoded form data in the specified header fields and returns an
HTTPBody
.func setOptionalRequestBodyAsXML<T>(T?, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody? Sets an optional request body as XML in the specified header fields and returns an
HTTPBody
.func setQueryItemAsURI<T>(in: inout HTTPRequest, style: ParameterStyle?, explode: Bool?, name: String, value: T?
) throws Sets a query item with the specified name and value in the HTTP request’s query parameters, treating the value as a URI component.
func setRequiredRequestBodyAsBinary(HTTPBody, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets a required request body as binary in the specified header fields and returns an
HTTPBody
.func setRequiredRequestBodyAsJSON<T>(T, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets a required request body as JSON in the specified header fields and returns an
HTTPBody
.func setRequiredRequestBodyAsMultipart<Part>(MultipartBody<Part>, headerFields: inout HTTPFields, contentType: String, allowsUnknownParts: Bool, requiredExactlyOncePartNames: Set<String>, requiredAtLeastOncePartNames: Set<String>, atMostOncePartNames: Set<String>, zeroOrMoreTimesPartNames: Set<String>, encoding: @escaping (Part) throws -> MultipartRawPart
) throws -> HTTPBody Sets a required request body as multipart and returns the streaming body.
func setRequiredRequestBodyAsURLEncodedForm<T>(T, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets a required request body as URL-encoded form data in the specified header fields and returns an
HTTPBody
.func setRequiredRequestBodyAsXML<T>(T, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets a required request body as XML in the specified header fields and returns an
HTTPBody
.func setResponseBodyAsBinary(HTTPBody, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets the response body as binary data.
func setResponseBodyAsJSON<T>(T, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets the response body as JSON data, serializing the provided value.
func setResponseBodyAsMultipart<Part>(MultipartBody<Part>, headerFields: inout HTTPFields, contentType: String, allowsUnknownParts: Bool, requiredExactlyOncePartNames: Set<String>, requiredAtLeastOncePartNames: Set<String>, atMostOncePartNames: Set<String>, zeroOrMoreTimesPartNames: Set<String>, encoding: @escaping (Part) throws -> MultipartRawPart
) throws -> HTTPBody Sets a response body as multipart and returns the streaming body.
func setResponseBodyAsXML<T>(T, headerFields: inout HTTPFields, contentType: String
) throws -> HTTPBody Sets the response body as XML data, serializing the provided value.
func validateAcceptIfPresent(String, in: HTTPFields
) throws Validates that the Accept header in the provided response is compatible with the provided content type substring.
func verifyContentTypeIfPresent(in: HTTPFields, matches: String
) throws Verifies the MIME type from the content-type header, if present.