0

I'm trying to create swagger.json file that consists get and post methods api. as a requirement for the get method, I need to pass multiple parameters to get method url string like http://localhost:3000/api/get?name=ajay&age=24&nationality=india and string parameters for get method are not constant. so I tried to create get method parameters as object in swagger UI and so that it can parse that json object and add those json parameters to the url. however it is not working as expected. can anyone help me to achieve above requirement.

"/get": {
      "get": {
        "tags": [
          "query"
        ],
        "description": "Query Function",
        "parameters": [
          {
            "name": "query",
            "in": "body",
            "type":"object",
            "description": "query or body parameters should be passed as defined in the function.",
            "schema": {
              "$ref": "#/definitions/query"
            }
          }
        ],
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "query successfull..",
            "schema": {
              "$ref": "#/definitions/query"
            }
          }
        }
      }
6
  • To recap the linked Q&A - this is possible in OpenAPI 3.0 but not in 2.0. The parameter needs to be defined with style: form + explode: true. Commented Mar 24, 2020 at 13:25
  • Hello Helen, Thanks for the comment. Can please provide me an example to do this? Or any reference? Commented Mar 24, 2020 at 13:30
  • See my answer in the linked Q&A. Commented Mar 24, 2020 at 13:47
  • I checked it. Somehow, it is for fixed query parameters only. What if we have unknown dynamic parameters to pass to url?? Commented Mar 24, 2020 at 13:51
  • Check out How to document dynamic query parameter names in OpenAPI (Swagger)? Commented Mar 24, 2020 at 16:22

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.