File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,28 @@ let decoder = ... // JSONDecoder() or YAMLDecoder()
9090let openAPIDoc = try decoder.decode (OpenAPI.Document .self , from : ... )
9191```
9292
93+ #### Decoding Future Versions
94+ ` OpenAPIKit ` adds support for new OAS versions when it has support for most or
95+ all of the features of that OAS version. If you want to parse an OpenAPI
96+ Document that is written in a newer version than ` OpenAPIKit ` supports and you
97+ are asserting that the newer version is possible to parse as if it were the
98+ pre-existing version, you can tell ` OpenAPIKit ` to parse the newer version as if
99+ it were the older version.
100+
101+ You do this with ` userInfo ` passed into the ` Decoder ` you are using. For
102+ example, to decode a hypothetical document version of ` "3.100.100" ` as if it
103+ were version ` "3.1.1" ` , set your decoder up as follows:
104+ ``` swift
105+ let userInfo = [
106+ DocumentConfiguration.versionMapKey : [" 3.100.100" : OpenAPI.Document .Version .v3_1_1 ]
107+ ]
108+
109+ let decoder = ... // JSONDecoder() or YAMLDecoder()
110+ decoder.userInfo = userInfo
111+
112+ let openAPIDoc = try decoder.decode (OpenAPI.Document .self , from : ... )
113+ ```
114+
93115#### Decoding Errors
94116You can wrap any error you get back from a decoder in ` OpenAPI.Error ` to get a friendlier human-readable description from ` localizedDescription ` .
95117
You can’t perform that action at this time.
0 commit comments