Skip to content

generate: Ref property in response doesn't have a description #2757

@Kangaroux

Description

@Kangaroux

Problem statement

If a response contains a reference to a model, and the field in the response has a comment, that comment is ignored and not included as a description.

Swagger specification

responses:
  CreateUserResponse:
    description: ""
    schema:
      properties:
        error:
          description: An error message describing what went wrong
          type: string
        user:
          # Missing description field
          $ref: '#/definitions/User'
      type: object

Steps to reproduce

// swagger:model
type User struct {
	ID    int64  `json:"id"`
	Email string `json:"email"`
}

// swagger:response
type CreateUserResponse struct {
	// in: body
	Body struct {
		// An error message describing what went wrong
		Error string `json:"error,omitempty"`

		// The created user
		User User `json:"user"`
	}
}
swagger generate spec -o ./swagger.yml

Environment

swagger version: v0.29.0
go version: go1.18 linux/amd64
OS: Pop!_OS 21.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions