mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 22:20:56 +00:00
This commit is contained in:
parent
c7367c2d34
commit
035736f5c4
@ -1,5 +1,7 @@
|
|||||||
{{#required}}
|
{{#required}}
|
||||||
|
{{^isReadOnly}}
|
||||||
@NotNull
|
@NotNull
|
||||||
|
{{/isReadOnly}}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{#isContainer}}
|
{{#isContainer}}
|
||||||
{{^isPrimitiveType}}
|
{{^isPrimitiveType}}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
{{#required}}
|
{{#required}}
|
||||||
|
{{^isReadOnly}}
|
||||||
@NotNull
|
@NotNull
|
||||||
|
{{/isReadOnly}}
|
||||||
{{/required}}
|
{{/required}}
|
||||||
{{>beanValidationCore}}
|
{{>beanValidationCore}}
|
@ -1 +1 @@
|
|||||||
{{#required}}@NotNull {{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}@Valid {{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}@Valid {{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}}
|
{{#required}}{{^isReadOnly}}@NotNull {{/isReadOnly}}{{/required}}{{#isContainer}}{{^isPrimitiveType}}{{^isEnum}}@Valid {{/isEnum}}{{/isPrimitiveType}}{{/isContainer}}{{^isContainer}}{{^isPrimitiveType}}@Valid {{/isPrimitiveType}}{{/isContainer}}{{>beanValidationCore}}
|
@ -793,11 +793,73 @@ public class SpringCodegenTest {
|
|||||||
assertEquals(desFile, DESTINATIONFILE);
|
assertEquals(desFile, DESTINATIONFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!flag){
|
if (!flag) {
|
||||||
fail("OpenAPIDocumentationConfig.java not generated");
|
fail("OpenAPIDocumentationConfig.java not generated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldAddNotNullOnRequiredAttributes() throws IOException {
|
||||||
|
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||||
|
|
||||||
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/spring/issue_5026-b.yaml");
|
||||||
|
final SpringCodegen codegen = new SpringCodegen();
|
||||||
|
codegen.setOpenAPI(openAPI);
|
||||||
|
codegen.setOutputDir(output.getAbsolutePath());
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput();
|
||||||
|
input.openAPI(openAPI);
|
||||||
|
input.config(codegen);
|
||||||
|
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||||
|
|
||||||
|
generator.opts(input).generate();
|
||||||
|
|
||||||
|
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Dummy.java"), "status");
|
||||||
|
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Dummy.java"), "@NotNull");
|
||||||
|
Files.readAllLines(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Dummy.java")).forEach(System.out::println);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldNotAddNotNullOnReadOnlyAttributes() throws IOException {
|
||||||
|
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||||
|
output.deleteOnExit();
|
||||||
|
String outputPath = output.getAbsolutePath().replace('\\', '/');
|
||||||
|
|
||||||
|
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/spring/issue_5026.yaml");
|
||||||
|
final SpringCodegen codegen = new SpringCodegen();
|
||||||
|
codegen.setOpenAPI(openAPI);
|
||||||
|
codegen.setOutputDir(output.getAbsolutePath());
|
||||||
|
|
||||||
|
ClientOptInput input = new ClientOptInput();
|
||||||
|
input.openAPI(openAPI);
|
||||||
|
input.config(codegen);
|
||||||
|
|
||||||
|
DefaultGenerator generator = new DefaultGenerator();
|
||||||
|
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false");
|
||||||
|
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
|
||||||
|
|
||||||
|
generator.opts(input).generate();
|
||||||
|
|
||||||
|
assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Dummy.java"), "status");
|
||||||
|
assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Dummy.java"), "@NotNull");
|
||||||
|
Files.readAllLines(Paths.get(outputPath + "/src/main/java/org/openapitools/model/Dummy.java")).forEach(System.out::println);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTypeMappings() {
|
public void testTypeMappings() {
|
||||||
final SpringCodegen codegen = new SpringCodegen();
|
final SpringCodegen codegen = new SpringCodegen();
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
version: "1.0.0"
|
||||||
|
title: reactive-spring-boot-request-body-issue
|
||||||
|
tags:
|
||||||
|
- name: ReactiveSpringBootRequestBodyIssue
|
||||||
|
paths:
|
||||||
|
/some/dummy/endpoint:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- ReactiveSpringBootRequestBodyIssue
|
||||||
|
requestBody:
|
||||||
|
description: request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Dummy'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Successfully created reverse listings for retail
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Dummy'
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Dummy:
|
||||||
|
required:
|
||||||
|
- status
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
status:
|
||||||
|
type: string
|
@ -0,0 +1,35 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
version: "1.0.0"
|
||||||
|
title: reactive-spring-boot-request-body-issue
|
||||||
|
tags:
|
||||||
|
- name: ReactiveSpringBootRequestBodyIssue
|
||||||
|
paths:
|
||||||
|
/some/dummy/endpoint:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- ReactiveSpringBootRequestBodyIssue
|
||||||
|
requestBody:
|
||||||
|
description: request
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Dummy'
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Successfully created reverse listings for retail
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Dummy'
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
Dummy:
|
||||||
|
required:
|
||||||
|
- status
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
readOnly: true
|
Loading…
x
Reference in New Issue
Block a user