-
Notifications
You must be signed in to change notification settings - Fork 148
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
feat(typings): update OpenAPI 3.0 and 3.1 typing declarations #1795
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 498f6b7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
88e238e
to
0ba50f7
Compare
0ba50f7
to
7463f90
Compare
ok, i think i'm done with this. missed a few keywords for Oas3_1 schemas. ready for review. thanks |
@@ -112,13 +112,10 @@ export interface Oas3Xml { | |||
} | |||
|
|||
// common fields for OpenAPI Schema v3.x | |||
interface Oas3XSchemaBase<T> { | |||
interface Oas3XSchemaBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer using the generic interface because it's less likely for the common properties to diverge. Not sure which approach would be cleaner though. Why did you decide to change the approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the keywords which utilized the generic interface were moved into the Oas3Schema
and Oas3_1Schema
. So it was unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but what was the reason for moving the keywords from Oas3XSchemaBase
? Was there an issue with leaving them as they were?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they have different behavior between 30 asd 31. So the extension of Oas3XSchemaBase was incorrect and the keywords should be assigned to each version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'll test that once I have time. Thank you for contributing!
Add missing keywords for OAS 3.1.x (JSON Schema 2020-12) Co-authored-by: Andrew Tatomyr <[email protected]>
331b109
to
498f6b7
Compare
I added a few extra JSON Schema 2020-12 keywords that were missed |
fixes #1547
What/Why/How?
The typings for OAS 3 and OAS 3_1 schemas were incorrectly defined per the OpenAPI Specification.
OAS 3.0 has a specific requirement which defines an OpenAPI Schema rather than a JSON Schema schema. There are subtleties to the OpenAPI 3.0 Schema.
OpenAPI 3.1 Schemas are equivalent to a JSON Schema 2020-12 schema.
Reference
Per the OpenAPI 3.0 Specification
4.7.24.1 JSON Schema Keywords
The following keywords are taken directly from the JSON Schema definition and follow the same specifications:
The following keywords are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification.
Alternatively, any time a Schema Object can be used, a Reference Object can be used in its place. This allows referencing definitions instead of defining them inline.
Additional keywords defined by the JSON Schema specification that are not mentioned here are strictly unsupported.
Other than the JSON Schema subset fields, the following fields MAY be used for further schema documentation:
4.7.24.2 Fixed Fields
Per the OpenAPI 3.1 Specification
4.8.24 Schema Object
The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is a superset of the JSON Schema Specification Draft 2020-12. The empty schema (which allows any instance to validate) MAY be represented by the boolean value true and a schema which allows no instance to validate MAY be represented by the boolean value false.
For more information about the keywords, see JSON Schema Core and JSON Schema Validation.
Unless stated otherwise, the keyword definitions follow those of JSON Schema and do not add any additional semantics; this includes keywords such as $schema, $id, $ref, and $dynamicRef being URIs rather than URLs. Where JSON Schema indicates that behavior is defined by the application (e.g. for annotations), OAS also defers the definition of semantics to the application consuming the OpenAPI document.
Testing
Screenshots (optional)
Check yourself
Security