You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Motivation
The OpenAPI specification allows for specifying examples along side a
schema in a content map[^1]. The example can be an object with some
defined fields, but none of these fields are mandatory in OpenAPI
3.0.3[^2].
However, it looks like we're failing to parse documents that don't have
the `value` field.
Specifically we can't parse this spec unless we add the `value` field:
```diff
responses:
MyResponse:
description: Some response
content:
application/json:
schema:
type: string
examples:
application/json:
summary: "a hello response"
+ value: "hello"
```
This is used in the wild—notably in the Github API.
This appears to be because the model used in OpenAPIKit expects `value`
to be non-optional[^3].
### Modifications
Add some tests, one with an `XCTExpectFailure`, to track this.
### Result
We have tests that we can use to track this incompatibility with such
OpenAPI documents.
### Test Plan
This patch is tests only.
[^1]: https://spec.openapis.org/oas/v3.0.3#mediaTypeObject
[^2]: https://spec.openapis.org/oas/v3.0.3#exampleObject
[^3]:
https://github.com/mattpolzin/OpenAPIKit/blob/main/Sources/OpenAPIKit/Example.swift#L19
---------
Signed-off-by: Si Beaumont <beaumont@apple.com>
0 commit comments