Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Request example is not rendered for GET requests #198

Open
tkeidar opened this issue Nov 2, 2021 · 1 comment
Open

[BUG] Request example is not rendered for GET requests #198

tkeidar opened this issue Nov 2, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@tkeidar
Copy link

tkeidar commented Nov 2, 2021

Describe the bug
When I try to set an example for GET requests swagger does not generate it.

To Reproduce

/**
   * GET /example
   * @summary Example
   * @description Get example for some input.
   * @param {string} param1.query.required - First param
   * @param {number} param2.query.required - Second param
   * @return {object} 200 - Success response
   * @return {object} 400 - Bad request response
   * @example request
   *  {
   *    "param1": "hi",
   *    "param2": 500
   *  }
   * @example response - 200 - Success response example
   *  {
   *    "hello": "world"
   *  }
   * @example response - 400 - Invalid input
   *  {
   *    "error": "Invalid input"
   *  }
   */

Expected behavior
I expect the generated json to include examples for the request, but actually here is the path I get:

"paths": {
    "/example": {
      "get": {
        "deprecated": false,
        "summary": "Example",
        "description": "Get example for some input.",
        "security": [],
        "responses": {
          "200": {
            "description": "Success response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example1": {
                    "summary": "Success response example",
                    "value": {
                      "hello": "world"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "examples": {
                  "example2": {
                    "summary": "Invalid input",
                    "value": {
                      "error": "Invalid input"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "param1",
            "in": "query",
            "description": "First param",
            "required": true,
            "deprecated": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "param2",
            "in": "query",
            "description": "Second param",
            "required": true,
            "deprecated": false,
            "schema": {
              "type": "number"
            }
          }
        ],
        "tags": []
      }
    }
  }

Screenshots
image

@kevinccbsg
Copy link
Member

Hi @tkeidar right now we only support examples for request body and responses. We will mark this as an enhancement.

@kevinccbsg kevinccbsg added the enhancement New feature or request label Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants