Skip to content

Can't generate description for object type in its definition. #708

@Terminator637

Description

@Terminator637

Describe the bug
Can't generate description for object type in its definition.

To Reproduce
Trying to add comments/annotations everywhere for my Errors struct but can't achieve expected behavior.

// Contextual errors map
type Errors struct {
	DataLayerName  string `json:"dataLayerName,omitempty" example:"can't be empty"`
}

type ErrorsResponse struct {
	// Contextual errors map
	Errors *Errors `json:"errors,omitempty"`
        // List of important notifications
	Notification []string `json:"notification,omitempty" example:"some important notification, other important notification"`
}

Expected behavior

"handlers.Errors": {
            "type": "object",
	    "description": "Contextual errors map",
            "properties": {
                "dataLayerName": {
                    "type": "string",
                    "example": "can't be empty"
                },

Visually it will look like on screenshot in Swagger UI Models if "description" will be there(added it manually):
2020-05-22_21-09

Actual behavior
But got it without "description": "Contextual errors map":

"handlers.Errors": {
            "type": "object",
            "properties": {
                "dataLayerName": {
                    "type": "string",
                    "example": "can't be empty"
                },

And in Swagger UI there is no description like on screenshot above.

Your swag version
latest master v1.6.6-0.20200519063744-e07798f56b23

Your go version
1.12.17

Desktop:

  • OS: Ubuntu
  • Version: 18.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