Skip to content

Commit ea4a9f7

Browse files
committed
fix tests
1 parent 4256f49 commit ea4a9f7

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
@@ -3275,7 +3275,8 @@ public void testRestClientWithXML_issue_19137() {
32753275
.setLibrary(JavaClientCodegen.RESTCLIENT)
32763276
.setAdditionalProperties(Map.of(
32773277
CodegenConstants.API_PACKAGE, "xyz.abcdef.api",
3278-
CodegenConstants.WITH_XML, true
3278+
CodegenConstants.WITH_XML, true,
3279+
CodegenConstants.DISALLOW_ADDITIONAL_PROPERTIES_IF_NOT_PRESENT, true
32793280
))
32803281
.setInputSpec("src/test/resources/3_1/java/petstore.yaml")
32813282
.setOutputDir(output.toString().replace("\\", "/"));

0 commit comments

Comments
 (0)