Skip to content

Commit e350337

Browse files
committed
fix tests
1 parent 0612c0d commit e350337

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

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
@@ -3171,7 +3171,8 @@ public void testRestClientWithXML_issue_19137() {
31713171
.setLibrary(JavaClientCodegen.RESTCLIENT)
31723172
.setAdditionalProperties(Map.of(
31733173
CodegenConstants.API_PACKAGE, "xyz.abcdef.api",
3174-
CodegenConstants.WITH_XML, true
3174+
CodegenConstants.WITH_XML, true,
3175+
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, true
31753176
))
31763177
.setInputSpec("src/test/resources/3_1/java/petstore.yaml")
31773178
.setOutputDir(output.toString().replace("\\", "/"));

0 commit comments

Comments
 (0)