SwaggerUI for DMN-SpringBoot-Example

27 views
Skip to first unread message

Ravi Mangalagiri

unread,
Oct 27, 2020, 6:51:41 PM10/27/20
to Kogito development mailing list
I built a demo application based on DMN-SpringBoot-Example. The pom generates openapi.json in target>classes>static folder and I see it.

I am not able to get Swagger-UI working for this project. I tried a couple of things but had no luck. I know this is not the forum for this question. But just checking if there is an example out there.

Thanks
Ravi Mangalagiri
703-505-4240 (c)

Matteo Mortari

unread,
Oct 28, 2020, 4:55:48 AM10/28/20
to Kogito development mailing list
Hi Ravi,
personally I just like to use the SmallRye openapi project for these tooling, normally I drop the openapi-ui dependency as part of my project I am working on.

I gave it a shot with the vanilla dmn-springboot-example and works correctly as attached screenshot.

You will need to access via URL: http://localhost:8080/docs/openapi-ui/index.html
and then navigate to the swagger/oas definition in the upper textfield as: /docs/swagger.json
and click the Explore button.

If that works on your side as you expect, you might want to consider experimenting also with this other SmallRye project: https://github.com/smallrye/smallrye-open-api/tree/master/ui/open-api-ui-forms#demo
As it could be very helpful when making quick demo of Kogito/DMN; just remember to make it point to /docs/swagger.json when used on SpringBoot.

Very personal experience, and just FYI, I found however the integration of openapi stuff in general when using Quarkus is way easier ;) ;)
I know I might sound biased of course, but as you pointed out yourself this is something not strictly Kogito-specific/related, so I thought it worth sharing a relatable experience :)

I hope this is of interest,
MM


--
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/CALg%3DC8MRRfbGKkbk8hD-CD6CdULrKqXrgtiTsnXSAsc2Vy7QDA%40mail.gmail.com.
Screenshot 2020-10-28 at 09.44.28.png

Ravi Mangalagiri

unread,
Oct 28, 2020, 10:57:25 AM10/28/20
to Kogito development mailing list
Matteo,
Can you share the dmn-springboot-example with smallrye ui please.



--
Ravi Mangalagiri
703-505-4240 (c)

Matteo Mortari

unread,
Oct 28, 2020, 11:21:23 AM10/28/20
to Kogito development mailing list
Hi Ravi,

gets this additional dependency: 
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-open-api-ui</artifactId>
<version>2.0.13</version>
<scope>runtime</scope>
</dependency>

please bear in mind I always go using the "master" branch.

Hope this helps?
MM

Ravi Mangalagiri

unread,
Oct 28, 2020, 11:38:09 AM10/28/20
to Kogito development mailing list
I followed the steps and got the following error.





Screen Shot 2020-10-28 at 11.34.58 AM.png

Matteo Mortari

unread,
Oct 28, 2020, 12:04:02 PM10/28/20
to Kogito development mailing list
Hi Ravi,
I am pretty sure, based on the content of your screenshot, and comparing that to my screenshot and instructions,

that you missed the prefix / in front of the URL for the swagger json file

/docs/swagger.json

with the prefixed / of /docs

Hope this solves for you?
MM

Ravi Mangalagiri

unread,
Oct 28, 2020, 12:12:42 PM10/28/20
to Kogito development mailing list

Matteo Mortari

unread,
Oct 28, 2020, 12:16:25 PM10/28/20
to Kogito development mailing list
Hi Ravi

That was definitely a problem that needed the correction,

I previously stated
> please bear in mind I always go using the "master" branch.

I believe the swagger/oas generator for DMN is not even on Kogito v0.17

Hope this helps,
MM

Ravi Mangalagiri

unread,
Oct 28, 2020, 12:26:10 PM10/28/20
to Kogito development mailing list
Got it. What is the repo I need to clone to build kogito locally?

Greatly Appreciated your support!

Matteo Mortari

unread,
Oct 28, 2020, 12:36:12 PM10/28/20
to Kogito development mailing list
Hi Ravi,

you might try by adding these lines to your application pom.xml directly to benefit of automatic snapshot resolution: https://github.com/kiegroup/kogito-examples/blob/6ba6e80691fe419dc82a39b38d26bda3a3d15f26/pom.xml#L96-L131

Alternatively, I usually have cloned this: https://github.com/kiegroup/kogito-runtimes
and I build locally with `mvn clean install -DskipTests`
any further pointer is on that repo readme

Hope this helps,
MM

Ravi Mangalagiri

unread,
Oct 28, 2020, 1:02:01 PM10/28/20
to Kogito development mailing list
I am on kogito 0.17.0-SNAPSHOT and still have the same error. 


Matteo Mortari

unread,
Oct 28, 2020, 1:20:26 PM10/28/20
to Kogito development mailing list
Hi Ravi,

unless I missed something, Kogito "master" is 1.0.0-SNAPSHOT: https://github.com/kiegroup/kogito-runtimes/blob/master/pom.xml#L15

Hope that helps,
MM

Ravi Mangalagiri

unread,
Oct 28, 2020, 2:00:09 PM10/28/20
to Kogito development mailing list
I think I will stop here. There seems to be some issue and needs to be fixed. 

image.png



Matteo Mortari

unread,
Oct 28, 2020, 2:18:30 PM10/28/20
to Kogito development mailing list
This stacktrace actually is very interesting!

I'm investigating...

MM

Matteo Mortari

unread,
Oct 29, 2020, 1:07:02 PM10/29/20
to Kogito development mailing list
Hi Ravi,
thank you for reporting the stacktrace!
It helped identify a bug which is being corrected with: https://github.com/kiegroup/drools/pull/3197

I am making an improvement on Kogito codegen which would cover a case like yours: https://github.com/kiegroup/kogito-runtimes/pull/861#issue-512423250
However, if the user-project customizes the swagger/OAS location beyond the conventions, it would imply the end-user also is responsible to adjust eventually via scaffolding.

Bringing in both code changes, it seems to me it would produce the expected result as attached screenshot.

I hope this helps,
MM
Screenshot 2020-10-29 at 17.54.45.png

Ravi Mangalagiri

unread,
Oct 29, 2020, 1:09:40 PM10/29/20
to Kogito development mailing list
Thanks Matteo

Can I try now with the snapshot?

Matteo Mortari

unread,
Oct 29, 2020, 1:12:43 PM10/29/20
to Kogito development mailing list
Hi Ravi,
no the PRs are not merged yet, and even when they will be merged they could only be tried locally by bringing them in by manual versioning.

I would suggest waiting for the next Kogito release is the easiest.

MM

Ravi Mangalagiri

unread,
Oct 29, 2020, 1:18:15 PM10/29/20
to Kogito development mailing list

Ravi Mangalagiri

unread,
Oct 29, 2020, 8:13:00 PM10/29/20
to Kogito development mailing list
Can you also make sure that it works when we turn the below property

kogito.decisions.stronglytyped=true

Matteo Mortari

unread,
Oct 30, 2020, 3:31:19 AM10/30/20
to Kogito development mailing list
Hi Ravi,
The stronglytyped is an experimental feature, so unless you gain the very specific benefit from it, I would always leave it per default (disabled).

Based on your current code base, you don't need it.

That said, the feature of swagger/OAS generation is orthogonal and meant to always be active; in other words it works regardless the status of stronglytyped enabled or disabled.

If you are eventually planning to experiment work on (currently not released) Kogito programmatic API, beyond REST calls, then yes you might benefits from stronglytyped and as mentioned it will work orthogonally to swagger/OAS.

I hope this clarifies,
MM

Ravi Mangalagiri

unread,
Oct 30, 2020, 10:15:24 AM10/30/20
to Kogito development mailing list
I am curious how the openapi.json would look when 'stronglytyped' is enabled. The way model pojo models generated, for example

configuration.dmn  | namespace : com.37decisions.dmnDemo.common
Pojo : com.37decisions.dmnDemo.common.InputSet

assetCalculatiuons.dmn | namespace : com.37decision.dmnDemo.mortgageCalc | includesModel: configuration.dmn
Pojo : com.37decisions.dmnDemo.mortgageCalc.InputSet

I am not sure how the openapi spec will look for both of these endpoints? I think if I am not mistaken openapi spec expects InputSet to be of only one package structure. Curious to know how scaffolding code is solving the problem....



Matteo Mortari

unread,
Oct 30, 2020, 12:25:06 PM10/30/20
to Kogito development mailing list
Hi Ravi,
I'm not sure I understand your question?

As I said, the openapi "contract" will be the same, since the swagger/OAS generation feature is orthogonal, independent to strongtlytyped experimental feature.

So from a JSON payload perspective, you would send exactly the same payload.
  • In a default case, the internals of the engine will make sure the JSON is unmarshalled for proper execution on the DMN engine.
  • If stronglytyped experimental feature is enabled, the unmarshalling is done by Jackson under the hood.

The openapi spec would look exactly the same because it is defined programmatically, regardless of strongtlytyped experimental feature setting.

I hope this clarifies,
MM
Reply all
Reply to author
Forward
0 new messages