-
Notifications
You must be signed in to change notification settings - Fork 9.1k
vocabulary enhancements #2803
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
vocabulary enhancements #2803
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,26 @@ | ||
--- | ||
$defs: | ||
extensible: | ||
patternProperties: | ||
^x-: true | ||
properties: | ||
discriminator: | ||
$ref: '#/$defs/extensible' | ||
properties: | ||
mapping: | ||
additionalProperties: | ||
type: string | ||
format: uri-reference | ||
type: object | ||
propertyName: | ||
type: string | ||
required: | ||
- propertyName | ||
type: object | ||
unevaluatedProperties: false | ||
extensible: | ||
patternProperties: | ||
^x-: true | ||
external-docs: | ||
example: | ||
deprecated: true | ||
externalDocs: | ||
$ref: '#/$defs/extensible' | ||
properties: | ||
description: | ||
|
@@ -44,19 +48,17 @@ $defs: | |
type: boolean | ||
type: object | ||
unevaluatedProperties: false | ||
dependentSchemas: | ||
discriminator: | ||
anyOf: | ||
- required: [ oneOf ] | ||
- required: [ anyOf ] | ||
- required: [ allOf ] | ||
Comment on lines
+51
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The spec technically says not having There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is indeed a very strange keyword, and doesn't really fit with the simplicity that most other keywords have. I'll put this PR into draft mode while the other issue is being discussed. |
||
$dynamicAnchor: meta | ||
$id: https://spec.openapis.org/oas/3.1/meta/base | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that this schema's keywords are all mixed up. I know that wasn't introduced in this schema, but it would be nice to fix that while we're making changes anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you mean here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean the ordering is not the same as the JSON version. Things that are best practice to put at the top of the document ( |
||
$schema: https://json-schema.org/draft/2020-12/schema | ||
$vocabulary: | ||
https://spec.openapis.org/oas/3.1/vocab/base: true | ||
properties: | ||
discriminator: | ||
$ref: '#/$defs/discriminator' | ||
example: true | ||
externalDocs: | ||
$ref: '#/$defs/external-docs' | ||
xml: | ||
$ref: '#/$defs/xml' | ||
Comment on lines
-52
to
-59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see you've inlined the referenced schemas. The style I prefer is that any objects (excluding objects used like maps) are generally pulled out into definitions. It allows the reader to see what the whole schema does in the first few lines. Especially when inlining multiple large object schemas, it can we hard to determine the top level properties of an object. This way the reader can see the top level structure more easily and then dig down into the definitions to learn more about the specific properties they are interested in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I inlined them here because they aren't referenced from anywhere else, and to mirror the style we use for the standard json-schema-spec schema files. This file is more like those schemas, rather than the main openapi schema (where splitting out into definitions, even if something is only referenced once, is helpful because the document is so nested). Vocabularies aren't like that -- there's just one level: the keywords themselves. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no precedent for compound keywords like these in the JSON Schema meta-schemas because there are no such keywords in JSON Schema. The only time we use objects is for map-like structures such as |
||
title: OAS Base vocabulary | ||
type: | ||
- object | ||
|
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.
This is not correct. These values can be either a uri-reference or a Schema Name.
Unfortunately, the concept of a "schema name" is not actually defined. See #2618 for a patch proposal that defines the concept the way I believe existing tooling interprets it.
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 see. It would be good to clarify that wording, then (and perhaps take out the bits that don't add much value).