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

How can I inline a Go struct in OpenAPI #134

Open
ZoeGeng opened this issue Jan 23, 2025 · 1 comment
Open

How can I inline a Go struct in OpenAPI #134

ZoeGeng opened this issue Jan 23, 2025 · 1 comment

Comments

@ZoeGeng
Copy link

ZoeGeng commented Jan 23, 2025

Since I have an embedded struct and a custom struct based on the JSON schema, like the following, I found that Swagger doesn't inline them.:

type(
FieldSchema struct {
		jsonschema.Schema `json:",inline"`
		XConstraintUnique *bool `json:"x-constraint-unique"`
	}

type Model struct {
       Fields []*FieldSchema `json:"fields"`
}


type ModelDef struct {
       Fields []*FieldSchema `json:", inline"`
       Site string `json:"site"`
}

)
@vearutop
Copy link
Member

@ZoeGeng what's the idea of having json:",inline" instead of not having any json tag at all (afaik encoding/json does not handle inline in any way)?

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