Repository navigation
Add initial OpenAPI 3.1 support - #138
Merged
Merged
Conversation
This is effectively a copy of the openapi30 module with some minor tweaks. We will actually get this working in later changes. Signed-off-by: Stephen Finucane <[email protected]>
These are not required in OAS 3.1 [1]. [1] https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.1.0.md#pathsObject Signed-off-by: Stephen Finucane <[email protected]>
This is newly introduced. Signed-off-by: Stephen Finucane <[email protected]>
OAS 3.1 finally provides a proper way to indicate nullable objects and
nullable references. For example:
foo:
oneOf:
- type: null
- type: string
bar:
oneOf:
- type: null
- $ref: '#/components/schema/Bar'
If a user indicates that a property can be nullable in this way, we want
to prefer the non-nullable option in our examples.
Signed-off-by: Stephen Finucane <[email protected]>
Signed-off-by: Stephen Finucane <[email protected]>
Signed-off-by: Stephen Finucane <[email protected]>
4 tasks done
dstrodtman
added a commit
to ray-project/ray
that referenced
this pull request
Aug 27, 2026
…5458) > **Stacked PR.** This targets `doc-1513-remove-invalid-response-summary` (#65457), not `master`, because that PR makes the spec valid and this one shouldn't inherit a failing validator run. Review #65457 first; GitHub retargets this to `master` automatically when it merges. The two changes are independent in substance and can be split if you'd rather take them separately. ## Why this change is needed `doc/source/cluster/running-applications/job-submission/openapi.yml` declares `openapi: 3.1.0` and uses not one construct that requires 3.1. Audited the full spec for 3.1-only constructs. Every check came back empty: | 3.1-only construct | Present? | | --- | --- | | `jsonSchemaDialect` | no | | top-level `webhooks` | no | | `$schema` | no | | `const` | no | | `examples` (the plural, JSON-Schema-aligned form) | no | | type arrays (`type: [string, "null"]`) | no | | `null` type | no | | `info.summary` | no | It also uses no `nullable`, the 3.0-only keyword it would need if it had ever expressed nullability. The complete set of keywords in the file is `description`, `type`, `summary`, `schema`, `content`, `title`, `required`, `properties`, `parameters`, `in`, `$ref`, `allOf`, `additionalProperties`, `enum`, `deprecated`, `items`, `requestBody`, `responses`, `get`, `post`, `delete`, `components`, `schemas`, `info`, `paths`, and `version`. Every one is valid in 3.0.x with identical semantics. So the document is already a valid 3.0.3 document that happens to declare 3.1.0. **Declaring the oldest version the document actually conforms to widens the set of tools that can consume it.** 3.1 support across the OpenAPI ecosystem still lags 3.0 — client generators, validators, and renderers handle 3.0.x completely and 3.1 partially. `rest.rst` explicitly invites readers to generate client libraries from this spec, so the declared version directly affects whether that works for them. Nothing is gained by declaring 3.1 while using no 3.1 feature. There's a concrete in-repo case for this too. The doc build currently renders this spec with `sphinxcontrib-redoc`, unmaintained since 2020, and the maintained alternative from the same org, `sphinxcontrib-openapi`, has only partial 3.1 support: - The PR that added it, [sphinx-contrib/openapi#138](sphinx-contrib/openapi#138) (merged January 2023), is titled "Add **initial** OpenAPI 3.1 support" and its description says "we focus on the MVP here" with "a whole lot more to support here including things like webhooks." - [sphinx-contrib/openapi#160](sphinx-contrib/openapi#160) is an open, uncommented 3.1 rendering bug filed October 2024 — an unhandled `TypeError` in the `openapi31.py` code path. Declaring 3.0.3 removes that whole risk class from any future evaluation of that extension, at the cost of one line and no lost expressiveness. ## Related changes Stacked on #65457, which removes 21 invalid `summary` keys from Response Objects. That's a separate, version-independent validity fix; this PR is about the declared version only. ## What changes One line: `openapi: 3.1.0` → `openapi: 3.0.3`. **`info.version` deliberately stays at `4.0.0`.** It tracks the Ray Jobs API version, not the OpenAPI document version. The two are easy to conflate, so to be explicit: this PR changes only the OpenAPI specification version the document claims to conform to, and nothing about the API itself. ## The published page is unaffected, verified ReDoc handles both versions, so no visual change is expected — but this is a client-rendered page, and a green Sphinx build proves nothing about it. So I rendered the spec through the same pinned ReDoc v2.5.3 bundle the build uses, at both declared versions, and compared: | Check | Result | | --- | --- | | Rendered body text | **Byte-identical** (10,561 chars each) | | Full-page screenshot | **Pixel-identical** (same sha256) | | JavaScript errors or warnings | **None**, at either version | | Endpoint content actually rendered | Confirmed at both, so "identical" isn't two identical failures | ## Checks - [x] `openapi-spec-validator` reports `OK` against the declared 3.0.3. - [x] Rendered-output comparison above. - [x] `pre-commit run` clean on the staged change. - [x] Confirm `api.html` is unchanged in the Read the Docs preview for this PR. ## If you'd rather not take this Reasonable outcomes here include declining it. If the intent is that this spec should eventually use 3.1 features, say so and I'll close this — the useful part is then the recorded finding that nothing in the document depends on 3.1 today. --------- Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun
pushed a commit
to nadongjun/ray
that referenced
this pull request
Oct 6, 2026
…y-project#65458) > **Stacked PR.** This targets `doc-1513-remove-invalid-response-summary` (ray-project#65457), not `master`, because that PR makes the spec valid and this one shouldn't inherit a failing validator run. Review ray-project#65457 first; GitHub retargets this to `master` automatically when it merges. The two changes are independent in substance and can be split if you'd rather take them separately. ## Why this change is needed `doc/source/cluster/running-applications/job-submission/openapi.yml` declares `openapi: 3.1.0` and uses not one construct that requires 3.1. Audited the full spec for 3.1-only constructs. Every check came back empty: | 3.1-only construct | Present? | | --- | --- | | `jsonSchemaDialect` | no | | top-level `webhooks` | no | | `$schema` | no | | `const` | no | | `examples` (the plural, JSON-Schema-aligned form) | no | | type arrays (`type: [string, "null"]`) | no | | `null` type | no | | `info.summary` | no | It also uses no `nullable`, the 3.0-only keyword it would need if it had ever expressed nullability. The complete set of keywords in the file is `description`, `type`, `summary`, `schema`, `content`, `title`, `required`, `properties`, `parameters`, `in`, `$ref`, `allOf`, `additionalProperties`, `enum`, `deprecated`, `items`, `requestBody`, `responses`, `get`, `post`, `delete`, `components`, `schemas`, `info`, `paths`, and `version`. Every one is valid in 3.0.x with identical semantics. So the document is already a valid 3.0.3 document that happens to declare 3.1.0. **Declaring the oldest version the document actually conforms to widens the set of tools that can consume it.** 3.1 support across the OpenAPI ecosystem still lags 3.0 — client generators, validators, and renderers handle 3.0.x completely and 3.1 partially. `rest.rst` explicitly invites readers to generate client libraries from this spec, so the declared version directly affects whether that works for them. Nothing is gained by declaring 3.1 while using no 3.1 feature. There's a concrete in-repo case for this too. The doc build currently renders this spec with `sphinxcontrib-redoc`, unmaintained since 2020, and the maintained alternative from the same org, `sphinxcontrib-openapi`, has only partial 3.1 support: - The PR that added it, [sphinx-contrib/openapi#138](sphinx-contrib/openapi#138) (merged January 2023), is titled "Add **initial** OpenAPI 3.1 support" and its description says "we focus on the MVP here" with "a whole lot more to support here including things like webhooks." - [sphinx-contrib/openapi#160](sphinx-contrib/openapi#160) is an open, uncommented 3.1 rendering bug filed October 2024 — an unhandled `TypeError` in the `openapi31.py` code path. Declaring 3.0.3 removes that whole risk class from any future evaluation of that extension, at the cost of one line and no lost expressiveness. ## Related changes Stacked on ray-project#65457, which removes 21 invalid `summary` keys from Response Objects. That's a separate, version-independent validity fix; this PR is about the declared version only. ## What changes One line: `openapi: 3.1.0` → `openapi: 3.0.3`. **`info.version` deliberately stays at `4.0.0`.** It tracks the Ray Jobs API version, not the OpenAPI document version. The two are easy to conflate, so to be explicit: this PR changes only the OpenAPI specification version the document claims to conform to, and nothing about the API itself. ## The published page is unaffected, verified ReDoc handles both versions, so no visual change is expected — but this is a client-rendered page, and a green Sphinx build proves nothing about it. So I rendered the spec through the same pinned ReDoc v2.5.3 bundle the build uses, at both declared versions, and compared: | Check | Result | | --- | --- | | Rendered body text | **Byte-identical** (10,561 chars each) | | Full-page screenshot | **Pixel-identical** (same sha256) | | JavaScript errors or warnings | **None**, at either version | | Endpoint content actually rendered | Confirmed at both, so "identical" isn't two identical failures | ## Checks - [x] `openapi-spec-validator` reports `OK` against the declared 3.0.3. - [x] Rendered-output comparison above. - [x] `pre-commit run` clean on the staged change. - [x] Confirm `api.html` is unchanged in the Read the Docs preview for this PR. ## If you'd rather not take this Reasonable outcomes here include declining it. If the intent is that this spec should eventually use 3.1 features, say so and I'll close this — the useful part is then the recorded finding that nothing in the document depends on 3.1 today. --------- Signed-off-by: Douglas Strodtman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This isn't my finest work but it passes with the schema I'm using locally.
There are quite a few changes in OpenAPI 3.1 but two are addressed here:
There's a whole lot more to support here including things like webhooks but we
focus on the MVP here. All that extra functionality can be added later.
A list of commits:
Add initial framework for OpenAPI 3.1OAS 3.1: Support specs without 'paths'OAS 3.1: Support null typeOAS 3.1: Prefer non-null valuestox: Allow running specific testsUpdate OpenAPI-Specification submoduleAdd tests for OpenAPI 3.1 schemas