-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Define how to handle null
type
#15
Comments
null
type for different propertiesnull
type
In JSON, |
So, for JSON Schema: { "properties": { "test": { "type": "null" } } } validates correctly against { "test": null } and { } In a sense, removing the property completely makes sense to some extend here, as there are no values you want to access is there? However, with require, removing the property is not possible and it needs to be present: { "required": ["test"], "properties": { "test": { "type": "null" } } } validates correctly against { "test": null } but not { } In a sense, we have the same scenario anyway, where you don't really have an incentive to access such as property in any use-case is there (besides when the class is serialized the property needs to be there)? In TS we can do the following: class testType {
test: null
} And for Java: class testType {
final Object test = null;
} We could also let custom serializable functionality handle it, and not generate the property at all: class testType {
serialize(){
return '{test: null}'
}
} I do however find that a bit weird 🤔 What are your thoughts? |
You have to remember that JSON Schema describes JSON data and in JSON, So, in your example, the "test" property definitely needs to be generated because "test" is null and not required class TestType {
JsonNull test = JsonNull.getInstance();
} "test" is null and required class TestType {
@NotNull
JsonNull test = JsonNull.getInstance();
} I'm assuming "test" is null and not required type TestType = {
test?: null;
} "test" is null and required type TestType = {
test: null;
} |
Alright, that makes sense 👍 Thanks for clarifying 🙂 |
I realize this has been closed for a while, but I thought this was relevant.
In some API frameworks (like what's offered out of the box by .Net), this is difficult to discern, though, because they treat |
We need to figure out how we want to handle the
null
type overall.The text was updated successfully, but these errors were encountered: