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"
            }
          }
        }
      }
ajay
  • 328
  • 1
  • 5
  • 17
  • 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`. – Helen Mar 24 '20 at 13:25
  • Hello Helen, Thanks for the comment. Can please provide me an example to do this? Or any reference? – ajay Mar 24 '20 at 13:30
  • See [my answer](https://stackoverflow.com/a/51277233/113116) in the linked Q&A. – Helen Mar 24 '20 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?? – ajay Mar 24 '20 at 13:51
  • Check out [How to document dynamic query parameter names in OpenAPI (Swagger)?](https://stackoverflow.com/q/49582559/113116) – Helen Mar 24 '20 at 16:22
  • Thanks man..! This is What I needed. – ajay Mar 24 '20 at 16:44

0 Answers0