Skip to content

Commit cb27c62

Browse files
committed
update migration guide
1 parent 79ab6d8 commit cb27c62

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

documentation/migration_guides/v5_migration_guide.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,89 @@ builtin methods so the following code _does not need to change_:
6666
let httpMethod : OpenAPI.HttpMethod = .post
6767
```
6868

69+
### Parameters
70+
There are no breaking changes for the `OpenAPIKit30` module (OAS 3.0.x
71+
specification).
72+
73+
For the `OpenAPIKit` module (OAS 3.1.x and 3.2.x versions) read on.
74+
75+
An additional parameter location of `querystring` has been added. This is a
76+
breaking change to code that exhaustively switches on `OpenAPI.Parameter.Context`
77+
or `OpenAPI.Parameter.Context.Location`.
78+
79+
To support the new `querystring` location, `schemaOrContent` has been moved into
80+
the `OpenAPI.Parameter.Context` because it only applies to locations other than
81+
`querystring`. You can still access `schemaOrContent` as a property on the
82+
`Parameter`. Code that pattern matches on cases of `OpenAPI.Parameter.Context`
83+
will need to add the new `schemaOrContent` values associated with each case.
84+
85+
```swift
86+
// BEFORE
87+
switch parameter.context {
88+
case .query(required: _)
89+
}
90+
91+
// AFTER
92+
switch parameter.context {
93+
case .query(required: _, schemaOrContent: _)
94+
}
95+
```
96+
97+
#### Constructors
98+
The following only applies if you construct parameters in-code (use Swift to
99+
build an OpenAPI Document).
100+
101+
Unfortunately, the change that made `schemaOrContent` not apply to all possible
102+
locations means that the existing convenience constructors and static functions
103+
that created parameters in-code do not make sense anymore. There were fairly
104+
substantial changes to what is available with an aim to continue to offer
105+
simular convenience as before.
106+
107+
Following are a few changes you made need to make with examples.
108+
109+
Code that populates the `parameters` array of the `OpenAPI.Operation` type with the
110+
`.parameter(name:,context:,schema:)` function needs to be updated. The `schema`
111+
has moved into the `context` so you change your code in the following way:
112+
```swift
113+
// BEFORE
114+
.parameter(
115+
name: "name",
116+
context: .header,
117+
schema: .string
118+
)
119+
120+
// AFTER
121+
.parameter(
122+
name: "name",
123+
context: .header(schema: .string)
124+
)
125+
```
126+
127+
Code that initializes `OpenAPI.Parameter` via one of its `init` functions will
128+
most likely need to change. Many of the initializers have been removed but you can
129+
replace `.init(name:,context:,schema:)` or similar initializers with
130+
`.header(name:,schema:)` (same goes for `query`, `path`, and `cookie`). So you change
131+
your code in the following way:
132+
```swift
133+
// BEFORE
134+
.init(
135+
name: "name",
136+
context: .header,
137+
schema: .string
138+
)
139+
140+
// AFTER
141+
.header(
142+
name: "name",
143+
schema: .string
144+
)
145+
```
146+
147+
Because the `ParameterContext` has taken on the `schemaOrContent` of the
148+
`Parameter`, convenience constructors like `ParameterContext.header` (and
149+
similar for the other locations) no longer make sense and have been removed. You
150+
must also specify the schema or content, e.g. `ParameterContext.header(schema: .string)`.
151+
69152
### Errors
70153
Some error messages have been tweaked in small ways. If you match on the
71154
string descriptions of any OpenAPIKit errors, you may need to update the

0 commit comments

Comments
 (0)