DMN Data Type Constraints and JsonSchema

245 views
Skip to first unread message

Amit Mor

unread,
Dec 29, 2020, 2:12:01 PM12/29/20
to Kogito development mailing list
Hello fellow Kogito-ians,

I'm working hard to somehow extract DMN Data Types (and most importantly and additionally the type Constraints) information so that our DMN client services (backend services calling the REST endpoints) can utilize the extracted types as a mean to validate content before calling the downstream models and even to represent those extracted schemas through a UI.

The generated OpenAPI spec is really a great addition, as well as the generated `target/classes/META-INF/resources/dmnDefinitions.json` files (json-schema?).

The issue here is the constraints of the data types - it appears that string types, with added Enum constraint, are reflected correctly in the generated json schema, for example, this is generated from a string data type with enum constraint of 2 strings ("amit" & "keren"):

"first_name": {
      "enum": [
        "amit",
        "keren"
      ],
      "type": "string",
      "x-dmn-type": "DMNType{ https://kiegroup.org/dmn/_C334EEAE-08D0-419A-98A2-5AF5BF3D649C : first_name }"
    }

whereas, for a field named "some_number", of type: number, with type constraint of "range", as annotated in the DMN xml as:
<dmn:itemDefinition id="_87A220EA-37CF-42AB-A7AF-FBA631CD59D6" name="some_number" isCollection="false">
    <dmn:typeRef>number</dmn:typeRef>
    <dmn:allowedValues kie:constraintType="range" id="_41CBF70A-18BE-4871-B423-236ED8AC57E4">
      <dmn:text>[1..5]</dmn:text>
    </dmn:allowedValues>
  </dmn:itemDefinition>


is not reflected in the generated json schema:
"some_number": {
      "type": "number",
      "x-dmn-type": "DMNType{ https://kiegroup.org/dmn/_C334EEAE-08D0-419A-98A2-5AF5BF3D649C : some_number }"
    },

I'm not sure if this is the intended behavior and if so is there another mechanism that I could use to "extract" the allowed value ranges for a given input data-type?

Many thanks for the great great work!


Jozef Marko

unread,
Jan 5, 2021, 3:19:58 AM1/5/21
to kogito-de...@googlegroups.com
Hi Amit, thank you for bringing this to my attention. I used kogito-examples/dmn-quarkus-example and tried to restrict Fine Amount to be a positive number. Then in the generated dmnDefinitions.json was such information [1] available, but seems as not appropriate place/formatting. Someone more experienced in this area could confirm if this can be solved by a Jira.

[1]
"tFine_Amount": {
  "type": "number",
  "x-dmn-type": "FEEL:number\n[>=0]"
},

--
You received this message because you are subscribed to the Google Groups "Kogito development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/609ead7c-abbe-42fa-b222-d73d7b7d3624n%40googlegroups.com.


--
Regards, Jozef
RHBA Quality Engineer

Matteo Mortari

unread,
Jan 12, 2021, 5:34:06 AM1/12/21
to Kogito development mailing list
Hi Amit, Jozef,
thank you for reporting.

I'm enhancing the current OAS productions for multiple use-cases of FEEL:number(s), with https://issues.redhat.com/browse/DROOLS-5943

In short:
  • wherever possible the extended OAS attribute: x-dmn-allowed-values has been added

    and
  • where possible the equivalent of the ItemDefinition allowed values has been projected on the OAS number range definitions.
Hope this helps,
MM

Amit Mor

unread,
Jan 12, 2021, 7:24:39 AM1/12/21
to kogito-de...@googlegroups.com
This is subsubzero cool. Thanks. The responsiveness of the Kogito team is superb and makes me feel, as an architect, that I’ve picked the right tool for my team and company who are going to rely heavily on Kogito. 

You received this message because you are subscribed to a topic in the Google Groups "Kogito development mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kogito-development/9p_hoIelr5E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kogito-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kogito-development/CAHOoiEoPs-Pu%3DYLgSwseZ64HmDEXMk0toW2wrr0o61xdCjYaqg%40mail.gmail.com.
--
All the best,
Amit Mor
Reply all
Reply to author
Forward
0 new messages