Skip to content

double brackets in field description causes template engine to fail #1177

@mainpart

Description

@mainpart

If i use {{ and }} syntax in field comments swagger fail to templatize document with neccessary variables to function.

type Struct struct{
Field1 string // you can use {{funcwhatever param}} in string value
}

swaggo successfully compiles docs.go but fails to template it because funcwhatever is not defined in runtime.
as a result html page become dysfunctional

// ReadDoc parses SwaggerTemplate into swagger document.
func (i *Spec) ReadDoc() string {
	i.Description = strings.Replace(i.Description, "\n", "\\n", -1)
         ...
	}).Parse(i.SwaggerTemplate)
	if err != nil {
		return i.SwaggerTemplate
	}

swag version 1.81

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions