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

Add 'db' tag to struct #1113

Closed
taylageben opened this issue Jul 30, 2017 · 3 comments
Closed

Add 'db' tag to struct #1113

taylageben opened this issue Jul 30, 2017 · 3 comments

Comments

@taylageben
Copy link

Problem statement

At the moment my generated model struct only contains a json tag. Is there a way to automatically add a db tag as well? If not, could this functionality be added?

For example:

type NewPet struct {

	// chip
	Chip string `json:"chip,omitempty" db:"chip"`

	// name
	// Required: true
	Name *string `json:"name" db:"name"`

	// tag
	Tag string `json:"tag,omitempty" db:"tag"`
}
@casualjim
Copy link
Member

you can add a custom tag. see here: https://github.com/go-swagger/go-swagger/blob/master/fixtures/codegen/todolist.models.yml#L680-L685

@taylageben
Copy link
Author

Thanks so much! Managed to get it working!

@jolancornevin
Copy link

The URL is deprecated because it's not a permalink. Here's what @casualjim wanted to reference:

WithCustomTag:
type: object
properties:
customtag:
type: string
x-go-custom-tag: mytag:"foo,bar"

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

3 participants