[core] Treat an OAS 3.1 boolean schema false as closed additionalProperties (#25430)

CP
10h ago
+50-9

Fixes #25430

With OAS 3.1, swagger-parser can represent additionalProperties: false as a Schema with booleanSchemaValue false. The issue spec triggers this representation when a property defines an inline map.

ModelUtils.isMapSchema treats this value as closed. DefaultCodegen.setAddProps previously treated it as a typed schema. The model therefore had additional-properties accessors but no HashMap parent. The generated jaxrs-spec model did not compile.

Treat a false boolean schema like Boolean.FALSE in setAddProps and addRequiredVarsMap. This matches the existing ModelUtils checks. A closed schema no longer exposes additional-properties members.

The shared codegen fix was chosen over a {{#parent}} guard in the jaxrs-spec template. The template guard would only hide the inconsistent model state for one generator.

Regenerating the affected samples changed only PropertiesWithAnyOf.cs. Its additionalProperties: false schema no longer produces an AdditionalProperties dictionary.

Testing

  • The new regression test fails on origin/master with java.lang.AssertionError: expected [false] but found [true]. It passes with the fix.
  • DefaultCodegenTest, JavaJAXRSSpecServerCodegenTest, OpenAPINormalizerTest, ModelUtilsTest, DefaultGeneratorTest, InlineModelResolverTest, and org.openapitools.codegen.java.**: 1822 tests, 0 failures, 0 errors.
  • The baseline issue project fails to compile with 3 errors in PatchRequest.java. The fixed issue project compiles successfully.
  • Regenerated all three sample configs whose OAS 3.1 inputs contain additionalProperties: false: csharp-generichost-latest-annotatedEnum, jetbrains-http-client-adyen-checkout-new, and rust-reqwest-regression-16119. No generated changes were missing from the commit.
  • The regenerated C# project builds with 0 warnings and 0 errors.

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
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes OAS 3.1 additionalProperties: false handling so closed schemas no longer generate uncompilable jaxrs-spec models. Swagger-parser represents additionalProperties: false as a boolean schema instead of Boolean.FALSE, and DefaultCodegen.setAddProps previously treated it as a typed schema, producing additional-properties accessors without a HashMap parent. The fix treats a false boolean schema like Boolean.FALSE in setAddProps and addRequiredVarsMap, matching the existing ModelUtils checks. The shared codegen fix was chosen over a {{#parent}} template guard, which would only hide the inconsistent model state for one generator. Regenerated samples change only PropertiesWithAnyOf.cs, which no longer emits an AdditionalProperties dictionary. A regression test covers the inline-map case; it fails on master without the fix.