Situation
We are designing a new REST API and using swagger annotations to document our Spring controller methods. I discovered that many “constructions” are boilerplate and repeatedly appear.
Example:
@Operation(
summary = "...",
description = "...",
responses = [
ApiResponse(
responseCode = "200",
description = "Ok",
),
ApiResponse(
responseCode = "204",
description = "No contet",
content = [Content(schema = Schema(implementation = Void::class))]
),
ApiResponse(
responseCode = "201",
headers = [
Header(
name = "Location",
description = "The location of the created resource",
schema = Schema(implementation = Void::class)
)
],
description = "...",
),
]
)
I want to extract some “standard construction” and reuse them.
I can not create “const val
” from annotation because it is not a primitive type. Inline functions are not acceptable as well.
Any propositions?