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

RO
1d ago
+37-1

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