Skip to content

Commit

Permalink
clean: simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
54m committed Nov 22, 2022
1 parent e4f8baa commit 289cbc5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/server/swaggen.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ func (g *Generator) generateSwagComment(ep *parser.Endpoint) string {
for k, v := range obj.Entries {
t, attrs := getSwagType(v.Type)

param, ok := reflect.StructTag(v.RawTag).Lookup("param")
structTag := reflect.StructTag(v.RawTag)

param, ok := structTag.Lookup("param")
if !ok {
param = k
}
Expand All @@ -45,7 +47,7 @@ func (g *Generator) generateSwagComment(ep *parser.Endpoint) string {
if _, ok := placeholders[param]; ok {
params = append(params, fmt.Sprintf(`// @Param %s path %s %v "%s"%s`+"\n", param, t, true, k, attrs))
} else if ep.Method == parser.GET {
example, ok := reflect.StructTag(v.RawTag).Lookup("example")
example, ok := structTag.Lookup("example")
if !ok {
example = k
}
Expand Down

0 comments on commit 289cbc5

Please sign in to comment.