forked from apple/swift-openapi-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParameterStyles.swift
64 lines (53 loc) · 1.98 KB
/
ParameterStyles.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftOpenAPIGenerator open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftOpenAPIGenerator project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftOpenAPIGenerator project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
/// The serialization style used by a parameter.
///
/// Details: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md#fixed-fields-10
@_spi(Generated) public enum ParameterStyle: Sendable {
/// The form style.
///
/// Details: https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.8
case form
/// The simple style.
///
/// Details: https://datatracker.ietf.org/doc/html/rfc6570#section-3.2.2
case simple
/// The deepObject style.
///
/// Details: https://spec.openapis.org/oas/v3.0.4.html#style-values
case deepObject
}
extension ParameterStyle {
/// The default style for path parameters.
static let defaultForPathParameters: Self = .simple
/// The default style for query items.
static let defaultForQueryItems: Self = .form
/// The default style for query items.
static let defaultForHeaderFields: Self = .simple
/// The default style for cookies.
static let defaultForCookies: Self = .form
/// Returns the default value of the explode field for the given style
/// - Parameter style: The parameter style.
/// - Returns: The explode value.
static func defaultExplodeFor(forStyle style: ParameterStyle) -> Bool { style == .form }
}
extension URICoderConfiguration.Style {
init(_ style: ParameterStyle) {
switch style {
case .form: self = .form
case .simple: self = .simple
case .deepObject: self = .deepObject
}
}
}