feat(apidocs): Hide enum values and nested fields from the schema - #123968
Open
azulus wants to merge 2 commits into
Open
feat(apidocs): Hide enum values and nested fields from the schema#123968azulus wants to merge 2 commits into
azulus wants to merge 2 commits into
Conversation
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
from
September 9, 2026 22:23
d7a4ca7 to
a1fc184
Compare
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
2 times, most recently
from
September 9, 2026 22:45
6b7be39 to
0194020
Compare
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
5 times, most recently
from
September 10, 2026 19:50
ba99947 to
54b6584
Compare
azulus
marked this pull request as ready for review
September 10, 2026 19:57
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
from
September 10, 2026 20:09
54b6584 to
6cbfb15
Compare
gricha
approved these changes
Sep 10, 2026
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
2 times, most recently
from
September 10, 2026 20:24
fdd50a9 to
6bf0381
Compare
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
from
September 10, 2026 20:28
6bf0381 to
51dcadf
Compare
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
from
September 10, 2026 20:37
51dcadf to
20d87d1
Compare
Withholding part of the public schema only works per field today, so anything
finer means hand-writing an OpenApiParameter constant beside the serializer it
duplicates. Those drift: /replay-count/ accepted the spans data source for 52
days before its constant mentioned it.
omit_from_public_schema keys become dotted paths, and the class of the field a
segment names decides what the next segment means, so data_source.discover has
one reading. Deprecation takes the same {path: reason} shape and now needs a
reason.
Withholding a value the field falls back to marks the parameter required and
drops the default, since a default only means anything for an optional
parameter. Crossing into a component several shapes share needs every one of
them to declare it.
Flat names are one-segment paths, so the 40 existing declarations are unchanged
and the schema is byte-identical until something adopts a path.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three OpenApiParameter constants duplicated the validator the endpoint already checks requests against, and keeping them in step was manual. It had already failed once: spans was accepted for 52 days before a constant mentioned it. Naming the validator in parameters= derives the documented parameters from the fields the handler validates with. data_source is unchanged. query becomes required, which the code enforces, and returnIds gains the default it applies. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
azulus
force-pushed
the
jeremy/apidocs-omission-paths
branch
from
September 10, 2026 21:08
20d87d1 to
f6fb5ca
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f6fb5ca. Configure here.
| target = _referenced_component(node) | ||
| if target is not None: | ||
| parents.setdefault(target, set()).add(owner) | ||
| return parents |
Contributor
There was a problem hiding this comment.
Parent check misses operation refs
Medium Severity
parents_by_component only records other schema components that hold a property $ref. It does not see a shared shape used as an operation request or response. A nested omission can therefore mutate that component and hide the field from an endpoint that never declared the path, which is the case this check is meant to block.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f6fb5ca. Configure here.
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.


Withholding part of the public schema only works per field today. Anything finer means hand-writing an
OpenApiParameterconstant beside the serializer it duplicates, and the copy drifts:/replay-count/accepted thespansdata source for 52 days before its constant mentioned it, and still documentsqueryas optional though the validator requires it.Keys in
omit_from_public_schemabecome dotted paths, so a choice value or a nested field can be named the way a plain field already could. The class of the field a segment names decides what the next segment means, sodata_source.discoverhas one reading and no second keyword is needed. Deprecation takes the same{path: reason}shape and now requires a reason. Withholding the value a field falls back to also drops the default and marks the parameter required, since a default only means anything for an optional one.Deprecating a choice is refused rather than accepted quietly: OpenAPI can express it with
oneOfbranches, but drf-spectacular emits a flat enum and generators collapse those branches, so the marker would reach nobody. A path may cross into a component several shapes share only when every one of them declares it, since hiding a field from a shared shape would hide it from an endpoint that never asked.Flat names are one-segment paths, so the 40 existing declarations are unchanged and the schema is byte-identical until something adopts a path. The second commit is the first adoption.
data_sourcecomes out exactly as before, so the deprecation those constants encoded survives being derived rather than transcribed;querybecomes required, which the validator declares andtest_invalid_params_query_requiredalready asserts.