Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define Map objects in Open API 3.0, for GET API

I have GET API, which takes Map as a request param. How to define this in Open API 3.0, in yaml format

@GetMapping
public void getDevicesInfo(@RequestParam(required = false) Map parameters)
{

}

Open API is not supporting Map type.

like image 860
Mamatha K Avatar asked Oct 22 '25 08:10

Mamatha K


1 Answers

In your YAML file you need to add additionalProperties for Map in Java and use parameters for @RequestParam as :

/api/v1/test:
  get:
    tags:
      - test
    operationId: getDevicesInfo
    parameters:
      - name: parameters
        in: query
        required: false
        schema:
          type: object
          additionalProperties:
            type: object
    responses:
      '200':
        description: OK

The generated GET API looks like:

enter image description here

I hope it helps you :)

like image 62
Suraj Gautam Avatar answered Oct 23 '25 20:10

Suraj Gautam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!