Skip to content

Conversation

@hniksic
Copy link

@hniksic hniksic commented Jan 14, 2026

Fixes #274.

Query strings cannot express null values - a parameter is either present with a value or absent - so null types in the schema don't make sense and cause issues for SDK generators.

The transformation handles two cases:

  • type: ["string", "null"], changed to type: "string"
  • anyOf: [{$ref: ...}, {type: "null"}], changed to {$ref: ...}

This is enabled by default and can be disabled if needed:

aide::generate::strip_query_null_types(false);

A manual method TransformOpenApi::strip_null_from_query_params() is also available if you need to apply it at a specific point in your transform chain.

Schemars generates null types for Option<T> fields (either
`type: ["string", "null"]` or `anyOf: [{...}, {type: "null"}]`),
but query strings cannot express null values - a parameter is
either present with a value or absent.

This change automatically strips null types from query parameter
schemas during finalization. The behavior is enabled by default
and can be disabled with `strip_query_null_types(false)`.
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.

Query parameter schemas include null types inappropriate for query strings

1 participant