mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-04-20 17:29:09 +00:00
This commit is contained in:
@@ -27,6 +27,9 @@ import java.util.Optional;
|
||||
{{#async}}
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
{{/async}}
|
||||
{{#returnSuccessCode}}
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
{{/returnSuccessCode}}
|
||||
import {{javaxPackage}}.annotation.Generated;
|
||||
|
||||
{{#operations}}
|
||||
|
||||
@@ -5575,4 +5575,36 @@ public class SpringCodegenTest {
|
||||
.toFileAssert()
|
||||
.assertMethod("findPetsByStatus").hasReturnType("List<Pet>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasRestControllerDoesNotHaveController_issue21156() throws IOException {
|
||||
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_1/issue_21156.yaml");
|
||||
final SpringCodegen codegen = new SpringCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
codegen.setOutputDir(output.getAbsolutePath());
|
||||
codegen.setLibrary("spring-boot");
|
||||
|
||||
codegen.additionalProperties().put(INTERFACE_ONLY, "false");
|
||||
codegen.additionalProperties().put(DELEGATE_PATTERN, "true");
|
||||
codegen.additionalProperties().put(SPRING_CONTROLLER, "true");
|
||||
codegen.additionalProperties().put(RETURN_SUCCESS_CODE, "true");
|
||||
|
||||
ClientOptInput input = new ClientOptInput();
|
||||
input.openAPI(openAPI);
|
||||
input.config(codegen);
|
||||
|
||||
DefaultGenerator generator = new DefaultGenerator();
|
||||
generator.setGenerateMetadata(false); // skip metadata generation
|
||||
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
|
||||
|
||||
Map<String, File> files = generator.opts(input).generate().stream()
|
||||
.collect(Collectors.toMap(File::getName, Function.identity()));
|
||||
|
||||
JavaFileAssert javaFileAssert = JavaFileAssert.assertThat(files.get("TestApiDelegate.java"));
|
||||
javaFileAssert
|
||||
.hasImports("java.util.concurrent.atomic.AtomicInteger");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
openapi: 3.1.1
|
||||
info:
|
||||
title: Test Bug
|
||||
version: 1.0.0
|
||||
servers:
|
||||
- url: https://where.am.i
|
||||
paths:
|
||||
/test/bug:
|
||||
post:
|
||||
operationId: testRequest
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TestRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: Test request successful
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TestResponse'
|
||||
'500':
|
||||
$ref: '#/components/responses/InternalServerError'
|
||||
components:
|
||||
schemas:
|
||||
TestRequest:
|
||||
properties:
|
||||
test:
|
||||
type: string
|
||||
TestResponse:
|
||||
properties:
|
||||
test:
|
||||
type: string
|
||||
ErrorResponse:
|
||||
properties:
|
||||
error:
|
||||
type: string
|
||||
responses:
|
||||
InternalServerError:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
description: Internal server error
|
||||
Reference in New Issue
Block a user