Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: kaivec on June 22, 2020, 06:31:57 pm

Title: Generate custom constraints for JSON-schema with the EA JSON addin
Post by: kaivec on June 22, 2020, 06:31:57 pm
Hi All,

im using the EA JSON addin from Geert Bellekens to generate json-schema and I want to create constraints for my Attributes, e.g. minLength or minimum... . I found out that you can do this in the tagged values section, but I can only get some tags to work, like minimum, maximum, etc... Is there a list of the tags that are possible and is it possible to create custom constraints?

Also when I generate json-schema, things like the additionalProperties tag is always set to false, and all my properties are set to required. Is there a way to change that? E.g. in my case i would need the additional properties to be an object, and most of my properties arent required. Would this be possible somehow?

I would be happy about any advice :)
Title: Re: Generate custom constraints for JSON-schema with the EA JSON addin
Post by: Geert Bellekens on June 22, 2020, 06:45:36 pm
Hi Kaivec,

You can only add the constraints (facets in XSD terms) that are supported by JSON Schema, but minimum or minlength are among those.
These should be available if you make a JSON_atribute or a JSON_Datatype (If you are using v15.1 look in the properties docked window)

Required or not is controlled by the multiplicity of the attribute. Set it to 0..1 to make it optional.

Changing AdditionalProperties is not (yet) supported.
It is currently set to False only
https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/search?q=AllowAdditionalProperties&unscoped_q=AllowAdditionalProperties (https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/search?q=AllowAdditionalProperties&unscoped_q=AllowAdditionalProperties)

Geert
Title: Re: Generate custom constraints for JSON-schema with the EA JSON addin
Post by: kaivec on June 22, 2020, 07:37:07 pm
Thanks for the fast answer!