Closed Persi closed 1 month ago
@Persi we already have this using item
annotation. However, this will only pass item type and not it's properties. See here:
https://github.com/losisin/helm-values-schema-json/pull/49/files
If object is defined with properties, how should the desired JSON look like?
This MR looks good to me, I'll try it out after next release. Thank you for the fast reaction and fix :)
I tried current release 1.5.4 of your helm plugin, but unfortunately it does not seem to work.
My property looks like follows:
myprop: [] # @schema description: nice desc here;uniqueItems:true;item:object;itemProperties:{\"name\": {\"type\": \"string\"}, \"serviceType\": {\"type\": \"string\"}}
Result looks like follows:
"myprop": {
"description": "nice desc here",
"items": {
"type": "object"
},
"type": "array",
"uniqueItems": true
},
What do i miss?
I think it's the quotes escaping. this yaml:
myprop: [] # @schema description: nice desc here;uniqueItems:true;item:object;itemProperties:{"name": {"type": "string"}, "serviceType": {"type": "string"}}
produces this json:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"myprop": {
"description": "nice desc here",
"items": {
"properties": {
"name": {
"type": "string"
},
"serviceType": {
"type": "string"
}
},
"type": "object"
},
"type": "array",
"uniqueItems": true
}
},
"type": "object"
}
Wow ... if you do the thing and you do it right ... it just works :D Thanks for your support!
glad I can help :)
I could not find a solution to define the type of objects contained in an array. I believe the JSON Schema Spec is providing a way to do that, with the keyword items on an array.
If my default values.yaml should just provide the option to define a property as array, with an empty array as default value, I am unable to define the type of object I expect in that array.
For example:
just results in the following schema definition:
My suggestion would be to introduce a new keyword like
itemType
, with a definition for object as follows:For primitive types just like that: