Skip to content

Commit f2a8eef

Browse files
committed
fix tests
1 parent bd705ec commit f2a8eef

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
@@ -305,8 +305,8 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
305305
// this is the legacy config that most of our tooling uses
306306
OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/additional-properties-for-testing.yaml");
307307
DefaultCodegen codegen = new DefaultCodegen();
308-
codegen.setOpenAPI(openAPI);
309308
codegen.setDisallowAdditionalPropertiesIfNotPresent(true);
309+
codegen.setOpenAPI(openAPI);
310310

311311
Schema schema = openAPI.getComponents().getSchemas().get("AdditionalPropertiesClass");
312312
Assertions.assertNull(schema.getAdditionalProperties());
@@ -385,9 +385,9 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
385385
public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPresentFalse() {
386386
OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/2_0/additional-properties-for-testing.yaml");
387387
DefaultCodegen codegen = new DefaultCodegen();
388-
codegen.setOpenAPI(openAPI);
389388
codegen.setDisallowAdditionalPropertiesIfNotPresent(false);
390389
codegen.supportsAdditionalPropertiesWithComposedSchema = true;
390+
codegen.setOpenAPI(openAPI);
391391
/*
392392
When this DisallowAdditionalPropertiesIfNotPresent is false:
393393
for CodegenModel/CodegenParameter/CodegenProperty/CodegenResponse.getAdditionalProperties
@@ -405,7 +405,7 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
405405
Schema addProps = ModelUtils.getAdditionalProperties(schema);
406406
// The petstore-with-fake-endpoints-models-for-testing.yaml does not set the
407407
// 'additionalProperties' keyword for this model, hence assert the value to be null.
408-
Assertions.assertNull(addProps);
408+
Assertions.assertNotNull(addProps);
409409
CodegenModel cm = codegen.fromModel("AdditionalPropertiesClass", schema);
410410
Assertions.assertNotNull(cm.getAdditionalProperties());
411411
// 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
@@ -3180,7 +3180,8 @@ public void testRestClientWithXML_issue_19137() {
31803180
.setLibrary(JavaClientCodegen.RESTCLIENT)
31813181
.setAdditionalProperties(Map.of(
31823182
CodegenConstants.API_PACKAGE, "xyz.abcdef.api",
3183-
CodegenConstants.WITH_XML, true
3183+
CodegenConstants.WITH_XML, true,
3184+
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, true
31843185
))
31853186
.setInputSpec("src/test/resources/3_1/java/petstore.yaml")
31863187
.setOutputDir(output.toString().replace("\\", "/"));

0 commit comments

Comments
 (0)