Skip to content

Conversation

@mattpolzin
Copy link
Owner

@mattpolzin mattpolzin commented Oct 22, 2025

New Feature

OpenAPIKit adds support for new OAS versions when it has support for most or
all of the features of that OAS version. If you want to parse an OpenAPI
Document that is written in a newer version than OpenAPIKit supports and you
are asserting that the newer version is possible to parse as if it were the
pre-existing version, you can tell OpenAPIKit to parse the newer version as if
it were the older version.

You do this with userInfo passed into the Decoder you are using. For
example, to decode a hypothetical document version of "3.100.100" as if it
were version "3.1.1", set your decoder up as follows:

let userInfo = [
  DocumentConfiguration.versionMapKey: ["3.100.100": OpenAPI.Document.Version.v3_1_1]
]

let decoder = ... // JSONDecoder() or YAMLDecoder()
decoder.userInfo = userInfo

let openAPIDoc = try decoder.decode(OpenAPI.Document.self, from: ...)

@mattpolzin mattpolzin force-pushed the feature/oas-conversion-userinfo branch from 160db29 to 454e0e9 Compare October 22, 2025 15:03
@mattpolzin mattpolzin merged commit 8e20f7d into main Oct 22, 2025
32 of 33 checks passed
@mattpolzin mattpolzin deleted the feature/oas-conversion-userinfo branch October 22, 2025 15:18
@mattpolzin mattpolzin restored the feature/oas-conversion-userinfo branch October 22, 2025 15:19
mattpolzin added a commit that referenced this pull request Oct 22, 2025
Backport of #433 (Add support for mapping newer OAS versions to older ones)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants