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

my post api should accept a model which has some readonly fields #2378

Open
SeaJames opened this issue Aug 11, 2020 · 1 comment
Open

my post api should accept a model which has some readonly fields #2378

SeaJames opened this issue Aug 11, 2020 · 1 comment
Labels
model Related to swagger generate model command question

Comments

@SeaJames
Copy link

SeaJames commented Aug 11, 2020

my post api should accept a model which has some readonly fields(like id...), but swagger seems not to be work well, ok, i found can add 'readonly' tag for work properly, but I think this is not a good way, acctually, the readonly should use for gin or gorm

Problem statement

type MyItem struct {
// id
// Read only: true
ID uint64 json:"id" yaml:"id" binding:"-" gorm:"PRIMARY_KEY;AUTO_INCREMENT" readonly:"true"
}

Swagger specification

Steps to reproduce

Environment

swagger version: x.x.x
go version: x.x.x
OS:

@fredbi fredbi changed the title my post api should accept a model which has some readonly fields(like id...), but swagger seems not to be work well, ok, i found can add 'readonly' tag for work properly, but I think this is not a good way, acctually, the readonly should use for gin or gorm my post api should accept a model which has some readonly fields Aug 11, 2020
@fredbi
Copy link
Contributor

fredbi commented Aug 11, 2020

The swagger readOnly specification currently doesn't do anything on generated validations. See #936
There is no interaction between the swagger spec and the db-specific tags, unless you force tags manually.

@fredbi fredbi added model Related to swagger generate model command question labels Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
model Related to swagger generate model command question
Projects
None yet
Development

No branches or pull requests

2 participants