mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
Update CodegenTest to apply InlineModelResolver to swagger
This commit is contained in:
parent
d250ce3bec
commit
4531bc41eb
@ -14,7 +14,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "read a file upload param from a 2.0 spec")
|
||||
public void fileUploadParamTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/petstore.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/pet/{petId}/uploadImage";
|
||||
final Operation p = model.getPaths().get(path).getPost();
|
||||
@ -39,7 +39,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "read formParam values from a 2.0 spec")
|
||||
public void formParamTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/petstore.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/petstore.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/pet/{petId}";
|
||||
final Operation p = model.getPaths().get(path).getPost();
|
||||
@ -83,7 +83,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "handle required parameters from a 2.0 spec as required when figuring out Swagger types")
|
||||
public void requiredParametersTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/requiredTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/requiredTest.json");
|
||||
|
||||
final DefaultCodegen codegen = new DefaultCodegen() {
|
||||
public String getSwaggerType(Property p) {
|
||||
@ -106,7 +106,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "select main response from a 2.0 spec using the lowest 2XX code")
|
||||
public void responseSelectionTest1() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/withTwoHundredAndDefault";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -117,7 +117,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "select main response from a 2.0 spec using the default keyword when no 2XX code")
|
||||
public void responseSelectionTest2() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/responseSelectionTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/withoutTwoHundredButDefault";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -128,7 +128,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "return byte array when response format is byte")
|
||||
public void binaryDataTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/binaryDataTest.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/binaryDataTest.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/binaryResponse";
|
||||
final Operation p = model.getPaths().get(path).getPost();
|
||||
@ -142,7 +142,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "use operation consumes and produces")
|
||||
public void localConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/localConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -158,7 +158,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "use spec consumes and produces")
|
||||
public void globalConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/globalConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -174,7 +174,7 @@ public class CodegenTest {
|
||||
|
||||
@Test(description = "use operation consumes and produces (reset in operation with empty array)")
|
||||
public void localResetConsumesAndProducesTest() {
|
||||
final Swagger model = new SwaggerParser().read("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final Swagger model = parseAndPrepareSwagger("src/test/resources/2_0/globalConsumesAndProduces.json");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
final String path = "/tests/localResetConsumesAndProduces";
|
||||
final Operation p = model.getPaths().get(path).getGet();
|
||||
@ -187,4 +187,11 @@ public class CodegenTest {
|
||||
Assert.assertNull(op.produces);
|
||||
|
||||
}
|
||||
|
||||
private Swagger parseAndPrepareSwagger(String path) {
|
||||
Swagger swagger = new SwaggerParser().read(path);
|
||||
// resolve inline models
|
||||
new InlineModelResolver().flatten(swagger);
|
||||
return swagger;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user