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

fix: set nullable when it's a pointer of Struct #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chuliang
Copy link

Not sure about it. Normally the schema can be used only one time with Tonic(?)

@@ -895,7 +895,17 @@ func (g *Generator) newSchemaFromType(t reflect.Type) *SchemaOrRef {
case reflect.Slice, reflect.Array, reflect.Map:
return g.buildSchemaRecursive(t)
case reflect.Struct:
return g.newSchemaFromStruct(t)
sor := g.newSchemaFromStruct(t)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already check if the type is "nullable" above when dereferencing the pointer. We could simply check if the schema pointed by the ref is non-nil and set the Nullable property accordingly.

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

Successfully merging this pull request may close these issues.

2 participants