Skip to content

add tests showing that nullability is dropped for Option<T> bodies - #1750

Merged
sunshowers merged 2 commits into
mainfrom
sunshowers/spr/add-tests-showing-nullability-dropped-for-optiont-bodies
Oct 29, 2026
Merged

sunshowers merged 2 commits into
mainfrom
sunshowers/spr/add-tests-showing-nullability-dropped-for-optiont-bodies

Conversation

@sunshowers

Copy link
Copy Markdown
Collaborator

Currently, on seeing an endpoint with request and/or response bodies of type
Option<CoolStruct>, Dropshot represents it in OpenAPI as a plain $ref to
CoolStruct, with nullability dropped.

These tests record the current, incorrect behavior. The next commit
fixes it.

@sunshowers
sunshowers added this pull request to stack #1752 October 27, 2026 23:51
@sunshowers
sunshowers requested a review from ahl October 27, 2026 23:53
@sunshowers sunshowers changed the title add tests showing nullability dropped for Option<T> bodies add tests showing that nullability is dropped for Option<T> bodies Oct 27, 2026

@ahl ahl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ok; are you going to squash these two PRs down or did you want each to land in main? Slight preference for the former, but up to you

@sunshowers

sunshowers commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

My plan was to land them separately. But I want to make sure our story re drift is straight before landing this stack, as discussed in chat


// BUG: Currently, the fact that the type is nullable is dropped,
// leading to the same output as Foo below.
let schema = make_subschema_for::<Option<Foo>>(&mut generator);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

FWIW, with SchemaSettings::openapiv3() one would expect the generated schema to be something like { allOf: [ { $ref: Foo }], nullable: true }, instead it seems to be:

{
  "$ref": "Foo",
  "nullable": true
}

... which isn't a valid OppenAPI 3.0.x schema

@sunshowers
sunshowers merged commit 0c94fdf into main Oct 29, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants