-
Notifications
You must be signed in to change notification settings - Fork 40k
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
OpenAPI spec (swagger.json) integer type valid ranges not specified #105533
Comments
For example, to:
should be added:
|
the spec says that these fields are bools:
the Go struct -> OpenAPI generator could include the type limits from the type information (e.g. uint16 -> 0-65535), but that would be artificial in some cases, since some integer fields have actual limits. for actual limits the generator would need a way to extract those from tags above a field. field limits are currently only documented loosely in the comments above a field in a written form. /sig api-machinery |
Right. It must be that exclusiveMinimum/Maximum are meant to be used in conjunction with minimum/maximum to specify exclusive/inclusive. Including the type limits from uint16 etc. would not be perfect, but it would be noticeably better than now since the signed/unsigned distinction and basic ranges can be used to determine appropriate static types. It could be made clear in the top-level OpenAPI doc that these are lower and upper bounds not limits. |
This is already supported in CRDs, and it doesn't seem too difficult to add into the OpenAPI generator for built-ins. Something like // +minimum=X
// +maximum=Y
Foo int32 for the go structs of native types. Deriving the limits from some kind of NLP parsing of the comments feels quite error prone and I would heavily favor a more simplistic approach with the added comment tags. @apelisse @jpbetz do you see any drawbacks of adding this? These tags are already supported by OpenAPI v2 |
You're right, it's a great idea and it's part of the plan, it's just not that easy to implement. We've clarified a lot of things recently with defaults so I think we'll be able to do it now/next. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
Still definitely interested in doing that, but we don't have the bandwidth right now. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
/lifecycle frozen |
This issue has not been updated in over 1 year, and should be re-triaged. You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
fyi kubernetes/enhancements#4153 should resolve this issue |
/triage accepted |
In the generated OpenAPI swagger.json, integer types such as
ContainerPort
have clearly documented valid ranges in the human-readable comments, but these are not actually specified in the API JSON using the minimum/maximum/exclusiveMinimum/exclusiveMaximum keywords. This creates problems for statically-typed languages used to generate for the API because they cannot perform this type checking. They can't even make a choice as to whether to represent a given integer quantity as a "natural" or "unsigned" type or a signed one.I assume the range information is available in some form within the API server that generates the swagger, so would it be possible to include it?
The text was updated successfully, but these errors were encountered: