Releases: mattpolzin/OpenAPIKit
Fix error reporting on Path decoding
Fixes errors on Path where nested Either decoding errors are involved.
Adding specification extension support
Added specification extensions for:
- Document
- Document.Info
- PathItem
- Components
- Operation
- Server
- Contact
- License
- Parameter
Added Parameter.location
to expose a raw representable enum that just represents location (query, header, path, cookie).
- Rename
Parameter.Location
toParameter.Context
. - Rename
Parameter.parameterLocation
toParameter.context
.
Fixes a bug with decoding whole number floats as integers
Decoding was inadvertently strict w/r/t whole number floats (like "1.0") being parsable as the Int
type, specifically when using certain decoders.
Fixes #56.
Better JsonSchema allOf support
- Added
.other
case toOpenAPI.ContentType
. - Added
PathItem.endpoints
to get an array of all endpoints defined for the particular path. - Added validation that security schemes referenced from
PathItem.Operations
can be found in theComponents
. - Added
JSONSchemaFragment
to allowJSONSchema.all(of:)
case to represent less than wholeJSONSchemas
. - Fixed bug where
JSONSchema
would not parse anything without an explicittype
specified -- upon further reading of the JSON Schema specification, it is fine to omit thetype
property. NowJSONSchema
is happy as long as it has some way to infer the type.
- Renamed the wildcard
ContentTypes
to be "any" instead of "all":
all
->any
applicationAll
->anyApplication
audioAll
->anyAudio
imageAll
->anyImage
textAll
->anyText
videoAll
->anyVideo
JSONSchema.all(of:)
used to store an array ofJSONSchema
whereas now it stores an array ofJSONSchemaFragment
.
Better JSONSchema examples and minor OrderedDictionary error improvements
OrderedDictionary
produces better error output when it fails to decodeOpenAPI.ComponentKey
(the keys of components in the Components Object).JSONSchema
is aligned withOpenAPI.Example
in usingAnyCodable
for examples.
JSONSchema
example properties switched from String
to AnyCodable
. This aligns with the examples of the Example Object (OpenAPI.Example
). AnyCodable
is preferable here because it will get encoded as a JSON structure instead of a String and that will be presented more favorably in UIs such as ReDoc. Any Encodable
thing can still be turned into a String
, wrapped in AnyCodable
, and passed in to produce the result that you used to get, the work to do so is just a bit more exposed.
Change `openAPISchema()` function to property.
The throwing openAPISchema()
function has been changed to the openAPISchema
property (which is, naturally, non-throwing) because this function never needed to throw anyway in the end. It has been quite a few versions since any code relied on a throwing variant of it.
Bring dependencies into project
Brings Poly, OrderedDictionary, and AnyCodable dependencies into project, additionally making small tweaks and (in the case of Either
) substantial additions to the available interface.
Either
Support now offered by the in-library Either
type instead of the Poly2
type.
Adds OpenAPI.Component.dereference() function and named accessors for all existing types OpenAPIKit wraps in Either.
OrderedDictionary
and AnyCodable
No changes to interface except for only adding the AnyCodable
type (no need for the AnyEncodable
or AnyDecodable
types).
0.25.0: Merge pull request #34 from mattpolzin/bugfix/components-object-keys
Fixes #28
Changes keys in Components Object dictionaries from String
to OpenAPI.ComponentKey
in order to provide validation. ComponentKey
has String
raw values and is ExpressibleByStringLiteral
so this is a pretty small breaking change.
API cleanup
Additions:
- Retrieve referenced components with
OpenAPI.Components.subscript()
- Construct references from components object with
OpenAPI.Components.reference(named:ofType:)
⚠️ Breaking Changes ⚠️
JSON References
JSONReference
has structurally changed substantially, as has the individual dictionaries in OpenAPI.Components
. The latter does not break any public APIs except for Components.init
taking a bunch of OrderedDictionary
parameters instead of the old RefDict
type.
JSONReference
internal construction has changed as follows:
Old: JSONReference.internal(\.schemas, named: "hello_world")
New: JSONReference.component(named: "hello_world")
Old: JSONReference.internal(.unsafe("#/hello/world"))
New: JSONReference.internal(path: "/hello/world")
JSONReference
external construction has changed as follows:
Old: JSONReference.external("hello.json", .unsafe("#/hello/world"))
New: JSONReference.external(URL(string: "hello.json#/hello/world")!)
Misc.
- Rename
OpenAPI.ExternalDoc
->OpenAPI.ExternalDocumentation
- Rename
OpenAPI.PathComponents
->OpenAPI.Path
- Rename
OpenAPI.Response.StatusCode.Range
cases:_100
->information
_200
->success
_300
->redirect
_400
->clientError
_500
->serverError
- Remove
AnyCodable
export (must now be explicitly imported by other libraries if they wish to interact with theAnyCodable
API directly).
Move Reflection Code
Moved reflection code and some code that takes Swift types to OpenAPISchema using a JSONEncoder into a new library at mattpolzin/OpenAPIReflection
.