Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) v
{{#vendorExtensions.x-operation-extra-annotation}}
{{{.}}}
{{/vendorExtensions.x-operation-extra-annotation}}
{{#isDeprecated}}
@Deprecated
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
{{/isDeprecated}}
@RequestMapping(
method = [RequestMethod.{{httpMethod}}],
// "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ interface {{classname}} {
{{#vendorExtensions.x-operation-extra-annotation}}
{{{.}}}
{{/vendorExtensions.x-operation-extra-annotation}}
{{#isDeprecated}}
@Deprecated
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
{{/isDeprecated}}
@RequestMapping(
method = [RequestMethod.{{httpMethod}}],
// "{{#lambdaEscapeInNormalString}}{{{path}}}{{/lambdaEscapeInNormalString}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4663,6 +4663,49 @@ public void testSealedResponseInterfacesVoidResponse() throws IOException {
Assert.assertTrue(petContent.contains(") : CreatePetResponse {") || petContent.contains(") : CreatePetResponse"),
"Pet should implement CreatePetResponse");
}

@Test
public void testDeprecatedAnnotationOnInterface() throws IOException {
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
output.deleteOnExit();
String outputPath = output.getAbsolutePath().replace('\\', '/');

KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
codegen.setOutputDir(output.getAbsolutePath());
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "org.openapitools.api");
codegen.additionalProperties().put(KotlinSpringServerCodegen.INTERFACE_ONLY, true);

new DefaultGenerator().opts(new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/support-deprecated-api.yaml"))
.config(codegen))
.generate();

assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PingApi.kt"),
"@Deprecated @RequestMapping("
);
}

@Test
public void testDeprecatedAnnotationOnController() throws IOException {
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
output.deleteOnExit();
String outputPath = output.getAbsolutePath().replace('\\', '/');

KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
codegen.setOutputDir(output.getAbsolutePath());
codegen.additionalProperties().put(CodegenConstants.API_PACKAGE, "org.openapitools.api");

new DefaultGenerator().opts(new ClientOptInput()
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/support-deprecated-api.yaml"))
.config(codegen))
.generate();

assertFileContains(
Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/PingApiController.kt"),
"@Deprecated @RequestMapping("
);
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
openapi: "3.0.0"
info:
title: Verify @Deprecated annotation
version: "1.0"

paths:

/ping:
get:
deprecated: true
operationId: ping
responses:
200:
description: OK
Loading