springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

Support dynamic evaluation of description field in the RequestBody annotation

Open kbos-work opened this issue 1 year ago • 4 comments

Is your feature request related to a problem? Please describe.

While using the @RequestBody annotation it doesn't replace variable content ${myapicall.request_body.description} for the description. Example the following will result in outputting the variable as is inside the swagger doc

@RequestBody(description = "${myapicall.request_body.description}")

Describe the solution you'd like

While using annotations in for example @Operation and @Parameter it supports dynamic evaluation of properties. For example the following will generate the swagger doc in which the summary/descriptions are replaced with the corresponding values from the property file

@Operation(summary = "${myapicall.summary}", description = "${myapicall.description}")
public ResponseEntity<Object> doApiCall(@Parameter(description = "${myapicall.params.example}", required = true) @RequestParam String example) {

}

It would be great if the same would be supported for @RequestBody. Looking deeper in the source it would effectively mean to support the usage of PropertyResolverUtils inside the RequestBodyService similar to GenericParameterService

Describe alternatives you've considered

  • Only real alternative is defining it directly in code, but in case of an multi language setup that would not work

Additional context

None

kbos-work avatar Jan 22 '24 22:01 kbos-work

+1

vsadokhin avatar Jan 23 '24 02:01 vsadokhin

It would resolve also https://github.com/swagger-api/swagger-ui/issues/9296

esirkova avatar Jan 23 '24 13:01 esirkova

Thanks @esirkova

scintilla932 avatar Jan 24 '24 06:01 scintilla932

I pushed a PR from my personal account today, so please have a look

BokoEnos avatar Jan 25 '24 11:01 BokoEnos