swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.79k stars 1.21k forks source link

Support text/plain params schema #1921

Open moguchev opened 3 weeks ago

moguchev commented 3 weeks ago

Is your feature request related to a problem? Please describe.

I hava a text/plain API method with this description:

// @id              AcquiringInternetPaymentHandler
// @description     weebhook method for incoming payments
// @accept          plain
// @param           token body string true "base64 jwt token" format(base64) example(eyJ0eXAiOiJKV1...)

And it generates such specification:

  "parameters": [
      {
          "format": "base64",
          "example": "eyJ0eXAiOiJKV1...",
          "description": "base64 jwt token",
          "name": "token",
          "in": "body",
          "required": true,
          "schema": {
              "type": "string"
          }
      }
  ]

The problem is that body param has schema and attributes example and format must be in schema:

  "parameters": [
      {
          "description": "base64 jwt token",
          "name": "token",
          "in": "body",
          "required": true,
          "schema": {
              "type": "string",
              "format": "base64",
              "example": "eyJ0eXAiOiJKV1..."
          }
      }
  ]

Describe the solution you'd like If body is not a object and plain then attributes format and example should be in schema

Describe alternatives you've considered

Additional context