-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support for deep models #39
Comments
@Sayujya you mean Nested structs (a struct inside another struct) or or Promoted fields ? Nested structs:
Promoted fields:
Can you post your example? |
How do you specify that? I just get this
|
@Sayujya where is your type |
@Sayujya don't you mean like:
I'm facing a similar issue, where the type declared above its usage doesn't get recognized. |
@nadilas can you post your declarative comments? I can't reproduce this issue. |
Sure: // @title API
// @version 1.0
// @description fdsfds
// @termsOfService asfsadf
// @contact.name API Support
// @contact.url dsgdfsg
// @contact.email fdssgfdsfd
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost
// @BasePath /v1
func main() { }
// @Summary fdsgfdsgfd
// @Description dfsgdfsgfd
// @ID get-all-tags
// @Accept json
// @Produce json
// @Param some_id path int true "Some ID"
// @Success 200 {array} models.Tag
// @Failure 400 {object} models.APIError "ID is required"
// @Failure 404 {object} models.APIError "Can not find ID"
// @Router /v1/tags [get]
func GetTags(c *gin.Context) {}
type TagTemplate struct {
ID string
TagId string
RemotePath string
HtmlData string
}
type Tag struct {
ID string
Name string
Template TagTemplate
LabelType LabelType
} And the result: 200:
[
{
"ID": "string",
"LabelSerialNr": "string",
"LabelType": "Unknown Type: LabelType",
"Template": "Unknown Type: TagTemplate"
}
] |
@nadilas I have created https:/easonlin404/swag-issue using above declarative comments. Can you help to figure out? |
@easonlin404 so I guess I found the issue. In the Problems I encountered:
type Tag struct {
ID string
Name string
Template TagTemplate
LabelType LabelType
Label2Type models2.Label2Type // doesn't work
}
That's it. Models from the same package now get resolved.
|
@nadilas thank you sorted out the problem and to add supported for cross-package models. |
fix via #42 |
@easonlin404 how about case with nested struct ?
|
I fix. |
Is there a way to get deep models working? Right now if I have a struct inside another struct, it doesn't recognize the top struct. Similarly bool (type bool) isn't recognized either.
The text was updated successfully, but these errors were encountered: