-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Explicitly mention type: "integer"
in definition of Schema Object
#4038
Comments
Part of OAI#4038
This is not a difference. However, integers are not part of the JSON data model, and therefore it is not something that can control the applicability of JSON Schema keywords of These are two separate things, as the JSON Schema specification explicitly states. We cannot change the applicability criteria for the format registry, because that is defined by JSON Schema and not the OAS. |
@handrews I know you've already tried to explain this multiple times. Thank you for you patience here. I couldn't find any information in the specifications I could link that'd implicitly or explicitly invalidate the statement I made above. |
@baywet the things you quoted prove what I said. The values in the The |
@handrews thanks. Let's try to backtrack this together then. |
the section you linked titled "Instance Data Model" which explicitly lists the six types: null, boolean, object, array, number, string. This is in turn derived from the JSON data model, which defined four types (object, array, number, string) and three literals ( |
Allow me to rephrase my question. If the type keyword is not how a given schema declares which model it's using, how does the schema declare which model it's using? |
@baywet the data model type is inherent in the instance. JSON (RFC 8259) defines a data model. JSON Schema is defined for JSON, so that is all the data model we have to work with. JSON Schema is not defined for any other data model / type system. JSON Schema refines the JSON data model slightly by doing a few things:
Beyond that, JSON Schema is a constraint system. It is not a data definition system. There is no further data model or type system. There are just constraints against which an instance is valid or invalid. JSON Schema keywords and format values can be tied to a particular data model type, which (as explicitly shown in the section that has now been quoted many times, does not include integer). What this means is that, in terms of validation, if the instance is of the applicable data model type, then the constraint is evaluated. If the instance is of some other data model type, then the constraint automatically passes. The |
If OpenAPI wants to have an actual data definition system, then it should invest in creating one, or in adapting an existing one that was actually designed for that purpose, which JSON Schema was not. JSON Schema could still be retained for complex runtime validation, to which it is well-suited, using exactly the features that are so problematic for data definition (e.g. It's not a coincidence that the various VC-backed companies out there (or large estabished companies such as Microsoft) have made alternative ways to define data that then gets mapped down to OpenAPI. While some of these are positioned as "OpenAPI alternatives", they almost exclusively work around JSON Schema's lack of suitability for data definition / code generation. It's going to continue to be a problem for as long as OpenAPI relies exclusively on JSON Schema for this functionality. |
For completeness (and in case anyone didn't read the other several PRs on this topic): I am opposed to mentioning "integer" in the Schema Object section in either 3.0 or 3.1. The use of "integer" in the In 3.1, we use standard JSON Schema in its entirety and should not comment on any particular keyword- we intentionally removed that entire section for 3.1, and it was the right decision. In 3.0, there is a list of keywords, but only for explaining differences between the use of the keywords in OAS and their use in standard JSON Schema. The use of "integer" with |
Sorry, I missed that "integer" was removed only from the instance data model in the JSON Schema Core and is still listed as an allowed value for @handrews Glad to have you here to educate us 😎 |
Will be fixed by #4045 by not explicitly re-defining "integer" |
OAS 3.0 and 3.1 explicitly define
"integer"
as an allowed value of thetype
keyword in section Data Types.This difference between OAS and pure JSON Schema is not mentioned in section Schema Object.
Proposal
Explicitly mention this significant difference and define OAS
type: "integer"
as a shortcut for JSON Schematype: "number", multipleOf: 1
.Explicitly state in the Format Registry that column "Type" uses the extended OAS definition.
The text was updated successfully, but these errors were encountered: