Showing results for 
Search instead for 
Did you mean: 

Document a @RequestBody Map/List in Swagger

Frequent Visitor

Document a @RequestBody Map/List in Swagger

I'm creating the swagger file for the documentation of the various APi. In a controller I have the case where I request a RequestParam and a RequestBody:


@Timed(value = MetricsTimerConstants.storeMessageWithParamsTimer)
public ResponseEntity<Object> saveMessageWithParams(@RequestBody Map<String, Object> request,
@RequestParam List<String> params) { .....



 Is there a way to define Lists and Maps in OpenApi?I have read the documentation but I can't find a part where they explain how to define the Maps and the Lists in the Swaggers. Thanks so much for the support



Re: Document a @RequestBody Map/List in Swagger

Is your question about Swagger Java annotations or about OpenAPI syntax syntax for maps? If the latter, check out these links:

OpenAPI 3.0: Data Types - Arrays

OpenAPI 3.0: Dictionaries, HashMaps and Associative Arrays

Helen Kosova
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video: