Skip to content

~Reducible~ Reusable ~Recyclable~ Content

Pre-release
Pre-release

Choose a tag to compare

@mattpolzin mattpolzin released this 18 Dec 15:43
35e0fe6

What's Changed

  • Bump the default Document OAS version to 3.2.0 (#459)
  • Fix external loader sendable warning/error (#461)
  • Add OAS 3.2.0 defaultMapping field for Discriminator Object (#464)
  • Add OAS 3.2.0 mediaTypes to Components Object (#465)
  • Support OpenAPI.Content references in OpenAPI.Content.Map entries (#465)

Breaking Changes

The ExternalLoader protocol now requires SendableMetatype conformance. This should be a given in most cases.

The default OAS version of a Document has been updated to v3_2_0. If you
need to produce a v3_1_x document, update your code to specify that version in
the OpenAPI.Document constructor.

Content Map (OpenAPI.Content.Map)

Content maps now reflect the specification correctly in allowing references to
Media Type Objects (OpenAPI.Content). This means that code that creates or
reads OpenAPI.Content values from a Content.Map needs to be updated to dig
one level deeper and account for the possibility that the Content is
referenced to instead of inlined.

// BEFORE
let contentMap: OpenAPI.Content.Map = [
  .json: .init(schema: .string)
]
let jsonContent: OpenAPI.Content? = contentMap[.json]

// AFTER
let contentMap: OpenAPI.Content.Map = [
  .json: .content(.init(schema: .string)),
  .xml: .component(named: "xml")
]
let jsonContent: OpenAPI.Content? = contentMap[.json]?.contentValue
if case let .b(jsonContent) = contentMap[.json] { /*...*/ }

let referenceToContent: OpenAPI.Reference<OpenAPI.Content>? = contentMap[.xml]?.reference
if case let .a(referenceToContent) = contentMap[.xml] { /*...*/ }

If you are constructing an OpenAPI.Content.Map, you have one other option for
migrating existing code: You can use the new .direct() convenience
constructor:

// BEFORE
let contentMap: OpenAPI.Content.Map = [
  .json: .init(schema: .string)
]

// AFTER
let contentMap: OpenAPI.Content.Map = [
  .json: .content(.init(schema: .string))
]
// OR
let contentMap: OpenAPI.Content.Map = .direct([
  .json: .init(schema: .string)
])

Full Changelog: 5.0.0-beta.1...5.0.0-beta.2