Add OAS 3.2.0 parameter header features #451
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #442
Breaking Changes / Migration Guide
There are no breaking changes for the
OpenAPIKit30module (OAS 3.0.xspecification).
For the
OpenAPIKitmodule (OAS 3.1.x and 3.2.x versions) read on.An additional parameter location of
querystringhas been added. This is abreaking change to code that exhaustively switches on
OpenAPI.Parameter.Contextor
OpenAPI.Parameter.Context.Location.To support the new
querystringlocation,schemaOrContenthas been moved intothe
OpenAPI.Parameter.Contextbecause it only applies to locations other thanquerystring. You can still accessschemaOrContentas a property on theParameter. Code that pattern matches on cases ofOpenAPI.Parameter.Contextwill need to add the new
schemaOrContentvalues associated with each case.Constructors
The following only applies if you construct parameters in-code (use Swift to
build an OpenAPI Document).
Unfortunately, the change that made
schemaOrContentnot apply to all possiblelocations means that the existing convenience constructors and static functions
that created parameters in-code do not make sense anymore. There were fairly
substantial changes to what is available with an aim to continue to offer
simular convenience as before.
Following are a few changes you made need to make with examples.
Code that populates the
parametersarray of theOpenAPI.Operationtype with the.parameter(name:,context:,schema:)function needs to be updated. Theschemahas moved into the
contextso you change your code in the following way:Code that initializes
OpenAPI.Parametervia one of itsinitfunctions willmost likely need to change. Many of the initializers have been removed but you can
replace
.init(name:,context:,schema:)or similar initializers with.header(name:,schema:)(same goes forquery,path, andcookie). So you changeyour code in the following way:
Because the
ParameterContexthas taken on theschemaOrContentof theParameter, convenience constructors likeParameterContext.header(andsimilar for the other locations) no longer make sense and have been removed. You
must also specify the schema or content, e.g.
ParameterContext.header(schema: .string).