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

non-exported struct fields are being exported #666

Closed
tcarreira opened this issue Apr 10, 2020 · 0 comments
Closed

non-exported struct fields are being exported #666

tcarreira opened this issue Apr 10, 2020 · 0 comments

Comments

@tcarreira
Copy link

Describe the bug
If I have not-exported fields on a struct, it gets exported as a json example. It should stay hidden

To Reproduce

If you have this code:

// TestStruct Test Struct
type TestStruct struct {
	tableName    struct{}
	anotherField string
	ID           uint64 `json:"-"`
	Name         string `json:"name"`
	Age          int    `json:"age"`
}

// TestFunction Test
// ---
// @Summary Test Function
// @Description Test non-exported fields
// @Produce json
// @Success 200 {object} TestStruct "Test Struct"
// @Router /test [get]
func TestFunction() {}

We get the struct TestStruct with example :

{
  "age": 0,
  "anotherField": "string",
  "name": "string",
  "tableName": {}
}

Expected behavior
we should get:

{
  "age": 0,
  "name": "string"
}

Screenshots
Screenshot_20200410_051256

Your swag version

$ swag -v
swag version v1.6.5

Your go version

$ go version
go version go1.14.1 linux/amd64

Additional context
The fields disappear it I explicitly disable them with a json tag:

// TestStruct Test Struct
type TestStruct struct {
	tableName    struct{} `json:"-"`
	anotherField string   `json:"-"`
	ID           uint64   `json:"-"`
	Name         string   `json:"name"`
	Age          int      `json:"age"`
}

PS
Point me in the right direction, and I may get some time to submit a PR

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

1 participant