diff --git a/modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml b/modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
index ab59209425d3..fdc0d5272e05 100644
--- a/modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
+++ b/modules/openapi-generator-maven-plugin/examples/multi-module/pom.xml
@@ -19,7 +19,7 @@
0.2.1
2.7
1.0.0
- 5.10.2
+ 4.13.2
1.4
diff --git a/modules/openapi-generator-maven-plugin/pom.xml b/modules/openapi-generator-maven-plugin/pom.xml
index cf86efe11033..aebf82f8bf4b 100644
--- a/modules/openapi-generator-maven-plugin/pom.xml
+++ b/modules/openapi-generator-maven-plugin/pom.xml
@@ -59,8 +59,8 @@
${project.version}
- org.junit.jupiter
- junit-jupiter-api
+ junit
+ junit
${junit.version}
test
diff --git a/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java b/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java
index d39da0d8a622..328fb3b71e3a 100644
--- a/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java
+++ b/modules/openapi-generator-maven-plugin/src/test/java/org/openapitools/codegen/plugin/CodeGenMojoTest.java
@@ -16,7 +16,7 @@
package org.openapitools.codegen.plugin;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.Assert.assertThrows;
import java.io.File;
import java.nio.file.Files;
diff --git a/modules/openapi-generator-online/pom.xml b/modules/openapi-generator-online/pom.xml
index fdf1637d661c..65749ce506fd 100644
--- a/modules/openapi-generator-online/pom.xml
+++ b/modules/openapi-generator-online/pom.xml
@@ -127,8 +127,8 @@
- org.junit.jupiter
- junit-jupiter-api
+ junit
+ junit
${junit.version}
test
diff --git a/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java b/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java
index c29405b7cfa8..2ddae0b75894 100644
--- a/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java
+++ b/modules/openapi-generator-online/src/test/java/org/openapitools/codegen/online/api/GenApiControllerTest.java
@@ -1,14 +1,14 @@
package org.openapitools.codegen.online.api;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.openapitools.codegen.online.model.ResponseCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
+import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.hamcrest.Matchers.hasItem;
@@ -18,7 +18,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-@ExtendWith(SpringExtension.class)
+@RunWith(SpringRunner.class)
@WebMvcTest(GenApiController.class)
public class GenApiControllerTest {
diff --git a/modules/openapi-generator/pom.xml b/modules/openapi-generator/pom.xml
index 0c06298489fa..4202bc3434ab 100644
--- a/modules/openapi-generator/pom.xml
+++ b/modules/openapi-generator/pom.xml
@@ -327,16 +327,10 @@
com.tngtech.archunit
- archunit-junit5
+ archunit-junit4
${archunit.version}
test
-
- org.junit.jupiter
- junit-jupiter-api
- ${junit.version}
- test
-
org.testng
testng
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinWiremockServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinWiremockServerCodegen.java
index 2de5bda7e1fd..4ed88127122e 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinWiremockServerCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinWiremockServerCodegen.java
@@ -41,6 +41,8 @@ public String getHelp() {
public KotlinWiremockServerCodegen() {
super();
+ embeddedTemplateDir = templateDir = "kotlin-wiremock";
+
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
diff --git a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/beanValidation.mustache b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/beanValidation.mustache
index efd11d223ff5..a7f264654822 100644
--- a/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/beanValidation.mustache
+++ b/modules/openapi-generator/src/main/resources/JavaJaxRS/spec/beanValidation.mustache
@@ -1 +1 @@
-{{#required}}@NotNull {{/required}}{{#isContainer}}{{^items.isPrimitiveType}}{{^items.isDate}}{{^items.isDateTime}}{{^items.isString}}{{^items.isFile}}{{^items.isEnumOrRef}}@Valid {{/items.isEnumOrRef}}{{/items.isFile}}{{/items.isString}}{{/items.isDateTime}}{{/items.isDate}}{{/items.isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime}}{{^isString}}{{^isFile}}{{^isEnumOrRef}}@Valid {{/isEnumOrRef}}{{/isFile}}{{/isString}}{{/isDateTime}}{{/isDate}}{{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}}
\ No newline at end of file
+{{#required}}{{^isReadOnly}}@NotNull {{/isReadOnly}}{{/required}}{{#isContainer}}{{^items.isPrimitiveType}}{{^items.isDate}}{{^items.isDateTime}}{{^items.isString}}{{^items.isFile}}{{^items.isEnumOrRef}}@Valid {{/items.isEnumOrRef}}{{/items.isFile}}{{/items.isString}}{{/items.isDateTime}}{{/items.isDate}}{{/items.isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime}}{{^isString}}{{^isFile}}{{^isEnumOrRef}}@Valid {{/isEnumOrRef}}{{/isFile}}{{/isString}}{{/isDateTime}}{{/isDate}}{{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache b/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache
index adc71b7f0bd8..e4669fad0ea7 100644
--- a/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache
+++ b/modules/openapi-generator/src/main/resources/codegen/generatorClassTest.mustache
@@ -1,6 +1,6 @@
package {{generatorPackage}};
-import org.junit.jupiter.api.Test;
+import org.junit.Test;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.config.CodegenConfigurator;
@@ -33,4 +33,4 @@ public class {{generatorClass}}Test {
DefaultGenerator generator = new DefaultGenerator();
generator.opts(clientOptInput).generate();
}
-}
\ No newline at end of file
+}
diff --git a/modules/openapi-generator/src/main/resources/codegen/pom.mustache b/modules/openapi-generator/src/main/resources/codegen/pom.mustache
index 81a80f9df176..457219d200b7 100644
--- a/modules/openapi-generator/src/main/resources/codegen/pom.mustache
+++ b/modules/openapi-generator/src/main/resources/codegen/pom.mustache
@@ -41,6 +41,7 @@
-Xms512m -Xmx1500m
methods
+ pertest
@@ -113,8 +114,8 @@
provided
- org.junit.jupiter
- junit-jupiter-api
+ junit
+ junit
${junit-version}
test
@@ -123,6 +124,6 @@
UTF-8
{{openapiGeneratorVersion}}
1.0.0
- 5.10.2
+ 4.13.2
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/AllGeneratorsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/AllGeneratorsTest.java
index 28619f3156f4..7384eebca26e 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/AllGeneratorsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/AllGeneratorsTest.java
@@ -30,21 +30,25 @@ public class AllGeneratorsTest {
@Test
public void testEachWithPetstore() throws IOException {
for (final CodegenConfig codegenConfig : CodegenConfigLoader.getAll()) {
- File output = Files.createTempDirectory("test").toFile();
- output.deleteOnExit();
-
- final CodegenConfigurator configurator = new CodegenConfigurator()
- .setGeneratorName(codegenConfig.getName())
- .setInputSpec("src/test/resources/3_0/petstore.yaml")
- .setOutputDir(output.getAbsolutePath().replace("\\", "/"));
-
- final ClientOptInput clientOptInput = configurator.toClientOptInput();
- DefaultGenerator generator = new DefaultGenerator();
- List files = generator.opts(clientOptInput).generate();
-
- // Main intention of this test is to check that nothing crashes. Besides, we check here that
- // at least 1 file is generated, besides the common ".openapi-generator-ignore", "FILES" and "VERSION" files.
- Assert.assertTrue(files.size() >= 4);
+ try {
+ File output = Files.createTempDirectory("test").toFile();
+ output.deleteOnExit();
+
+ final CodegenConfigurator configurator = new CodegenConfigurator()
+ .setGeneratorName(codegenConfig.getName())
+ .setInputSpec("src/test/resources/3_0/petstore.yaml")
+ .setOutputDir(output.getAbsolutePath().replace("\\", "/"));
+
+ final ClientOptInput clientOptInput = configurator.toClientOptInput();
+ DefaultGenerator generator = new DefaultGenerator();
+ List files = generator.opts(clientOptInput).generate();
+
+ // Main intention of this test is to check that nothing crashes. Besides, we check here that
+ // at least 1 file is generated, besides the common ".openapi-generator-ignore", "FILES" and "VERSION" files.
+ Assert.assertTrue(files.size() >= 4);
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to run " + codegenConfig.getName() + " with petstore.yaml: " + e.getMessage());
+ }
}
}
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java
index a4ca489e6b84..1eb57d9014f6 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/ArchUnitRulesTest.java
@@ -4,7 +4,7 @@
import com.tngtech.archunit.core.domain.JavaModifier;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.lang.ArchRule;
-import org.junit.jupiter.api.Test;
+import org.junit.Test;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
import static com.tngtech.archunit.library.GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS;
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
index daaea9a26376..8560323b31f5 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/DefaultCodegenTest.java
@@ -49,8 +49,6 @@
import org.testng.Assert;
import org.testng.annotations.Ignore;
import org.testng.annotations.Test;
-import org.junit.jupiter.api.Assertions;
-
import java.io.File;
import java.io.IOException;
@@ -72,7 +70,7 @@ public void testDeeplyNestedAdditionalPropertiesImports() {
codegen.setOpenAPI(openApi);
PathItem path = openApi.getPaths().get("/ping");
CodegenOperation operation = codegen.fromOperation("/ping", "post", path.getPost(), path.getServers());
- Assertions.assertEquals(Sets.intersection(operation.imports, Sets.newHashSet("Person")).size(), 1);
+ assertEquals(Sets.intersection(operation.imports, Sets.newHashSet("Person")).size(), 1);
}
@Test
@@ -82,7 +80,7 @@ public void testOptionalResponseImports() {
codegen.setOpenAPI(openApi);
PathItem path = openApi.getPaths().get("/api/Users/{userId}");
CodegenOperation operation = codegen.fromOperation("/api/Users/{userId}", "get", path.getGet(), path.getServers());
- Assertions.assertTrue(operation.isResponseOptional);
+ assertTrue(operation.isResponseOptional);
}
@Test
@@ -92,7 +90,7 @@ public void testEnumImports() {
codegen.setOpenAPI(openApi);
PathItem path = openApi.getPaths().get("/pets/petType/{type}");
CodegenOperation operation = codegen.fromOperation("/pets/petType/{type}", "get", path.getGet(), path.getServers());
- Assertions.assertEquals(Sets.intersection(operation.imports, Sets.newHashSet("PetByType")).size(), 1);
+ assertEquals(Sets.intersection(operation.imports, Sets.newHashSet("PetByType")).size(), 1);
}
@Test
@@ -116,8 +114,8 @@ public void testHasBodyParameter() {
final DefaultCodegen codegen = new DefaultCodegen();
codegen.setOpenAPI(openAPI);
- Assertions.assertFalse(codegen.hasBodyParameter(pingOperation));
- Assertions.assertTrue(codegen.hasBodyParameter(createOperation));
+ assertFalse(codegen.hasBodyParameter(pingOperation));
+ assertTrue(codegen.hasBodyParameter(createOperation));
}
@Test(expectedExceptions = RuntimeException.class)
@@ -151,35 +149,35 @@ public void testGetConsumesInfoAndGetProducesInfo() {
new ApiResponses().addApiResponse("201", new ApiResponse()
.description("Created response")));
Set createConsumesInfo = DefaultCodegen.getConsumesInfo(openAPI, createOperation);
- Assertions.assertEquals(createConsumesInfo.size(), 2);
- Assertions.assertTrue(createConsumesInfo.contains("application/json"), "contains 'application/json'");
- Assertions.assertTrue(createConsumesInfo.contains("application/xml"), "contains 'application/xml'");
+ assertEquals(createConsumesInfo.size(), 2);
+ assertTrue(createConsumesInfo.contains("application/json"), "contains 'application/json'");
+ assertTrue(createConsumesInfo.contains("application/xml"), "contains 'application/xml'");
Set createProducesInfo = DefaultCodegen.getProducesInfo(openAPI, createOperation);
- Assertions.assertEquals(createProducesInfo.size(), 0);
+ assertEquals(createProducesInfo.size(), 0);
final DefaultCodegen codegen = new DefaultCodegen();
codegen.setOpenAPI(openAPI);
CodegenOperation coCreate = codegen.fromOperation("somepath", "post", createOperation, null);
- Assertions.assertTrue(coCreate.hasConsumes);
- Assertions.assertEquals(coCreate.consumes.size(), 2);
- Assertions.assertFalse(coCreate.hasProduces);
+ assertTrue(coCreate.hasConsumes);
+ assertEquals(coCreate.consumes.size(), 2);
+ assertFalse(coCreate.hasProduces);
Operation updateOperationWithRef = new Operation()
.requestBody(new RequestBody().$ref("#/components/requestBodies/MyRequestBody"))
.responses(new ApiResponses().addApiResponse("201", new ApiResponse().$ref("#/components/responses/MyResponse")));
Set updateConsumesInfo = DefaultCodegen.getConsumesInfo(openAPI, updateOperationWithRef);
- Assertions.assertEquals(updateConsumesInfo.size(), 1);
- Assertions.assertTrue(updateConsumesInfo.contains("application/json"), "contains 'application/json'");
+ assertEquals(updateConsumesInfo.size(), 1);
+ assertTrue(updateConsumesInfo.contains("application/json"), "contains 'application/json'");
Set updateProducesInfo = DefaultCodegen.getProducesInfo(openAPI, updateOperationWithRef);
- Assertions.assertEquals(updateProducesInfo.size(), 1);
- Assertions.assertTrue(updateProducesInfo.contains("application/xml"), "contains 'application/xml'");
+ assertEquals(updateProducesInfo.size(), 1);
+ assertTrue(updateProducesInfo.contains("application/xml"), "contains 'application/xml'");
CodegenOperation coUpdate = codegen.fromOperation("somepath", "post", updateOperationWithRef, null);
- Assertions.assertTrue(coUpdate.hasConsumes);
- Assertions.assertEquals(coUpdate.consumes.size(), 1);
- Assertions.assertEquals(coUpdate.consumes.get(0).get("mediaType"), "application/json");
- Assertions.assertTrue(coUpdate.hasProduces);
- Assertions.assertEquals(coUpdate.produces.size(), 1);
- Assertions.assertEquals(coUpdate.produces.get(0).get("mediaType"), "application/xml");
+ assertTrue(coUpdate.hasConsumes);
+ assertEquals(coUpdate.consumes.size(), 1);
+ assertEquals(coUpdate.consumes.get(0).get("mediaType"), "application/json");
+ assertTrue(coUpdate.hasProduces);
+ assertEquals(coUpdate.produces.size(), 1);
+ assertEquals(coUpdate.produces.get(0).get("mediaType"), "application/xml");
}
@Test
@@ -190,22 +188,22 @@ public void testGetProducesInfo() {
Operation textOperation = openAPI.getPaths().get("/ping/text").getGet();
CodegenOperation coText = codegen.fromOperation("/ping/text", "get", textOperation, null);
- Assertions.assertTrue(coText.hasProduces);
- Assertions.assertEquals(coText.produces.size(), 1);
- Assertions.assertEquals(coText.produces.get(0).get("mediaType"), "text/plain");
+ assertTrue(coText.hasProduces);
+ assertEquals(coText.produces.size(), 1);
+ assertEquals(coText.produces.get(0).get("mediaType"), "text/plain");
Operation jsonOperation = openAPI.getPaths().get("/ping/json").getGet();
CodegenOperation coJson = codegen.fromOperation("/ping/json", "get", jsonOperation, null);
- Assertions.assertTrue(coJson.hasProduces);
- Assertions.assertEquals(coJson.produces.size(), 1);
- Assertions.assertEquals(coJson.produces.get(0).get("mediaType"), "application/json");
+ assertTrue(coJson.hasProduces);
+ assertEquals(coJson.produces.size(), 1);
+ assertEquals(coJson.produces.get(0).get("mediaType"), "application/json");
Operation issue443Operation = openAPI.getPaths().get("/other/issue443").getGet();
CodegenOperation coIssue443 = codegen.fromOperation("/other/issue443", "get", issue443Operation, null);
- Assertions.assertTrue(coIssue443.hasProduces);
- Assertions.assertEquals(coIssue443.produces.size(), 2);
- Assertions.assertEquals(coIssue443.produces.get(0).get("mediaType"), "application/json");
- Assertions.assertEquals(coIssue443.produces.get(1).get("mediaType"), "application/text");
+ assertTrue(coIssue443.hasProduces);
+ assertEquals(coIssue443.produces.size(), 2);
+ assertEquals(coIssue443.produces.get(0).get("mediaType"), "application/json");
+ assertEquals(coIssue443.produces.get(1).get("mediaType"), "application/text");
}
@Test
@@ -213,8 +211,8 @@ public void testInitialConfigValues() throws Exception {
final DefaultCodegen codegen = new DefaultCodegen();
codegen.processOpts();
- Assertions.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
- Assertions.assertTrue(codegen.isHideGenerationTimestamp());
+ assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.TRUE);
+ assertTrue(codegen.isHideGenerationTimestamp());
}
@Test
@@ -223,8 +221,8 @@ public void testSettersForConfigValues() throws Exception {
codegen.setHideGenerationTimestamp(false);
codegen.processOpts();
- Assertions.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
- Assertions.assertFalse(codegen.isHideGenerationTimestamp());
+ assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
+ assertFalse(codegen.isHideGenerationTimestamp());
}
@Test
@@ -233,8 +231,8 @@ public void testAdditionalPropertiesPutForConfigValues() throws Exception {
codegen.additionalProperties().put(CodegenConstants.HIDE_GENERATION_TIMESTAMP, false);
codegen.processOpts();
- Assertions.assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
- Assertions.assertFalse(codegen.isHideGenerationTimestamp());
+ assertEquals(codegen.additionalProperties().get(CodegenConstants.HIDE_GENERATION_TIMESTAMP), Boolean.FALSE);
+ assertFalse(codegen.isHideGenerationTimestamp());
}
@Test
@@ -249,7 +247,7 @@ public void testArraySchemaIsNotIncludedInAliases() {
Map aliases = codegen.getAllAliases(schemas);
- Assertions.assertEquals(aliases.size(), 0);
+ assertEquals(aliases.size(), 0);
}
@Test
@@ -262,8 +260,8 @@ public void testFormParameterHasDefaultValue() {
ModelUtils.getSchemaFromRequestBody(openAPI.getPaths().get("/fake").getGet().getRequestBody()));
CodegenParameter codegenParameter = codegen.fromFormProperty("enum_form_string", (Schema) requestBodySchema.getProperties().get("enum_form_string"), new HashSet());
- Assertions.assertEquals(codegenParameter.defaultValue, "-efg");
- Assertions.assertNull(codegenParameter.getSchema());
+ assertEquals(codegenParameter.defaultValue, "-efg");
+ assertNull(codegenParameter.getSchema());
}
@Test
@@ -278,8 +276,8 @@ public void testDateTimeFormParameterHasDefaultValue() {
CodegenParameter codegenParameter = codegen.fromFormProperty("visitDate", (Schema) requestBodySchema.getProperties().get("visitDate"),
new HashSet<>());
- Assertions.assertEquals(codegenParameter.defaultValue, "1971-12-19T03:39:57-08:00");
- Assertions.assertNull(codegenParameter.getSchema());
+ assertEquals(codegenParameter.defaultValue, "1971-12-19T03:39:57-08:00");
+ assertNull(codegenParameter.getSchema());
}
@Test
@@ -288,13 +286,13 @@ public void testOriginalOpenApiDocumentVersion() {
String location = "src/test/resources/2_0/python-prior/petstore-with-fake-endpoints-models-for-testing.yaml";
OpenAPI openAPI = TestUtils.parseFlattenSpec(location);
SemVer version = ModelUtils.getOpenApiVersion(openAPI, location, null);
- Assertions.assertEquals(version, new SemVer("2.0.0"));
+ assertEquals(version, new SemVer("2.0.0"));
// Test with OAS 3.0 document.
location = "src/test/resources/3_0/python/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml";
openAPI = TestUtils.parseFlattenSpec(location);
version = ModelUtils.getOpenApiVersion(openAPI, location, null);
- Assertions.assertEquals(version, new SemVer("3.0.0"));
+ assertEquals(version, new SemVer("3.0.0"));
}
@Test
@@ -306,14 +304,14 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
codegen.setDisallowAdditionalPropertiesIfNotPresent(true);
Schema schema = openAPI.getComponents().getSchemas().get("AdditionalPropertiesClass");
- Assertions.assertNull(schema.getAdditionalProperties());
+ assertNull(schema.getAdditionalProperties());
Schema addProps = ModelUtils.getAdditionalProperties(schema);
// The petstore-with-fake-endpoints-models-for-testing.yaml does not set the
// 'additionalProperties' keyword for this model, hence assert the value to be null.
- Assertions.assertNull(addProps);
+ assertNull(addProps);
CodegenModel cm = codegen.fromModel("AdditionalPropertiesClass", schema);
- Assertions.assertNull(cm.getAdditionalProperties());
+ assertNull(cm.getAdditionalProperties());
// When the 'additionalProperties' keyword is not present, the model
// should allow undeclared properties. However, due to bug
// https://github.com/swagger-api/swagger-parser/issues/1369, the swagger
@@ -341,41 +339,41 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
// This property has the following inline schema.
// additionalProperties:
// type: string
- Assertions.assertNotNull(map_string_sc);
- Assertions.assertNotNull(map_string_sc.getAdditionalProperties());
- Assertions.assertNotNull(map_string_cp.getAdditionalProperties());
+ assertNotNull(map_string_sc);
+ assertNotNull(map_string_sc.getAdditionalProperties());
+ assertNotNull(map_string_cp.getAdditionalProperties());
// map_with_additional_properties
// This property has the following inline schema.
// additionalProperties: true
- Assertions.assertNotNull(map_with_additional_properties_sc);
+ assertNotNull(map_with_additional_properties_sc);
// It is unfortunate that child.getAdditionalProperties() returns null for a V2 schema.
// We cannot differentiate between 'additionalProperties' not present and
// additionalProperties: true.
// UPDATE fixed in swagger parser 2.1.14
- Assertions.assertTrue((Boolean) map_with_additional_properties_sc.getAdditionalProperties());
+ assertTrue((Boolean) map_with_additional_properties_sc.getAdditionalProperties());
addProps = ModelUtils.getAdditionalProperties(map_with_additional_properties_sc);
- Assertions.assertEquals(addProps, new Schema());
- Assertions.assertNotNull(map_with_additional_properties_cp.getAdditionalProperties());
+ assertEquals(addProps, new Schema());
+ assertNotNull(map_with_additional_properties_cp.getAdditionalProperties());
// map_without_additional_properties
// This property has the following inline schema.
// additionalProperties: false
- Assertions.assertNotNull(map_without_additional_properties_sc);
+ assertNotNull(map_without_additional_properties_sc);
// It is unfortunate that child.getAdditionalProperties() returns null for a V2 schema.
// We cannot differentiate between 'additionalProperties' not present and
// additionalProperties: false.
// UPDATE fixed in swagger parser 2.1.14
- Assertions.assertFalse((Boolean) map_without_additional_properties_sc.getAdditionalProperties());
+ assertFalse((Boolean) map_without_additional_properties_sc.getAdditionalProperties());
addProps = ModelUtils.getAdditionalProperties(map_without_additional_properties_sc);
- Assertions.assertNull(addProps);
- Assertions.assertNull(map_without_additional_properties_cp.getAdditionalProperties());
+ assertNull(addProps);
+ assertNull(map_without_additional_properties_cp.getAdditionalProperties());
// check of composed schema model
String schemaName = "Parent";
schema = openAPI.getComponents().getSchemas().get(schemaName);
cm = codegen.fromModel(schemaName, schema);
- Assertions.assertNull(cm.getAdditionalProperties());
+ assertNull(cm.getAdditionalProperties());
}
@Test
@@ -397,14 +395,14 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
*/
Schema schema = openAPI.getComponents().getSchemas().get("AdditionalPropertiesClass");
- Assertions.assertNull(schema.getAdditionalProperties());
+ assertNull(schema.getAdditionalProperties());
Schema addProps = ModelUtils.getAdditionalProperties(schema);
// The petstore-with-fake-endpoints-models-for-testing.yaml does not set the
// 'additionalProperties' keyword for this model, hence assert the value to be null.
- Assertions.assertNull(addProps);
+ assertNull(addProps);
CodegenModel cm = codegen.fromModel("AdditionalPropertiesClass", schema);
- Assertions.assertNotNull(cm.getAdditionalProperties());
+ assertNotNull(cm.getAdditionalProperties());
// When the 'additionalProperties' keyword is not present, the model
// should allow undeclared properties. However, due to bug
// https://github.com/swagger-api/swagger-parser/issues/1369, the swagger
@@ -432,41 +430,41 @@ public void testAdditionalPropertiesV2SpecDisallowAdditionalPropertiesIfNotPrese
// This property has the following inline schema.
// additionalProperties:
// type: string
- Assertions.assertNotNull(map_string_sc);
- Assertions.assertNotNull(map_string_sc.getAdditionalProperties());
- Assertions.assertNotNull(map_string_cp.getAdditionalProperties());
+ assertNotNull(map_string_sc);
+ assertNotNull(map_string_sc.getAdditionalProperties());
+ assertNotNull(map_string_cp.getAdditionalProperties());
// map_with_additional_properties
// This property has the following inline schema.
// additionalProperties: true
- Assertions.assertNotNull(map_with_additional_properties_sc);
+ assertNotNull(map_with_additional_properties_sc);
// It is unfortunate that child.getAdditionalProperties() returns null for a V2 schema.
// We cannot differentiate between 'additionalProperties' not present and
// additionalProperties: true.
// UPDATE fixed in swagger parser 2.1.14
- Assertions.assertTrue((Boolean) map_with_additional_properties_sc.getAdditionalProperties());
+ assertTrue((Boolean) map_with_additional_properties_sc.getAdditionalProperties());
addProps = ModelUtils.getAdditionalProperties(map_with_additional_properties_sc);
- Assertions.assertEquals(addProps, new Schema());
- Assertions.assertNotNull(map_with_additional_properties_cp.getAdditionalProperties());
+ assertEquals(addProps, new Schema());
+ assertNotNull(map_with_additional_properties_cp.getAdditionalProperties());
// map_without_additional_properties
// This property has the following inline schema.
// additionalProperties: false
- Assertions.assertNotNull(map_without_additional_properties_sc);
+ assertNotNull(map_without_additional_properties_sc);
// It is unfortunate that child.getAdditionalProperties() returns null for a V2 schema.
// We cannot differentiate between 'additionalProperties' not present and
// additionalProperties: false.
// UPDATE fixed in swagger parser 2.1.14
- Assertions.assertFalse((Boolean) map_without_additional_properties_sc.getAdditionalProperties());
+ assertFalse((Boolean) map_without_additional_properties_sc.getAdditionalProperties());
addProps = ModelUtils.getAdditionalProperties(map_without_additional_properties_sc);
- Assertions.assertEquals(addProps, null);
- Assertions.assertNull(map_without_additional_properties_cp.getAdditionalProperties());
+ assertEquals(addProps, null);
+ assertNull(map_without_additional_properties_cp.getAdditionalProperties());
// check of composed schema model
String schemaName = "Parent";
schema = openAPI.getComponents().getSchemas().get(schemaName);
cm = codegen.fromModel(schemaName, schema);
- Assertions.assertNotNull(cm.getAdditionalProperties());
+ assertNotNull(cm.getAdditionalProperties());
}
@Test
@@ -478,15 +476,15 @@ public void testAdditionalPropertiesV3SpecDisallowAdditionalPropertiesIfNotPrese
codegen.setOpenAPI(openAPI);
Schema componentSchema = openAPI.getComponents().getSchemas().get("AdditionalPropertiesClass");
- Assertions.assertNull(componentSchema.getAdditionalProperties());
+ assertNull(componentSchema.getAdditionalProperties());
// When the 'additionalProperties' keyword is not present, the schema may be
// extended with any undeclared properties.
Schema addProps = ModelUtils.getAdditionalProperties(componentSchema);
- Assertions.assertNotNull(addProps);
- Assertions.assertEquals(addProps, new Schema());
+ assertNotNull(addProps);
+ assertEquals(addProps, new Schema());
CodegenModel cm = codegen.fromModel("AdditionalPropertiesClass", componentSchema);
- Assertions.assertNotNull(cm.getAdditionalProperties());
+ assertNotNull(cm.getAdditionalProperties());
Map modelPropSchemas = componentSchema.getProperties();
Schema map_with_undeclared_properties_string_sc = modelPropSchemas.get("map_with_undeclared_properties_string");
@@ -518,60 +516,60 @@ public void testAdditionalPropertiesV3SpecDisallowAdditionalPropertiesIfNotPrese
// This property has the following inline schema.
// additionalProperties:
// type: string
- Assertions.assertNotNull(map_with_undeclared_properties_string_sc);
- Assertions.assertNotNull(map_with_undeclared_properties_string_sc.getAdditionalProperties());
- Assertions.assertNotNull(map_with_undeclared_properties_string_cp.getAdditionalProperties());
+ assertNotNull(map_with_undeclared_properties_string_sc);
+ assertNotNull(map_with_undeclared_properties_string_sc.getAdditionalProperties());
+ assertNotNull(map_with_undeclared_properties_string_cp.getAdditionalProperties());
// map_with_undeclared_properties_anytype_1
// This property does not use the additionalProperties keyword,
// which means by default undeclared properties are allowed.
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_1_sc);
- Assertions.assertNull(map_with_undeclared_properties_anytype_1_sc.getAdditionalProperties());
+ assertNotNull(map_with_undeclared_properties_anytype_1_sc);
+ assertNull(map_with_undeclared_properties_anytype_1_sc.getAdditionalProperties());
addProps = ModelUtils.getAdditionalProperties(map_with_undeclared_properties_anytype_1_sc);
- Assertions.assertNotNull(addProps);
- Assertions.assertEquals(addProps, new Schema());
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_1_cp.getAdditionalProperties());
+ assertNotNull(addProps);
+ assertEquals(addProps, new Schema());
+ assertNotNull(map_with_undeclared_properties_anytype_1_cp.getAdditionalProperties());
// map_with_undeclared_properties_anytype_2
// This property does not use the additionalProperties keyword,
// which means by default undeclared properties are allowed.
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_2_sc);
- Assertions.assertNull(map_with_undeclared_properties_anytype_2_sc.getAdditionalProperties());
+ assertNotNull(map_with_undeclared_properties_anytype_2_sc);
+ assertNull(map_with_undeclared_properties_anytype_2_sc.getAdditionalProperties());
addProps = ModelUtils.getAdditionalProperties(map_with_undeclared_properties_anytype_2_sc);
- Assertions.assertNotNull(addProps);
- Assertions.assertEquals(addProps, new Schema());
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_2_cp.getAdditionalProperties());
+ assertNotNull(addProps);
+ assertEquals(addProps, new Schema());
+ assertNotNull(map_with_undeclared_properties_anytype_2_cp.getAdditionalProperties());
// map_with_undeclared_properties_anytype_3
// This property has the following inline schema.
// additionalProperties: true
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_3_sc);
+ assertNotNull(map_with_undeclared_properties_anytype_3_sc);
// Unlike the V2 spec, in V3 we CAN differentiate between 'additionalProperties' not present and
// additionalProperties: true.
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_3_sc.getAdditionalProperties());
- Assertions.assertEquals(map_with_undeclared_properties_anytype_3_sc.getAdditionalProperties(), Boolean.TRUE);
+ assertNotNull(map_with_undeclared_properties_anytype_3_sc.getAdditionalProperties());
+ assertEquals(map_with_undeclared_properties_anytype_3_sc.getAdditionalProperties(), Boolean.TRUE);
addProps = ModelUtils.getAdditionalProperties(map_with_undeclared_properties_anytype_3_sc);
- Assertions.assertNotNull(addProps);
- Assertions.assertEquals(addProps, new Schema());
- Assertions.assertNotNull(map_with_undeclared_properties_anytype_3_cp.getAdditionalProperties());
+ assertNotNull(addProps);
+ assertEquals(addProps, new Schema());
+ assertNotNull(map_with_undeclared_properties_anytype_3_cp.getAdditionalProperties());
// empty_map
// This property has the following inline schema.
// additionalProperties: false
- Assertions.assertNotNull(empty_map_sc);
+ assertNotNull(empty_map_sc);
// Unlike the V2 spec, in V3 we CAN differentiate between 'additionalProperties' not present and
// additionalProperties: false.
- Assertions.assertNotNull(empty_map_sc.getAdditionalProperties());
- Assertions.assertEquals(empty_map_sc.getAdditionalProperties(), Boolean.FALSE);
+ assertNotNull(empty_map_sc.getAdditionalProperties());
+ assertEquals(empty_map_sc.getAdditionalProperties(), Boolean.FALSE);
addProps = ModelUtils.getAdditionalProperties(empty_map_sc);
- Assertions.assertNull(addProps);
- Assertions.assertNull(empty_map_cp.getAdditionalProperties());
+ assertNull(addProps);
+ assertNull(empty_map_cp.getAdditionalProperties());
// check of composed schema model
String schemaName = "SomeObject";
Schema schema = openAPI.getComponents().getSchemas().get(schemaName);
cm = codegen.fromModel(schemaName, schema);
- Assertions.assertNotNull(cm.getAdditionalProperties());
+ assertNotNull(cm.getAdditionalProperties());
}
@Test
@@ -586,10 +584,10 @@ public void testAdditionalPropertiesV3SpecDisallowAdditionalPropertiesIfNotPrese
codegen.setOpenAPI(openAPI);
Schema schema = openAPI.getComponents().getSchemas().get("AdditionalPropertiesClass");
- Assertions.assertNull(schema.getAdditionalProperties());
+ assertNull(schema.getAdditionalProperties());
Schema addProps = ModelUtils.getAdditionalProperties(schema);
- Assertions.assertNull(addProps);
+ assertNull(addProps);
}
@Test
@@ -601,8 +599,8 @@ public void testEnsureNoDuplicateProduces() {
Operation operation = openAPI.getPaths().get("/test").getGet();
CodegenOperation co = codegen.fromOperation("/test", "get", operation, null);
- Assertions.assertEquals(co.produces.size(), 1);
- Assertions.assertEquals(co.produces.get(0).get("mediaType"), "application/json");
+ assertEquals(co.produces.size(), 1);
+ assertEquals(co.produces.get(0).get("mediaType"), "application/json");
}
@Test
@@ -617,14 +615,14 @@ public void testConsistentParameterNameAfterUniquenessRename() throws Exception
DefaultCodegen codegen = new DefaultCodegen();
codegen.setOpenAPI(openAPI);
CodegenOperation co = codegen.fromOperation("/some/path", "get", operation, null);
- Assertions.assertEquals(co.path, "/some/path");
- Assertions.assertEquals(co.allParams.size(), 2);
+ assertEquals(co.path, "/some/path");
+ assertEquals(co.allParams.size(), 2);
List allParamsNames = co.allParams.stream().map(p -> p.paramName).collect(Collectors.toList());
- Assertions.assertTrue(allParamsNames.contains("myparam"));
- Assertions.assertTrue(allParamsNames.contains("myparam2"));
+ assertTrue(allParamsNames.contains("myparam"));
+ assertTrue(allParamsNames.contains("myparam2"));
List queryParamsNames = co.queryParams.stream().map(p -> p.paramName).collect(Collectors.toList());
- Assertions.assertTrue(queryParamsNames.contains("myparam"));
- Assertions.assertTrue(queryParamsNames.contains("myparam2"));
+ assertTrue(queryParamsNames.contains("myparam"));
+ assertTrue(queryParamsNames.contains("myparam2"));
}
@Test
@@ -634,11 +632,11 @@ public void testUniquenessRenameOfFormParameters() throws Exception {
codegen.setOpenAPI(openAPI);
Operation operation = openAPI.getPaths().get("/form-param-poc/{id}").getPut();
CodegenOperation co = codegen.fromOperation("/form-param-poc/{id}", "put", operation, null);
- Assertions.assertEquals(co.path, "/form-param-poc/{id}");
- Assertions.assertEquals(co.allParams.size(), 2);
+ assertEquals(co.path, "/form-param-poc/{id}");
+ assertEquals(co.allParams.size(), 2);
List allParamsNames = co.allParams.stream().map(p -> p.paramName).collect(Collectors.toList());
- Assertions.assertTrue(allParamsNames.contains("id"));
- Assertions.assertTrue(allParamsNames.contains("id2"));
+ assertTrue(allParamsNames.contains("id"));
+ assertTrue(allParamsNames.contains("id2"));
}
@Test
@@ -651,8 +649,8 @@ public void testGetSchemaTypeWithComposedSchemaWithOneOf() {
ModelUtils.getSchemaFromRequestBody(operation.getRequestBody()));
String type = codegen.getSchemaType(schema);
- Assertions.assertNotNull(type);
- Assertions.assertEquals(type, "oneOf");
+ assertNotNull(type);
+ assertEquals(type, "oneOf");
}
@Test
@@ -668,7 +666,7 @@ public void testOneOfEnum() {
Set oneOf = new TreeSet();
oneOf.add("Dog");
oneOf.add("Cat");
- Assertions.assertEquals(petItems.oneOf, oneOf);
+ assertEquals(petItems.oneOf, oneOf);
// make sure that animal has the property type
boolean typeSeen = false;
boolean typeContainsEnums = false;
@@ -681,14 +679,14 @@ public void testOneOfEnum() {
break;
}
}
- Assertions.assertTrue(typeSeen);
- Assertions.assertTrue(typeContainsEnums);
+ assertTrue(typeSeen);
+ assertTrue(typeContainsEnums);
- Assertions.assertEquals(
+ assertEquals(
((StringSchema) openAPI.getComponents().getSchemas().get("Dog").getProperties().get("type")).getEnum().size(),
1
);
- Assertions.assertEquals(
+ assertEquals(
((StringSchema) openAPI.getComponents().getSchemas().get("Cat").getProperties().get("type")).getEnum().size(),
1
);
@@ -707,7 +705,7 @@ public void testOneOfMergeProperties() {
Set oneOf = new TreeSet();
oneOf.add("Dog");
oneOf.add("Cat");
- Assertions.assertEquals(pet.oneOf, oneOf);
+ assertEquals(pet.oneOf, oneOf);
// make sure that animal has the property type
boolean typeSeen = false;
for (CodegenProperty cp : pet.vars) {
@@ -716,7 +714,7 @@ public void testOneOfMergeProperties() {
break;
}
}
- Assertions.assertTrue(typeSeen);
+ assertTrue(typeSeen);
}
@Test
@@ -731,9 +729,9 @@ public void testComposedSchemaOneOfWithProperties() {
Set oneOf = new TreeSet();
oneOf.add("Apple");
oneOf.add("Banana");
- Assertions.assertEquals(fruit.oneOf, oneOf);
- Assertions.assertEquals(fruit.optionalVars.size(), 3);
- Assertions.assertEquals(fruit.vars.size(), 3);
+ assertEquals(fruit.oneOf, oneOf);
+ assertEquals(fruit.optionalVars.size(), 3);
+ assertEquals(fruit.vars.size(), 3);
// make sure that fruit has the property color
boolean colorSeen = false;
for (CodegenProperty cp : fruit.vars) {
@@ -742,7 +740,7 @@ public void testComposedSchemaOneOfWithProperties() {
break;
}
}
- Assertions.assertTrue(colorSeen);
+ assertTrue(colorSeen);
colorSeen = false;
for (CodegenProperty cp : fruit.optionalVars) {
if ("color".equals(cp.name)) {
@@ -750,19 +748,19 @@ public void testComposedSchemaOneOfWithProperties() {
break;
}
}
- Assertions.assertTrue(colorSeen);
+ assertTrue(colorSeen);
}
@Test
public void testEscapeText() {
final DefaultCodegen codegen = new DefaultCodegen();
- Assertions.assertEquals(codegen.escapeText("\n"), " ");
- Assertions.assertEquals(codegen.escapeText("\r"), " ");
- Assertions.assertEquals(codegen.escapeText("\t"), " ");
- Assertions.assertEquals(codegen.escapeText("\\"), "\\\\");
- Assertions.assertEquals(codegen.escapeText("\""), "\\\"");
- Assertions.assertEquals(codegen.escapeText("\\/"), "/");
+ assertEquals(codegen.escapeText("\n"), " ");
+ assertEquals(codegen.escapeText("\r"), " ");
+ assertEquals(codegen.escapeText("\t"), " ");
+ assertEquals(codegen.escapeText("\\"), "\\\\");
+ assertEquals(codegen.escapeText("\""), "\\\"");
+ assertEquals(codegen.escapeText("\\/"), "/");
}
@Test
@@ -770,14 +768,14 @@ public void testEscapeTextWhileAllowingNewLines() {
final DefaultCodegen codegen = new DefaultCodegen();
// allow new lines
- Assertions.assertEquals(codegen.escapeTextWhileAllowingNewLines("\n"), "\n");
- Assertions.assertEquals(codegen.escapeTextWhileAllowingNewLines("\r"), "\r");
+ assertEquals(codegen.escapeTextWhileAllowingNewLines("\n"), "\n");
+ assertEquals(codegen.escapeTextWhileAllowingNewLines("\r"), "\r");
// escape other special characters
- Assertions.assertEquals(codegen.escapeTextWhileAllowingNewLines("\t"), " ");
- Assertions.assertEquals(codegen.escapeTextWhileAllowingNewLines("\\"), "\\\\");
- Assertions.assertEquals(codegen.escapeTextWhileAllowingNewLines("\""), "\\\"");
- Assertions.assertEquals(codegen.escapeTextWhileAllowingNewLines("\\/"), "/");
+ assertEquals(codegen.escapeTextWhileAllowingNewLines("\t"), " ");
+ assertEquals(codegen.escapeTextWhileAllowingNewLines("\\"), "\\\\");
+ assertEquals(codegen.escapeTextWhileAllowingNewLines("\""), "\\\"");
+ assertEquals(codegen.escapeTextWhileAllowingNewLines("\\/"), "/");
}
@Test
@@ -788,12 +786,12 @@ public void updateCodegenPropertyEnum() {
codegen.updateCodegenPropertyEnum(array);
List