-
-
Notifications
You must be signed in to change notification settings - Fork 0
Marking String fields as nullable #207
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
Comments
Hi @rafal-gss, that's by design. Creek avoids nulls as much as possible. If a property is optional, use You may also be able to combine |
Actually, I don't think However, you can always inject data into the schema with class Model {
@JsonSchemaInject(json = "{\"type\": [\"null\", \"string\"]}")
public Optional<String> getFoo() {
return s;
}
//...
} The above would give you a JSON schema containing: "properties": {
"foo": { "type": ["null", "string"] }
} Though I'd still encourage you to avoid Let me know how you get on. |
Hi @big-andy-coates, thanks for a quick response! Looks like the |
No problem @rafal-gss Out of interest, are you looking at creek in general, or just needed a schema generator plugin? |
Just a schema generator. |
@big-andy-coates looks like the annotation you've mentioned is not part of the |
Sure, (as per docs: https://github.com/creek-service/creek-json-schema/tree/main/generator#jsonschema-annotations), you need to add a dependency on https://github.com/mbknor/mbknor-jackson-jsonSchema. |
Ugh, looks like it's abandoned. :/ I think it would be great if the creek libraries were more 'self-contained' - allowing for its usage without importing other libraries. For now, we're gonna have to go with another approach. |
Turns out the |
Yep, I hear you: creek-service/creek-json-schema#272 However, you can manually update dependencies with vulnerabilities in your own build files to ensure you're working with versions that have no known vulnerabilities. Good luck either way :) |
Cheers, Andy! |
Is your feature request related to a problem? Please describe.
By default, a class that has a property of type
String
will generate a schema withtype: string
, which does not accept nulls.What we need instead is
["string", "null"]
Describe the solution you'd like
Add an annotation that would allow defining whether given
String
field in nullable or not.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: