Swagger UI issue when context-path provided

1,626 views
Skip to first unread message

Ravi Mangalagiri

unread,
Jul 3, 2021, 4:56:30 PM7/3/21
to Kogito development mailing list
Hi All,
I am experimenting with Kogito 1.8.0.Final (springboot). 

When I define context-path in my application.properties file as shown below

server.servlet.context-path=/demo
kogito.service.url=http://localhost:8080/demo

I noticed that my Swagger UI is not able to get the schema or example payload.

For now the workaround is turn of the rest resource generation

kogito.generate.rest=false

and include kogito generated rest resource in my source and make the following change highlighted in yellow to get it to work
    @PostMapping(value = ""produces = MediaType.APPLICATION_JSON_VALUEconsumes = MediaType.APPLICATION_JSON_VALUE)
    @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @io.swagger.v3.oas.annotations.media.Content(mediaType = "application/json"schema = @io.swagger.v3.oas.annotations.media.Schema(ref = "/demo/dmnDefinitions.json#/definitions/InputSet1")), description = "DMN input")
    @io.swagger.v3.oas.annotations.responses.ApiResponse(content = @io.swagger.v3.oas.annotations.media.Content(mediaType = "application/json"schema = @io.swagger.v3.oas.annotations.media.Schema(ref = "/demo/dmnDefinitions.json#/definitions/OutputSet1")), description = "DMN output")
    public ResponseEntity<?dmn(@RequestBody(required = falsejava.util.Map<StringObjectvariables,
            HttpServletResponse httpResponse) {
        org.kie.kogito.decision.DecisionModel decision = application.get(org.kie.kogito.decision.DecisionModels.class)
                        "Traffic Violation");
        org.kie.dmn.api.core.DMNResult decisionResult = decision.evaluateAll(DMNJSONUtils.ctx(decisionvariables));
        enrichResponseHeaders(decisionResulthttpResponse);
        KogitoDMNResult result = new KogitoDMNResult(
                "https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF""Traffic Violation",
                decisionResult);
        return extractContextIfSucceded(result);
    }

Any thoughts?
--
Ravi Mangalagiri
703-505-4240 (c)

Matteo Mortari

unread,
Jul 5, 2021, 4:58:50 AM7/5/21
to Kogito development mailing list
Hi Ravi,

tracking this as https://issues.redhat.com/browse/KOGITO-5462 and a PR already on the way.

Thank you for reporting

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%3DC8Pn6a8g3Ob8H742YQTiwh8Q_S4euf%2Bv_qpn7y8e8yykeA%40mail.gmail.com.


--

francisco boato

unread,
May 3, 2022, 12:30:54 PM5/3/22
to Kogito development mailing list
Hello I'm using kogito (1.20) under spring-boot and i have the problem that swagger-ui "does not find" the file "dmnDefinitions.json" when i change the context-path using application.yaml.  
This problem is not present when using "application.properties format", but i cannot change the format of the file, the standard used in my company states that yaml format have to be used.
Is there any workaround for this situation?
Greetings,
Francisco.

Matteo Mortari

unread,
May 3, 2022, 12:36:50 PM5/3/22
to Kogito development mailing list
Hi Francisco,
could you provide and share a reproducer please?

Otherwise, the information mentioned in the jira ticket KOGITO-5462 of one year ago from our understanding solves the issue on both Quarkus and Spring Boot per the description there.

Let us know!

Thanks,
MM

francisco boato

unread,
May 4, 2022, 3:37:52 AM5/4/22
to Kogito development mailing list
Hi Matteo, the error can be reproduced in the  "dmn-springboot-example" project,  you just have to replace the  "application.properties" file with the "application.yaml" file attached,
Then, after running the application using "mvn clean spring-boot:run" and accessing the swagger page it came the error shown in the other attached file.
application.yaml
2022-05-04 09_33_41-Swagger UI – Mozilla Firefox.png

Matteo Mortari

unread,
May 4, 2022, 5:37:46 AM5/4/22
to Kogito development mailing list
Hi Francisco,
my assessment is that Kogito, in general, does not support in codegen the Spring's yaml as configuration format.

I checked and I don't think we serve any test (in kogito-runtimes) or example (in kogito-examples) of using Spring's yaml format for configuration of Kogito on Spring Boot.


Consequently, any Kogito codegen extension has no visibility on Spring configuration provided as yaml format.

where context, is the org.kie.kogito.codegen.api.context.KogitoBuildContext from the codegen infra.

In conclusion, it seems this is a general missing feature / potential gap of Kogito on Spring Boot.

I've raised this as a general feature request for Kogito, here: https://issues.redhat.com/browse/KOGITO-7085

As a workaround, you may try to transform your .yaml file into a .properties as part of the Maven build --this way you remain compliant with your requirement to use yaml, yet you serve the expected .properties file to the Kogito codegen infra. Wdyt ?

Hope this helps,
MM



Reply all
Reply to author
Forward
0 new messages