OpenAPIKit

I've been working on improving error output of the decoding process. Thanks again to @lassejansen for pushing for these improvements.

Now you can wrap DecodingErrors coming out of OpenAPIKit types with OpenAPI.Error(from:) to get easy access to human readable descriptions and coding paths.

There's lots of room for improvement, but following are a few examples of the human readable output.


Response header with both `content` and `schema`
openapi: "3.0.0"
info:
    title: test
    version: 1.0
paths:
    /hello/world:
        get:
            responses:
                '200':
                    description: hello
                    content: {}
                    headers:
                        hi:
                            schema:
                                type: string
                            content:
                                application/json:
                                    schema:
                                        type: string

Description:

Found neither a $ref nor a Header in .headers.hi for the status code '200' response of the GET endpoint under /hello/world.

Header could not be decoded because:
Inconsistency encountered when parsing Header: A single path parameter must specify one but not both content and schema.

Coding Path String: .paths['/hello/world'].get.responses.200.headers.hi


Security Scheme that has not been added to the Components Object
openapi: 3.0.0
info:
    title: test
    version: 1.0
paths: {}
components: {}
security:
    - missing: []

Description:

Inconsistency encountered when parsing security in the root Document object: Each key found in a Security Requirement dictionary must refer to a Security Scheme present in the Components dictionary.

Coding Path String: .security


JSON Schema `type` that is a Hash instead of a String
openapi: "3.0.0"
info:
    title: test
    version: 1.0
paths:
    /hello/world:
        get:
            requestBody:
                content:
                    application/json:
                        schema:
                            type:
                                hi: there
            responses: {}

Description:

Found neither a $ref nor a JSONSchema in .content['application/json'].schema for the request body of the GET endpoint under /hello/world.

JSONSchema could not be decoded because:
Expected type value to be parsable as Scalar but it was not.

Coding Path String: .paths['/hello/world'].get.requestBody.content['application/json'].schema