Skip to content

Commit b783ad9

Browse files
committed
Add deprecated property for OpenAPI operations
1 parent 31c23b2 commit b783ad9

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ build/
3030
!smithy-build/src/test/resources/software/amazon/smithy/build
3131
*/out/
3232
*/*/out/
33+
/wrapper

smithy-openapi/src/main/java/software/amazon/smithy/openapi/fromsmithy/OpenApiConverter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import software.amazon.smithy.model.shapes.Shape;
4444
import software.amazon.smithy.model.shapes.ShapeId;
4545
import software.amazon.smithy.model.traits.AuthTrait;
46+
import software.amazon.smithy.model.traits.DeprecatedTrait;
4647
import software.amazon.smithy.model.traits.DocumentationTrait;
4748
import software.amazon.smithy.model.traits.TitleTrait;
4849
import software.amazon.smithy.model.traits.Trait;
@@ -425,6 +426,10 @@ private <T extends Trait> void addPaths(
425426
String method = result.getMethod();
426427
String path = result.getUri();
427428
PathItem.Builder pathItem = paths.computeIfAbsent(result.getUri(), (uri) -> PathItem.builder());
429+
// Mark the operation deprecated if the trait's present.
430+
if (shape.hasTrait(DeprecatedTrait.class)) {
431+
result.getOperation().deprecated(true);
432+
}
428433
// Add security requirements to the operation.
429434
addOperationSecurity(context, result.getOperation(), shape, plugin);
430435
// Pass the operation through the plugin system and then build it.

smithy-openapi/src/test/resources/software/amazon/smithy/openapi/fromsmithy/test-service.openapi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"/payload/{path}": {
5454
"put": {
5555
"operationId": "PutPayload",
56+
"deprecated": true,
5657
"requestBody": {
5758
"content": {
5859
"application/octet-stream": {

0 commit comments

Comments
 (0)