Skip to content

fix(normalizer): keep any-type map values non-nullable when normalizing OAS 3.1 - #25812

Open
Robuske wants to merge 2 commits into
OpenAPITools:masterfrom
Robuske:normalizer-any-type-map-value-not-nullable
Open

Robuske wants to merge 2 commits into
OpenAPITools:masterfrom
Robuske:normalizer-any-type-map-value-not-nullable

Conversation

@Robuske

@Robuske Robuske commented Nov 25, 2026 •

Copy link
Copy Markdown

Follow-up to #23967 (which closed #23945): the new map branch in OpenAPINormalizer.normalizeSchema used ModelUtils.isNullTypeSchema, which also matches type-less schemas. As a result additionalProperties: {} and additionalProperties: true (any value) were rewritten to a nullable any-type, and generators emitted optional map values (swift6 [String: JSONValue?], kotlin Map<String, JsonElement?>).

The branch now only applies to a (resolved) value schema that is a null-type schema and not any-type, i.e. one that declares the null type (type: "null", type: ["null"], enum: [null], or a $ref to one). ModelUtils.isNullTypeSchema is unchanged because other callers rely on its current behavior.

Tests: extended testOpenAPINormalizer31SpecNullMapAdditionalProperties and 3_1/issue_23945.yaml with {}, true, enum: [null] and a $ref to {}; the test fails without the fix. ./mvnw clean package passes on JDK 11, and regenerating all samples (./bin/generate-samples.sh ./bin/configs/*.yaml) and the generator docs changes no files.

Fixes #25811

PR checklist

  • Read the contribution guidelines.

  • Run the following to build the project and update samples:

    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    

    No files changed.

  • If your PR is targeting a particular programming language, @mention the technical committee members. N/A: core change, no language target.


Summary by cubic

Fixes the OAS 3.1 normalizer so type-less map value schemas ({} and true) stay non-nullable when normalizing.

Previously additionalProperties: {} and additionalProperties: true were rewritten to nullable any-type, making generators emit optional map values like swift6 [String: JSONValue?].

  • The map branch now applies nullable only to explicit null-type schemas (type: "null", type: ["null"], enum: [null], or a $ref to one).
  • ModelUtils.isNullTypeSchema is unchanged since other callers depend on its current behavior.
  • Tests cover {}, true, enum: [null], and a $ref to an empty schema, and fail without the fix.

Fixes #25811

Written for commit d43eba3. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 3 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

@Robuske

Robuske commented Nov 26, 2026

Copy link
Copy Markdown
Author

@wing328 could you take a look when you have a moment? It's a small core fix in OpenAPINormalizer for #25811, a regression from #23967 where OAS 3.1 any-type map values (additionalProperties: {} / true) became nullable. It would be great to have it in 7.29.0. Thanks!

@Robuske
Robuske force-pushed the normalizer-any-type-map-value-not-nullable branch from 191b4db to a0c2d07 Compare November 26, 2026 20:35

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant