Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct field comments get incorrectly duplicated when using type aliases from other packages #1342

Closed
djui opened this issue Oct 4, 2022 · 1 comment

Comments

@djui
Copy link

djui commented Oct 4, 2022

Describe the bug

When using a comment on a struct field with a type alias to another package which also gets replaced, this field's comment will be duplicated to other fields that should not have a comment (or their own comment).

To Reproduce
This examples will demonstrate the issue: See in the swagger.yaml the field b has a description (Comment) but shouldn't.

// main.go

package main

import (
	"database/sql"
	"net/http"
)

type Bool sql.NullBool

type Foo struct {
	A Bool // Comment
	B Bool
}

// @Success 200 {object} Foo
func handle(w http.ResponseWriter, r *http.Request) {}
# .swaggo
replace database/sql.NullBool boolean

Run:

swag init --parseDependency --overridesFile ".swaggo" --dir cmd/main --outputTypes yaml

Output:

# swagger.yaml
main.Foo:
  properties:
    a:
      description: Comment
      type: boolean
    b:
      description: Comment
      type: boolean
  type: object

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots

Your swag version
e.g. 1.8.6

Your go version
e.g. 1.19.1

Desktop (please complete the following information):

  • OS: MacOS 12.6

Additional context

@danvixent
Copy link

I'm experiencing this bug as well

sdghchj added a commit that referenced this issue Nov 21, 2022
sdghchj added a commit that referenced this issue Nov 21, 2022
sdghchj added a commit that referenced this issue Nov 21, 2022
This reverts commit 6031d3e.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants