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

Define type: "integer" #4042

Closed
wants to merge 2 commits into from
Closed

Conversation

ralfhandl
Copy link
Contributor

@ralfhandl ralfhandl added this to the v3.0.4 milestone Aug 19, 2024
@ralfhandl ralfhandl added schema-object clarification requests to clarify, but not change, part of the spec labels Aug 19, 2024
@ralfhandl ralfhandl linked an issue Aug 19, 2024 that may be closed by this pull request
@ralfhandl ralfhandl requested review from handrews, mikekistler and a team August 19, 2024 13:40
Copy link
Member

@handrews handrews left a comment

Choose a reason for hiding this comment

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

Why are we defining integer instead of leaving it to JSON Schema, which is very precise on this matter?

@ralfhandl
Copy link
Contributor Author

Why are we defining integer instead of leaving it to JSON Schema, which is very precise on this matter?

This is a good question, although it comes a little too late. OAS 3.0.0 to 3.1.0 all explicitly define "integer" as an allowed value of the type keyword in section Data Types:

Note that integer as a type is also supported and is defined as a JSON number without a fraction or exponent part. Models are defined using the Schema Object, which is a superset of JSON Schema Specification Draft 2020-12.

This PR only tries to make the existing definition more precise and mention this extension in the Schema Objects section in addition to the Data Types section.

We cannot remove this feature in a minor version, let alone a patch version.

@handrews
Copy link
Member

What OpenAPI does with "integer" and formats can't change JSON Schema. It doesn't matter if it's been that way in the spec and not been noticed or not.

@handrews
Copy link
Member

I think the correct thing to do here is to note that JSON Schema only scopes formats to its data model types (number, string, boolean, null, object, array), and therefore the text of the OAS has been corrected to use "number" rather than "integer". We can add wording to the effect that this has nothing to do with the type keyword if we want.

Since this is a very tricky area, I would be happy to write up a PR that aligns with JSON Schema.

@handrews
Copy link
Member

Posted PR #4045

@@ -173,7 +173,7 @@ Note that no aspect of implicit connection resolution changes how [URLs are reso
### Data Types

Data types in the OAS are based on the types supported by the [JSON Schema Specification Wright Draft 00](https://tools.ietf.org/html/draft-wright-json-schema-00#section-4.2).
Note that `integer` as a type is also supported and is defined as a JSON number that is a multiple of 1.
Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part.
Copy link
Member

@handrews handrews Aug 21, 2024

Choose a reason for hiding this comment

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

I would prefer to backport the language about mathematical integers from #4045

Copy link
Member

Choose a reason for hiding this comment

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

Scratch the previous comment- I did not realize this was in the Schema Object section (there are way too many PRs and issues on this at once right now). I am strongly against this change. The presence of "integer" as a value for type is standard JSON Schema and should not be repeated. That just adds to confusion by including it in a list of exceptions when it is not an exception.

@ralfhandl ralfhandl closed this Aug 22, 2024
@ralfhandl ralfhandl deleted the 3.0.4-type-integer branch August 22, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification requests to clarify, but not change, part of the spec review schema-object
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explicitly mention type: "integer" in definition of Schema Object
2 participants