Skip to content

Commit d1f95bb

Browse files
committed
fix tests
1 parent c22998c commit d1f95bb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
302302
// this is the legacy config that most of our tooling uses
303303
OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/additional-properties-for-testing.yaml");
304304
DefaultCodegen codegen = new DefaultCodegen();
305-
codegen.setOpenAPI(openAPI);
306305
codegen.setDisallowAdditionalPropertiesIfNotPresent(true);
306+
codegen.setOpenAPI(openAPI);
307307

308308
Schema schema = openAPI.getComponents().getSchemas().get("AdditionalPropertiesClass");
309309
Assertions.assertNull(schema.getAdditionalProperties());
@@ -382,9 +382,9 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
382382
public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPresentFalse() {
383383
OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/additional-properties-for-testing.yaml");
384384
DefaultCodegen codegen = new DefaultCodegen();
385-
codegen.setOpenAPI(openAPI);
386385
codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
387386
codegen.supportsAdditionalPropertiesWithComposedSchema = true;
387+
codegen.setOpenAPI(openAPI);
388388
/*
389389
When this DisallowAdditionalPropertiesIfNotPresent is false:
390390
for CodegenModel/CodegenParameter/CodegenProperty/CodegenResponse.getAdditionalProperties
@@ -402,7 +402,7 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
402402
Schema addProps = ModelUtils.getAdditionalProperties(schema);
403403
// The petstore-with-fake-endpoints-models-for-testing.yaml does not set the
404404
// 'additionalProperties' keyword for this model, hence assert the value to be null.
405-
Assertions.assertNull(addProps);
405+
Assertions.assertNotNull(addProps);
406406
CodegenModel cm = codegen.fromModel("AdditionalPropertiesClass", schema);
407407
Assertions.assertNotNull(cm.getAdditionalProperties());
408408
// When the 'additionalProperties' keyword is not present, the model

modules/openapi-generator/src/test/java/org/openapitools/codegen/java/JavaClientCodegenTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3165,7 +3165,8 @@ public void testRestClientWithXML_issue_19137() {
31653165
.setLibrary(JavaClientCodegen.RESTCLIENT)
31663166
.setAdditionalProperties(Map.of(
31673167
CodegenConstants.API_PACKAGE, "xyz.abcdef.api",
3168-
CodegenConstants.WITH_XML, true
3168+
CodegenConstants.WITH_XML, true,
3169+
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, true
31693170
))
31703171
.setInputSpec("src/test/resources/3_1/java/petstore.yaml")
31713172
.setOutputDir(output.toString().replace("\\", "/"));

0 commit comments

Comments
 (0)