Skip to content

[doc] Render the Jobs API spec with sphinxcontrib-openapi instead of ReDoc - #65460

Merged
dstrodtman merged 6 commits into
masterfrom
doc-1514-migrate-openapi-renderer
Sep 3, 2026
Merged

dstrodtman merged 6 commits into
masterfrom
doc-1514-migrate-openapi-renderer

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PR. Targets doc-1513-declare-openapi-303 (#65458), which targets #65457. Review order is #65457 → #65458 → this. GitHub retargets automatically as each merges.

Conflicts with #65456 by design. That PR pins redoc_uri to a specific ReDoc version; this one deletes redoc_uri entirely. If #65456 lands first I'll resolve the conflict here. If this lands, #65456 becomes moot and should be closed. Either order works — #65456 is worth keeping as the safe fix in case this one stalls in review.

Why this change is needed

sphinxcontrib-redoc is unmaintained. 1.6.0 is the latest release and dates from 2020; the 2.0.0a1 alpha still imports pkg_resources. Keeping it costs this repo three things:

Cost Location
A setuptools<82 ceiling, because the extension imports pkg_resources at module load and setuptools 82 removed it doc/requirements-doc.txt
A misc.copy_overwrite entry in suppress_warnings, because the extension redundantly copies its own bundled asset doc/source/conf.py
The renderer fetched from a third-party CDN at page-view time doc/source/conf.py

All of that buys exactly one page. The Jobs API spec is the only consumer: conf.py had one redoc entry and there's no other OpenAPI document in the repo.

There's a second, larger reason. The current page is a client-rendered JavaScript island. ReDoc has no source file at all — the extension synthesizes api.html from conf.py. So today the page:

  • is in no toctree, and
  • is reachable only through a hardcoded `... <api.html>`_ link at rest.rst:94, and
  • has none of its endpoint content in the built HTML, so it can't participate in Sphinx search or cross-referencing.

Related changes

Fourth in the chain above. Supersedes the "record why we stay on ReDoc" PR (#65459), which I'll close — its conclusion is obsolete now that this works.

What changes

  • Swap sphinxcontrib.redoc → sphinxcontrib.openapi (0.9.0) in conf.py and doc/requirements-doc.txt, and regenerate the deplock.
  • Add a real api.md, put it in the job-submission toctree, and replace the raw <api.html> link with a :ref:.
  • Drop the now-unneeded misc.copy_overwrite suppression.
  • Change two operation summary fields from YAML block scalars to plain scalars (see below).
  • Update the setuptools comment: the <82 ceiling's cause is gone. The pin itself is left in place, since unpinning is a separate resolve worth verifying on its own.

sphinxcontrib-openapi is pure Python, from the same sphinx-contrib org, and needs no pkg_resources. The deplock diff is -sphinxcontrib-redoc and +sphinxcontrib-openapi plus its five dependencies (sphinxcontrib-httpdomain, sphinx-mdinclude, deepmerge, mistune, picobox).

Verification

Built with make -C doc rtd-build, which runs the RtD-faithful clean build with -W, matching fail_on_warning: true:

build succeeded.

Exit 0, and zero WARNING:/ERROR: lines in the whole log. raydepsets --check on docbuild_depset_311 reports "Lock files are up to date."

Checked against the built api.html rather than inferred:

Check Result
Request/response schemas rendered Yes — Request JSON Object and Response JSON Object field lists, with entrypoint, runtime_env, metadata, and the rest, including types and required flags
$ref and allOf resolution Resolved, including through JobDetails
Literal ** on the page None — zero docutils problematic nodes
http-routingtable index Generated
Page in the sidebar, with prev/next pagination Yes
MyST page equivalent to the .rst draft it replaced Yes — 8 httpdomain operation objects, identical Parameters / Request JSON Object / Response JSON Object / Status Codes field lists, no leaked rST, and both :ref: directions resolving with the right link text

Three non-obvious configuration details

All three are commented at their sites in the diff, because all three fail quietly.

The renderer is selected via openapi_default_renderer, not by the directive spelling. Writing .. openapi:httpdomain:: in the page adds an unknown directive name warning, which is fatal under fail_on_warning. Selecting it in conf.py and using a plain .. openapi:: avoids that.

The default renderer emits no request or response schemas at all — just paths, parameters, and status codes. So leaving openapi_default_renderer unset would silently drop most of the reference content while still building green. That's the trap worth knowing about if anyone touches this later.

The openapi directive can't be a bare MyST fence; it has to be wrapped in eval-rst. sphinxcontrib-openapi emits reStructuredText into a ViewList and hands it to nested_parse, but MyST's nested_parse renders that content as Markdown. A ```{openapi} fence therefore builds green with zero warnings while silently degrading the entire page: every .. http:get:: and :resjson: line renders as literal text, so nothing becomes an httpdomain object and the page has no field lists, no anchors, and no search or cross-referencing. That's a worse failure than the one above, and just as quiet.

Why the summary fields change

sphinxcontrib-openapi's renderer interpolates an operation's summary into **...** without stripping it. A YAML block scalar (summary: |) leaves a trailing newline in the value, so the markup opens on one line and closes on the next, docutils can't pair it, and readers see literal asterisks. Filed upstream as sphinx-contrib/openapi#173.

Two operations used block scalars (GET /api/version and POST /api/jobs); the other six already used plain scalars. Converting those two is the whole fix and changes no rendered text.

What this gives up, honestly

Request and response samples. ReDoc rendered example payloads; this doesn't. It isn't a configuration choice — both routes to examples are blocked by upstream bugs, and I've confirmed each against this spec:

  • :generate-examples-from-schemas: crashes with ValueError: dictionary update sequence element #0 has length 1; 2 is required (#166). Example generation can't handle an allOf that targets a non-object schema, which is exactly how JobDetails attaches descriptions to the JobType and JobStatus string enums.
  • :response-examples-for: is rejected as an unknown option (#165).

api.md carries a comment recording this so nobody re-derives it, and I've added the reproduction detail to both upstream issues. Weighed against gaining search, cross-referencing, navigation, a dependency that's actually maintained, and no third-party CDN at page-view time, losing sample payloads seemed like the right trade — but it is a real loss, and it's reasonable to want the upstream fixes first instead.

I've also filed #171, #172, and #173, each with a minimal reproducer, and am planning PRs for them.

Checks

  • make -C doc rtd-build: build succeeded, zero warnings.
  • raydepsets --check: lock files up to date.
  • Built page inspected for schema content, allOf/$ref resolution, and stray markup.
  • pre-commit run clean.
  • Read the Docs preview reviewed for the appearance change.

`summary` is not a valid field on an OpenAPI Response Object in either 3.0.x or
3.1. The valid fields are `description`, `headers`, `content`, and `links`. The
Ray Jobs API spec carries 21 of them, which makes the document fail validation
against the 3.1.0 version it declares:

    Unevaluated properties are not allowed ('summary' was unexpected)

ReDoc ignores unknown keys, so the published page is unaffected. Verified by
probing the rendered DOM of the live page: every one of the 21 summary strings
is absent from the rendered text while the sibling `description` of the same
Response Object renders, so the responses are reached and the key is dropped.

Every affected response already has a `description` that states the same thing
in prose, so removing the key loses no documented content and leaves the
required `description` field in place.

After this change the spec validates cleanly against 3.1.0. No other edits.

Signed-off-by: Douglas Strodtman <[email protected]>
The Ray Jobs API spec declares `openapi: 3.1.0` but uses no construct that
requires 3.1. There's no `jsonSchemaDialect`, no top-level `webhooks`, no
`$schema`, no `const`, no JSON-Schema-aligned `examples`, no type arrays, no
`null` type, and no `info.summary`. It also uses no `nullable`, the 3.0-only
keyword it would need if it expressed nullability anywhere. Every keyword in the
file is valid in 3.0.x with identical semantics.

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. The Ray Jobs REST API docs explicitly invite 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. If a future
change needs a 3.1 construct, bumping the version then is a deliberate,
reviewable act with a reason attached.

`info.version` stays at 4.0.0. It tracks the Ray Jobs API version, not the
OpenAPI document version, so it's unrelated to this change.

Verified that the rendered page is unaffected: rendering the spec through the
pinned ReDoc v2.5.3 bundle at both declared versions produces byte-identical
rendered text and a pixel-identical screenshot, with no JavaScript errors
either way.

Signed-off-by: Douglas Strodtman <[email protected]>
…ReDoc

`sphinxcontrib-redoc` is unmaintained: 1.6.0 is the latest release and dates
from 2020, and the 2.0.0a1 alpha still imports `pkg_resources`. It cost this
repo three things: a `setuptools<82` ceiling, a `misc.copy_overwrite` entry in
`suppress_warnings`, and a renderer fetched from a third-party CDN at page-view
time. All of that bought exactly one page, since the Jobs API spec is the only
consumer.

Replace it with `sphinxcontrib-openapi` 0.9.0, actively maintained by the same
sphinx-contrib org, pure Python, no bundled JS, no `pkg_resources`.

The page stops being a client-rendered JavaScript island. ReDoc had no source
file at all: the extension synthesized `api.html` from `conf.py`, the page was in
no toctree, and `rest.rst` linked it as a raw `<api.html>`. Its endpoint content
never appeared in the built HTML, so it couldn't participate in Sphinx search or
cross-referencing. This adds a real `api.rst`, puts it in the toctree, and
replaces the raw link with a `:ref:`. The build now also emits an
`http-routingtable` index.

Two configuration details that aren't obvious and are commented at their sites.
The renderer is selected with `openapi_default_renderer` rather than by writing
`.. openapi:httpdomain::`, because the directive spelling adds an "unknown
directive name" warning and `.readthedocs.yaml` sets `fail_on_warning: true`.
And the default renderer silently emits no request or response schemas at all,
so leaving it unset would quietly drop most of the reference content.

Operation summaries change from YAML block scalars to plain scalars. A block
scalar leaves a trailing newline that the renderer interpolates into `**...**`,
which docutils can't pair, putting literal asterisks on the page
(sphinx-contrib/openapi#173). Two operations were affected.

Request and response examples aren't enabled, and can't be yet;
`api.rst` records why and links the two upstream bugs.

Verified with an RtD-faithful build (`make -C doc rtd-build`, which runs `-W`):
build succeeded, zero warnings, and the rendered page carries the full request
and response schemas with no literal asterisks.

Signed-off-by: Douglas Strodtman <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the unmaintained sphinxcontrib-redoc extension with sphinxcontrib-openapi for rendering the Ray Jobs REST API OpenAPI specification. It introduces a new api.rst page to generate the API reference documentation, updates the Sphinx configuration (conf.py) and requirements, cleans up the OpenAPI specification file, and updates the dependency lockfile accordingly. As there are no review comments, I have no additional feedback to provide.

The new reference page landed as `api.rst`, which the no-new-.rst check
correctly rejects. Rewrite it as `api.md`.

The `openapi` directive can't be a bare MyST fence. sphinxcontrib-openapi
emits reStructuredText into a ViewList and hands it to `nested_parse`, but
MyST's `nested_parse` renders that content as Markdown. A ```{openapi}```
fence therefore builds green with zero warnings while silently degrading the
whole page: every `.. http:get::` and `:resjson:` line renders as literal
text, so nothing becomes an httpdomain object and the page has no field
lists, no anchors, and no search or cross-referencing. Wrapping the directive
in `eval-rst` parses it with a real rST parser.

Verified the built page is equivalent to the `.rst` version it replaces: 8
httpdomain operation objects, the same Parameters, Request JSON Object,
Response JSON Object, and Status Codes field lists, no leaked rST, and both
`:ref:` directions resolving with the right link text.

Signed-off-by: Douglas Strodtman <[email protected]>
@ray-gardener ray-gardener Bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Aug 13, 2026
Base automatically changed from doc-1513-declare-openapi-303 to master August 27, 2026 18:12
@dstrodtman
dstrodtman requested a review from a team as a code owner August 27, 2026 18:12

@ronny-anyscale ronny-anyscale left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

snap

…conflict

Signed-off-by: Douglas Strodtman <[email protected]>

# Conflicts:
#	doc/source/conf.py
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Sep 2, 2026
@dstrodtman
dstrodtman merged commit c31fbb4 into master Sep 3, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-1514-migrate-openapi-renderer branch September 3, 2026 20:21
dstrodtman added a commit that referenced this pull request Sep 4, 2026
> **Stacked on #65460** (redoc → `sphinxcontrib-openapi`), which removes
the `pkg_resources` importer that forced the `setuptools<82` ceiling.
That PR must merge first, so this stays a **draft** until then. GitHub
retargets this to `master` automatically when #65460 merges.

## Why

The `setuptools==80.9.0` pin in `doc/requirements-doc.txt` carried a
`<82` ceiling that existed for exactly one reason: `sphinxcontrib-redoc`
imported `pkg_resources` at module load, and setuptools 82.0.0 removed
`pkg_resources`. #65460 replaces redoc with `sphinxcontrib-openapi`
(which needs neither) and verified that every extension `conf.py` loads
imports cleanly with no setuptools and no importable `pkg_resources`.
The ceiling is obsolete, and #65460 deliberately left lifting the pin to
this follow-up.

## What changes

- Unpin `setuptools` in `doc/requirements-doc.txt`. The deplock pins the
resolved version.

## Remaining before un-drafting (finish-time gates, on the final #65460
base)

- [x] Regenerate `python/deplocks/docs/docbuild_depset_py3.11.lock` via
raydepsets; confirm `raydepsets --check`.
- [x] `make -C doc rtd-build`: build succeeded, zero warnings under
`-W`, confirming the current setuptools release resolves and builds.

Deferred on purpose: #65460 is still in review and will likely rebase
before it merges, which would rot a lock regenerated now. Both gates run
against its final base once it lands.

Open question for review: unpin (this PR) vs. bump-and-pin to a specific
current release. Unpinning matches the file's existing floating entries
(for example `sphinxemoji>=0.3.2`) and defers the exact version to the
lock; happy to pin a fixed setuptools instead if the team prefers.

Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…ReDoc (ray-project#65460)

> **Stacked PR.** Targets `doc-1513-declare-openapi-303` (ray-project#65458), which
targets ray-project#65457. Review order is ray-project#65457 → ray-project#65458 → this. GitHub retargets
automatically as each merges.
>
> **Conflicts with ray-project#65456 by design.** That PR pins `redoc_uri` to a
specific ReDoc version; this one deletes `redoc_uri` entirely. If ray-project#65456
lands first I'll resolve the conflict here. If this lands, ray-project#65456
becomes moot and should be closed. Either order works — ray-project#65456 is worth
keeping as the safe fix in case this one stalls in review.

## Why this change is needed

`sphinxcontrib-redoc` is unmaintained. 1.6.0 is the latest release and
dates from 2020; the `2.0.0a1` alpha still imports `pkg_resources`.
Keeping it costs this repo three things:

| Cost | Location |
| --- | --- |
| A `setuptools<82` ceiling, because the extension imports
`pkg_resources` at module load and setuptools 82 removed it |
`doc/requirements-doc.txt` |
| A `misc.copy_overwrite` entry in `suppress_warnings`, because the
extension redundantly copies its own bundled asset |
`doc/source/conf.py` |
| The renderer fetched from a third-party CDN at page-view time |
`doc/source/conf.py` |

All of that buys exactly one page. The Jobs API spec is the only
consumer: `conf.py` had one `redoc` entry and there's no other OpenAPI
document in the repo.

There's a second, larger reason. **The current page is a client-rendered
JavaScript island.** ReDoc has no source file at all — the extension
synthesizes `api.html` from `conf.py`. So today the page:

- is in **no toctree**, and
- is reachable only through a hardcoded `` `... <api.html>`_ `` link at
`rest.rst:94`, and
- has **none of its endpoint content in the built HTML**, so it can't
participate in Sphinx search or cross-referencing.

## Related changes

Fourth in the chain above. Supersedes the "record why we stay on ReDoc"
PR (ray-project#65459), which I'll close — its conclusion is obsolete now that this
works.

## What changes

- Swap `sphinxcontrib.redoc` → `sphinxcontrib.openapi` (0.9.0) in
`conf.py` and `doc/requirements-doc.txt`, and regenerate the deplock.
- Add a real `api.md`, put it in the `job-submission` toctree, and
replace the raw `<api.html>` link with a `:ref:`.
- Drop the now-unneeded `misc.copy_overwrite` suppression.
- Change two operation `summary` fields from YAML block scalars to plain
scalars (see below).
- Update the `setuptools` comment: the `<82` ceiling's cause is gone.
The pin itself is left in place, since unpinning is a separate resolve
worth verifying on its own.

`sphinxcontrib-openapi` is pure Python, from the same `sphinx-contrib`
org, and needs no `pkg_resources`. The deplock diff is
`-sphinxcontrib-redoc` and `+sphinxcontrib-openapi` plus its five
dependencies (`sphinxcontrib-httpdomain`, `sphinx-mdinclude`,
`deepmerge`, `mistune`, `picobox`).

## Verification

Built with `make -C doc rtd-build`, which runs the RtD-faithful clean
build with `-W`, matching `fail_on_warning: true`:

```
build succeeded.
```

Exit 0, and **zero `WARNING:`/`ERROR:` lines in the whole log**.
`raydepsets --check` on `docbuild_depset_311` reports "Lock files are up
to date."

Checked against the built `api.html` rather than inferred:

| Check | Result |
| --- | --- |
| Request/response schemas rendered | Yes — `Request JSON Object` and
`Response JSON Object` field lists, with `entrypoint`, `runtime_env`,
`metadata`, and the rest, including types and required flags |
| `$ref` and `allOf` resolution | Resolved, including through
`JobDetails` |
| Literal `**` on the page | None — zero docutils `problematic` nodes |
| `http-routingtable` index | Generated |
| Page in the sidebar, with prev/next pagination | Yes |
| MyST page equivalent to the `.rst` draft it replaced | Yes — 8
httpdomain operation objects, identical `Parameters` / `Request JSON
Object` / `Response JSON Object` / `Status Codes` field lists, no leaked
rST, and both `:ref:` directions resolving with the right link text |

## Three non-obvious configuration details

All three are commented at their sites in the diff, because all three
fail quietly.

**The renderer is selected via `openapi_default_renderer`, not by the
directive spelling.** Writing `.. openapi:httpdomain::` in the page adds
an `unknown directive name` warning, which is fatal under
`fail_on_warning`. Selecting it in `conf.py` and using a plain `..
openapi::` avoids that.

**The default renderer emits no request or response schemas at all** —
just paths, parameters, and status codes. So leaving
`openapi_default_renderer` unset would silently drop most of the
reference content while still building green. That's the trap worth
knowing about if anyone touches this later.

**The `openapi` directive can't be a bare MyST fence; it has to be
wrapped in `eval-rst`.** `sphinxcontrib-openapi` emits reStructuredText
into a `ViewList` and hands it to `nested_parse`, but MyST's
`nested_parse` renders that content as Markdown. A ```` ```{openapi}
```` fence therefore builds green with zero warnings while silently
degrading the entire page: every `.. http:get::` and `:resjson:` line
renders as literal text, so nothing becomes an httpdomain object and the
page has no field lists, no anchors, and no search or cross-referencing.
That's a worse failure than the one above, and just as quiet.

## Why the summary fields change

`sphinxcontrib-openapi`'s renderer interpolates an operation's `summary`
into `**...**` without stripping it. A YAML block scalar (`summary: |`)
leaves a trailing newline in the value, so the markup opens on one line
and closes on the next, docutils can't pair it, and readers see literal
asterisks. Filed upstream as
[sphinx-contrib/openapi#173](sphinx-contrib/openapi#173).

Two operations used block scalars (`GET /api/version` and `POST
/api/jobs`); the other six already used plain scalars. Converting those
two is the whole fix and changes no rendered text.

## What this gives up, honestly

**Request and response samples.** ReDoc rendered example payloads; this
doesn't. It isn't a configuration choice — both routes to examples are
blocked by upstream bugs, and I've confirmed each against this spec:

- `:generate-examples-from-schemas:` crashes with `ValueError:
dictionary update sequence element #0 has length 1; 2 is required`
([ray-project#166](sphinx-contrib/openapi#166)). Example
generation can't handle an `allOf` that targets a non-object schema,
which is exactly how `JobDetails` attaches descriptions to the `JobType`
and `JobStatus` string enums.
- `:response-examples-for:` is rejected as an unknown option
([ray-project#165](sphinx-contrib/openapi#165)).

`api.md` carries a comment recording this so nobody re-derives it, and
I've added the reproduction detail to both upstream issues. Weighed
against gaining search, cross-referencing, navigation, a dependency
that's actually maintained, and no third-party CDN at page-view time,
losing sample payloads seemed like the right trade — but it is a real
loss, and it's reasonable to want the upstream fixes first instead.

I've also filed
[ray-project#171](sphinx-contrib/openapi#171),
[ray-project#172](sphinx-contrib/openapi#172), and
[ray-project#173](sphinx-contrib/openapi#173), each with
a minimal reproducer, and am planning PRs for them.

## Checks

- [x] `make -C doc rtd-build`: build succeeded, zero warnings.
- [x] `raydepsets --check`: lock files up to date.
- [x] Built page inspected for schema content, `allOf`/`$ref`
resolution, and stray markup.
- [x] `pre-commit run` clean.
- [x] Read the Docs preview reviewed for the appearance change.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…oject#65875)

> **Stacked on ray-project#65460** (redoc → `sphinxcontrib-openapi`), which removes
the `pkg_resources` importer that forced the `setuptools<82` ceiling.
That PR must merge first, so this stays a **draft** until then. GitHub
retargets this to `master` automatically when ray-project#65460 merges.

## Why

The `setuptools==80.9.0` pin in `doc/requirements-doc.txt` carried a
`<82` ceiling that existed for exactly one reason: `sphinxcontrib-redoc`
imported `pkg_resources` at module load, and setuptools 82.0.0 removed
`pkg_resources`. ray-project#65460 replaces redoc with `sphinxcontrib-openapi`
(which needs neither) and verified that every extension `conf.py` loads
imports cleanly with no setuptools and no importable `pkg_resources`.
The ceiling is obsolete, and ray-project#65460 deliberately left lifting the pin to
this follow-up.

## What changes

- Unpin `setuptools` in `doc/requirements-doc.txt`. The deplock pins the
resolved version.

## Remaining before un-drafting (finish-time gates, on the final ray-project#65460
base)

- [x] Regenerate `python/deplocks/docs/docbuild_depset_py3.11.lock` via
raydepsets; confirm `raydepsets --check`.
- [x] `make -C doc rtd-build`: build succeeded, zero warnings under
`-W`, confirming the current setuptools release resolves and builds.

Deferred on purpose: ray-project#65460 is still in review and will likely rebase
before it merges, which would rot a lock regenerated now. Both gates run
against its final base once it lands.

Open question for review: unpin (this PR) vs. bump-and-pin to a specific
current release. Unpinning matches the file's existing floating entries
(for example `sphinxemoji>=0.3.2`) and defers the exact version to the
lock; happy to pin a fixed setuptools instead if the team prefers.

Signed-off-by: Douglas Strodtman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants