Skip to content

fix: infer - arrays should always accept null#49

Merged
jba merged 4 commits intogoogle:mainfrom
rafaeljusto:null-array
Dec 2, 2025
Merged

fix: infer - arrays should always accept null#49
jba merged 4 commits intogoogle:mainfrom
rafaeljusto:null-array

Conversation

@rafaeljusto
Copy link
Contributor

When building the JSON schema for an array we should always allow "null" since any slice in Go can contain a nil value.

Resolves #48

@rafaeljusto
Copy link
Contributor Author

This is another behaviour change, so I assume we would also need to wrap it around JSONSCHEMAGODEBUG? Should we keep the same typeschemasnull=1 flag value or use a different one?

@jba
Copy link
Collaborator

jba commented Nov 19, 2025

This is another behaviour change, so I assume we would also need to wrap it around JSONSCHEMAGODEBUG? Should we keep the same typeschemasnull=1 flag value or use a different one?

Yes. You can use the same flag value.

Also please update the README describing the env var and both effects of this flag.

@jba
Copy link
Collaborator

jba commented Nov 19, 2025

Actually not the README. doc.go at the bottom. Add a new section: # Controlling behavior changes.
Describe the env var and list the flag values using a dotted (unordered) list. Even though there's only one.

rafaeljusto added a commit to rafaeljusto/jsonschema-go that referenced this pull request Nov 19, 2025
@rafaeljusto
Copy link
Contributor Author

Done @jba ! Let me know if I should apply further changes. 🙂

When building the JSON schema for an array we should always allow "null" since
any slice in Go can contain a `nil` value.

Resolves google#48
@rafaeljusto
Copy link
Contributor Author

Thanks for taking the time to review this and share your feedback, @jba! I’ve applied your suggestion. Let me know if anything else needs adjusting.

@rafaeljusto rafaeljusto requested a review from jba November 26, 2025 22:15
Copy link
Collaborator

@jba jba left a comment

Choose a reason for hiding this comment

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

Sorry for the delay.

@jba jba merged commit 11a93dc into google:main Dec 2, 2025
6 checks passed
@rafaeljusto rafaeljusto deleted the null-array branch December 3, 2025 09:45
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.

Allow null for arrays

2 participants