Closed zrzka closed 5 years ago
I think it could be a part of it. I'm thinking of a case where we do not have an optional type there.
From rendition perspective, if the schema defines a non-optional property we could still accept empty {}
as a default value for the whole data object, as the form will set it there. It just needs to be an object. It looks weird, because it does not conform to the schema, but would work.
If we'd like to have it conform to the schema, it would work as well, so e.g. { "stringProperty" : ""}
should be perfectly fine, as long as it is returned for a schema where the stringProperty
does not have a default
keyword set as well.
So in other words:
properties:
- stringProperty:
type: string
could either result in default value be {}
or { "stringProperty" : ""}
- both are acceptable.
I kinda like the second a bit more because it is more specific and because it should pass the schema validation. What do you think ?
I did commit a change where I make sure that the root object / array is created.
But this ...
properties:
- stringProperty:
type: string
... leading to { "stringProperty" : ""}
I do not like. I don't see a reason to do it. This is about default
in the JellySchema. Empty object / array is one thing, but real value for string
(even empty ""
) is something completely different.
Cool, let me test this out after lunch and I can try and see what happens when I try to use it in rendition :)
One important note - this isn't replacement of what you do in rendition. It should fill in default
values and that's it. So, if you need more, should be done in rendition.
Change-type: patch Signed-off-by: Robert Vojta robert@balena.io