Skip to content

Support string coercion for array-form type in OpenAPI 3.1 (runtime) - #212

Merged
geemus merged 2 commits into
ota42y:masterfrom
treadinc:type-array-coercion
Oct 14, 2026
Merged

geemus merged 2 commits into
ota42y:masterfrom
treadinc:type-array-coercion

Conversation

@modosc

@modosc modosc commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

i started trying to wire up the recent 3.1 changes into committee and ran into an issue which this tries to resolve.

problem

committee passes query, path, and form params to openapi_parser as raw Strings and relies on coerce_value to convert them. 3.1 removed nullable, so a nullable param is written as type: [integer, "null"]. array-form type picks a type by matching the value's class, so "5" matches nothing and fails validation. every request that sends a nullable non-string param is rejected.

solution

  • with coerce_value on, a String that matches no type in an array-form type is coerced by trying each listed non-null type in order ("5" against [integer, "null"] becomes 5)
  • returns the first type that validates, otherwise the first type's error
  • exact class matches are unchanged (a String against [integer, string] stays a String)
  • not gated on document version, matching the other 3.1 runtime changes; array-form type is already flagged in 3.0 docs by TypeArrayIn30
  • no new SpecValidator rule, since this only changes runtime behavior for an existing keyword

depends on #211 (this branch includes its commit; only the last commit is new).

modosc and others added 2 commits September 24, 2026 15:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@geemus geemus 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.

lgtm, thanks!

@geemus
geemus merged commit 997134f into ota42y:master Oct 14, 2026
14 checks passed
@modosc
modosc deleted the type-array-coercion branch October 14, 2026 21:09
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