Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OASv3.1 Schema #2474

Closed
wants to merge 27 commits into from
Closed

OASv3.1 Schema #2474

wants to merge 27 commits into from

Conversation

philsturgeon
Copy link
Contributor

@philsturgeon philsturgeon commented Feb 18, 2021

Superseded by #2489.

Closes #2314.

Adding a JSON Schema for the whole OpenAPI v3.1 document, as plenty of tooling requires this before they can upgrade to OpenAPI v3.1.

This is based on a gist from @handrews, and is being tweaked for OpenAPI v3.1. https://gist.github.com/handrews/6dfebd56ef97328f9e4dc7a47a1e8bc7

This is different to the OpenAPI dialect/metaschema work being done first in #2016 but is starting again in another yet unmade PR.

@MikeRalphson
Copy link
Member

MikeRalphson commented Feb 18, 2021

@philsturgeon maybe this will help, I've updated openapi3-examples to have a 3.1 directory of pass/fail cases. Not everything would be picked up by a schema-only validator, but 🤷🏼 If you find any mistakes, let me know. https://github.com/Mermade/openapi3-examples/tree/master/3.1 There is a mega example which tries to show all new features of 3.1

philsturgeon and others added 2 commits February 18, 2021 19:13
Co-authored-by: Jason Desrosiers <jdesrosi@gmail.com>
Schema:
$anchor: Schema
oneOf:
- $ref: '#Reference'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- $ref: '#Reference'

This reference is redundant, as a draft2020-12 schema will of course accept the $ref keyword itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this is no longer redundant if the '#Reference' definition is extended to include 'summary' and 'description' properties and "unevaluated: false".)

$anchor: Schema
oneOf:
- $ref: '#Reference'
- type: object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that boolean schemas are excluded at this level?

Comment on lines +588 to +599
properties:
scheme:
type: string
oneOf:
- properties:
type:
const: http
- properties:
type:
const: bearer
bearerFormat:
type: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part doesn't look right to me. The logic is supposed to be

if scheme (not type!) = "bearer"
then bearerFormat may be present

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#fixed-fields-23

Something like:

Suggested change
properties:
scheme:
type: string
oneOf:
- properties:
type:
const: http
- properties:
type:
const: bearer
bearerFormat:
type: string
properties:
type:
const: http
scheme:
type: string
if:
properties:
scheme:
const: bearer
then:
properties:
bearerFormat:
type: string

@jdesrosiers jdesrosiers mentioned this pull request Mar 2, 2021
@jdesrosiers
Copy link
Contributor

I created a new PR at #2489 so we can make progress while @philsturgeon is busy planting trees. All of the comments and suggestions that have been posted here have been incorporated into the new PR.

philsturgeon and others added 5 commits March 3, 2021 09:03
Co-authored-by: Karen Etheridge <ether@cpan.org>
Co-authored-by: Helen Kosova <hkosova@users.noreply.github.com>
Co-authored-by: Helen Kosova <hkosova@users.noreply.github.com>
Co-authored-by: Jason Desrosiers <jdesrosi@gmail.com>
Co-authored-by: Karen Etheridge <ether@cpan.org>
@philsturgeon
Copy link
Contributor Author

Ha! Sorry, I just merged all the things but you beat me to it. Brilliant, take it away!

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.

Create a complete meta schema for 3.1
5 participants