From 22f4a5dc18e92e8356168a2ee73485ac8c106ef9 Mon Sep 17 00:00:00 2001 From: altro3 Date: Thu, 13 Mar 2025 13:52:17 +0700 Subject: [PATCH] Added ability to set name for ApiResponse and RequestBody annotations --- .../v3/oas/annotations/parameters/RequestBody.java | 8 ++++++++ .../swagger/v3/oas/annotations/responses/ApiResponse.java | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/parameters/RequestBody.java b/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/parameters/RequestBody.java index 975f970bda..072ca76349 100644 --- a/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/parameters/RequestBody.java +++ b/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/parameters/RequestBody.java @@ -24,6 +24,14 @@ @Retention(RetentionPolicy.RUNTIME) @Inherited public @interface RequestBody { + + /** + * Unique name to identify this RequestBody component. Used in components block. + * + * @return the name of the RequestBody + */ + String name() default ""; + /** * A brief description of the request body. * diff --git a/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/responses/ApiResponse.java b/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/responses/ApiResponse.java index a21e3ad110..8b1d8aa71d 100644 --- a/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/responses/ApiResponse.java +++ b/modules/swagger-annotations/src/main/java/io/swagger/v3/oas/annotations/responses/ApiResponse.java @@ -30,6 +30,14 @@ @Inherited @Repeatable(ApiResponses.class) public @interface ApiResponse { + + /** + * Unique name to identify this ApiResponse component. Used in components block. + * + * @return the name of the ApiResponse + */ + String name() default ""; + /** * A short description of the response. *