swaggo / swag

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

Generated open api missing schema in path/query parameter #1767

Closed YannickTeKulve closed 8 months ago

YannickTeKulve commented 8 months ago

Describe the bug The open api spec states: A parameter MUST contain either a schema property, or a content property, but not both. See also https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md and this example: https://github.com/OAI/OpenAPI-Specification/blob/19765c1eff1f733802b1c6f14cf8a073fb7a5b25/examples/v3.0/petstore-expanded.yaml#L113C11-L116C1

But when generating path or query parameters these are missing

To Reproduce The following comments:

// @Router       /foo/{name} [put]
// @Param        name path string true "The name"

Generates:

/foo/{name}:
    put:
      parameters:
      - description: The name
        in: path
        name: name
        required: true
        type: string
      responses: {}

Expected behavior Should be:

  /foo/{name}:
    put:
      parameters:
      - description: The name
        in: path
        name: name
        required: true
        schema:
          type: string
      responses: {}`

Your swag version v1.16.3

Your go version 1.21

Desktop (please complete the following information):

Additional context Also for json

YannickTeKulve commented 8 months ago

Close: v2 vs v3 openapi spec