Repository navigation
Conversation
There was a problem hiding this comment.
3 issues found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/test/resources/3_1/issue_25430.yaml">
<violation number="1" location="modules/openapi-generator/src/test/resources/3_1/issue_25430.yaml:25">
P3: This fixture only covers the `setAddProps` change. Add a `required` entry for a property not declared in `properties` (for example `required: [missing]`) to `PatchRequest`, and assert the generated model in the test. That exercises the `addRequiredVarsMap` change, which the test does not currently cover.</violation>
</file>
<file name="modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java">
<violation number="1" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:3668">
P3: This helper repeats the false-boolean `additionalProperties` check that `ModelUtils.isMapSchema` and `ModelUtils.isModelWithPropertiesOnly` already inline. Move it to `ModelUtils` as a public static method and call it from both places, so the OAS 3.1 closed-schema rule lives in one place.</violation>
<violation number="2" location="modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java:3670">
P2: The checked-in OpenAPI input uses `additionalProperties: {}` for `PropertiesWithAnyOf`, but this regeneration removes its `AdditionalProperties` dictionary. Preserve open empty schemas; only suppress the member for an actual boolean-false schema.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| // OAS 3.1 can parse `additionalProperties: false` as a boolean schema instead of Boolean.FALSE | ||
| private static boolean isBooleanSchemaFalse(Object additionalProperties) { | ||
| return additionalProperties instanceof Schema | ||
| && Boolean.FALSE.equals(((Schema) additionalProperties).getBooleanSchemaValue()); |
There was a problem hiding this comment.
P2: The checked-in OpenAPI input uses additionalProperties: {} for PropertiesWithAnyOf, but this regeneration removes its AdditionalProperties dictionary. Preserve open empty schemas; only suppress the member for an actual boolean-false schema.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java, line 3670:
<comment>The checked-in OpenAPI input uses `additionalProperties: {}` for `PropertiesWithAnyOf`, but this regeneration removes its `AdditionalProperties` dictionary. Preserve open empty schemas; only suppress the member for an actual boolean-false schema.</comment>
<file context>
@@ -3664,6 +3664,12 @@ protected void setAddProps(Schema schema, IJsonSchemaValidationProperties proper
+ // OAS 3.1 can parse `additionalProperties: false` as a boolean schema instead of Boolean.FALSE
+ private static boolean isBooleanSchemaFalse(Object additionalProperties) {
+ return additionalProperties instanceof Schema
+ && Boolean.FALSE.equals(((Schema) additionalProperties).getBooleanSchemaValue());
+ }
+
</file context>
| context: | ||
| type: object | ||
| additionalProperties: true | ||
| additionalProperties: false |
There was a problem hiding this comment.
P3: This fixture only covers the setAddProps change. Add a required entry for a property not declared in properties (for example required: [missing]) to PatchRequest, and assert the generated model in the test. That exercises the addRequiredVarsMap change, which the test does not currently cover.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/test/resources/3_1/issue_25430.yaml, line 25:
<comment>This fixture only covers the `setAddProps` change. Add a `required` entry for a property not declared in `properties` (for example `required: [missing]`) to `PatchRequest`, and assert the generated model in the test. That exercises the `addRequiredVarsMap` change, which the test does not currently cover.</comment>
<file context>
@@ -0,0 +1,25 @@
+ context:
+ type: object
+ additionalProperties: true
+ additionalProperties: false
</file context>
| } | ||
|
|
||
| // OAS 3.1 can parse `additionalProperties: false` as a boolean schema instead of Boolean.FALSE | ||
| private static boolean isBooleanSchemaFalse(Object additionalProperties) { |
There was a problem hiding this comment.
P3: This helper repeats the false-boolean additionalProperties check that ModelUtils.isMapSchema and ModelUtils.isModelWithPropertiesOnly already inline. Move it to ModelUtils as a public static method and call it from both places, so the OAS 3.1 closed-schema rule lives in one place.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java, line 3668:
<comment>This helper repeats the false-boolean `additionalProperties` check that `ModelUtils.isMapSchema` and `ModelUtils.isModelWithPropertiesOnly` already inline. Move it to `ModelUtils` as a public static method and call it from both places, so the OAS 3.1 closed-schema rule lives in one place.</comment>
<file context>
@@ -3664,6 +3664,12 @@ protected void setAddProps(Schema schema, IJsonSchemaValidationProperties proper
}
+ // OAS 3.1 can parse `additionalProperties: false` as a boolean schema instead of Boolean.FALSE
+ private static boolean isBooleanSchemaFalse(Object additionalProperties) {
+ return additionalProperties instanceof Schema
+ && Boolean.FALSE.equals(((Schema) additionalProperties).getBooleanSchemaValue());
</file context>
Fixes #25430
With OAS 3.1, swagger-parser can represent
additionalProperties: falseas aSchemawithbooleanSchemaValuefalse. The issue spec triggers this representation when a property defines an inline map.ModelUtils.isMapSchematreats this value as closed.DefaultCodegen.setAddPropspreviously treated it as a typed schema. The model therefore had additional-properties accessors but noHashMapparent. The generated jaxrs-spec model did not compile.Treat a false boolean schema like
Boolean.FALSEinsetAddPropsandaddRequiredVarsMap. This matches the existingModelUtilschecks. 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. ItsadditionalProperties: falseschema no longer produces anAdditionalPropertiesdictionary.Testing
origin/masterwithjava.lang.AssertionError: expected [false] but found [true]. It passes with the fix.DefaultCodegenTest,JavaJAXRSSpecServerCodegenTest,OpenAPINormalizerTest,ModelUtilsTest,DefaultGeneratorTest,InlineModelResolverTest, andorg.openapitools.codegen.java.**: 1822 tests, 0 failures, 0 errors.PatchRequest.java. The fixed issue project compiles successfully.additionalProperties: false:csharp-generichost-latest-annotatedEnum,jetbrains-http-client-adyen-checkout-new, andrust-reqwest-regression-16119. No generated changes were missing from the commit.PR checklist
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.
Summary by cubic
Fixes OAS 3.1
additionalProperties: falsehandling so closed schemas no longer generate uncompilable jaxrs-spec models. Swagger-parser representsadditionalProperties: falseas a boolean schema instead ofBoolean.FALSE, andDefaultCodegen.setAddPropspreviously treated it as a typed schema, producing additional-properties accessors without aHashMapparent. The fix treats a false boolean schema likeBoolean.FALSEinsetAddPropsandaddRequiredVarsMap, matching the existingModelUtilschecks. 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 onlyPropertiesWithAnyOf.cs, which no longer emits anAdditionalPropertiesdictionary. A regression test covers the inline-map case; it fails on master without the fix.Written for commit b7fdf73. Summary will update on new commits.