Author Topic: Generate custom constraints for JSON-schema with the EA JSON addin  (Read 433 times)

kaivec

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
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 :)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 10528
  • Karma: +358/-31
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Generate custom constraints for JSON-schema with the EA JSON addin
« Reply #1 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

Geert

kaivec

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Generate custom constraints for JSON-schema with the EA JSON addin
« Reply #2 on: June 22, 2020, 07:37:07 pm »
Thanks for the fast answer!