Search in sources :

Example 1 with DMNModelIOSets

use of org.kie.dmn.openapi.model.DMNModelIOSets in project droolsjbpm-integration by kiegroup.

the class OASGenerator method pathModelDSDMNResult.

private void pathModelDSDMNResult(OpenAPI openAPI, DMNModel dmnModel, DecisionService ds, DMNOASResult dmnoas) {
    final String description = "model decision service '" + ds.getName() + "' for structured DMNResult";
    DMNModelIOSets ioSets = dmnoas.lookupIOSetsByModel(dmnModel);
    DMNType identifyInputSet = ioSets.lookupDSIOSetsByName(ds.getName()).getDSInputSet();
    String inputRef = dmnoas.getNamingPolicy().getRef(identifyInputSet);
    Operation operation = buildOperationWithIORefs(description, inputRef, "#/components/schemas/" + MSConsts.MSDMNE_KOGITO_DMN_RESULT).summary(description).addTag(dmnModel.getName());
    PathItem pathItem = OASFactory.createObject(PathItem.class);
    pathItem.POST(operation);
    openAPI.getPaths().addPathItem("/server/containers/" + containerId + "/dmn/models/" + dmnModel.getName() + "/" + ds.getName() + "/dmnresult", pathItem);
}
Also used : DMNModelIOSets(org.kie.dmn.openapi.model.DMNModelIOSets) PathItem(org.eclipse.microprofile.openapi.models.PathItem) Operation(org.eclipse.microprofile.openapi.models.Operation) DMNType(org.kie.dmn.api.core.DMNType)

Example 2 with DMNModelIOSets

use of org.kie.dmn.openapi.model.DMNModelIOSets in project kogito-runtimes by kiegroup.

the class DecisionRestResourceGenerator method processOASAnn.

private void processOASAnn(MethodDeclaration dmnMethod, DecisionService ds) {
    String inputRef = null;
    String outputRef = null;
    if (withOASResult != null) {
        DMNModelIOSets ioSets = withOASResult.lookupIOSetsByModel(dmnModel);
        DMNType identifyInputSet = ds != null ? ioSets.lookupDSIOSetsByName(ds.getName()).getDSInputSet() : ioSets.getInputSet();
        DMNType identifyOutputSet = ds != null ? ioSets.lookupDSIOSetsByName(ds.getName()).getDSOutputSet() : ioSets.getOutputSet();
        inputRef = withOASResult.getNamingPolicy().getRef(identifyInputSet);
        outputRef = withOASResult.getNamingPolicy().getRef(identifyOutputSet);
    }
    final String DMN_DEFINITIONS_JSON = "/dmnDefinitions.json";
    // MP / Quarkus
    final String Q_CTX_PATH = context.getApplicationProperty("quarkus.http.root-path").filter(not("/"::equals)).orElse("");
    processAnnForRef(dmnMethod, "org.eclipse.microprofile.openapi.annotations.parameters.RequestBody", "org.eclipse.microprofile.openapi.annotations.media.Schema", Q_CTX_PATH + DMN_DEFINITIONS_JSON + inputRef, !mpAnnPresent);
    processAnnForRef(dmnMethod, "org.eclipse.microprofile.openapi.annotations.responses.APIResponse", "org.eclipse.microprofile.openapi.annotations.media.Schema", Q_CTX_PATH + DMN_DEFINITIONS_JSON + outputRef, !mpAnnPresent);
    // io.swagger / SB
    final String SB_CTX_PATH = context.getApplicationProperty("server.servlet.context-path").filter(not("/"::equals)).orElse("");
    processAnnForRef(dmnMethod, "io.swagger.v3.oas.annotations.parameters.RequestBody", "io.swagger.v3.oas.annotations.media.Schema", SB_CTX_PATH + DMN_DEFINITIONS_JSON + inputRef, !swaggerAnnPresent);
    processAnnForRef(dmnMethod, "io.swagger.v3.oas.annotations.responses.ApiResponse", "io.swagger.v3.oas.annotations.media.Schema", SB_CTX_PATH + DMN_DEFINITIONS_JSON + outputRef, !swaggerAnnPresent);
}
Also used : DMNModelIOSets(org.kie.dmn.openapi.model.DMNModelIOSets) DMNType(org.kie.dmn.api.core.DMNType)

Example 3 with DMNModelIOSets

use of org.kie.dmn.openapi.model.DMNModelIOSets in project drools by kiegroup.

the class DMNOASGeneratorImpl method indexModels.

private void indexModels() {
    for (DMNModel model : dmnModels) {
        DMNModelIOSets s = new DMNModelIOSets(model);
        ioSets.add(s);
        visitForIndexing(s);
    }
}
Also used : DMNModelIOSets(org.kie.dmn.openapi.model.DMNModelIOSets) DMNModel(org.kie.dmn.api.core.DMNModel)

Example 4 with DMNModelIOSets

use of org.kie.dmn.openapi.model.DMNModelIOSets in project drools by kiegroup.

the class DMNOASGeneratorImpl method assignNamesToIOSets.

private void assignNamesToIOSets() {
    for (int i = 0; i < ioSets.size(); i++) {
        DMNModelIOSets si = ioSets.get(i);
        si.setInputSetName(findUniqueNameUsing("InputSet", i + 1));
        si.setOutputSetName(findUniqueNameUsing("OutputSet", i + 1));
        int j = 1;
        for (DSIOSets ds : si.getDSIOSets()) {
            ds.setDSInputSetName(findUniqueNameUsing("InputSetDS" + j, i + 1));
            ds.setDSOutputSetName(findUniqueNameUsing("OutputSetDS" + j, i + 1));
            j++;
        }
    }
}
Also used : DMNModelIOSets(org.kie.dmn.openapi.model.DMNModelIOSets) DSIOSets(org.kie.dmn.openapi.model.DMNModelIOSets.DSIOSets)

Example 5 with DMNModelIOSets

use of org.kie.dmn.openapi.model.DMNModelIOSets in project droolsjbpm-integration by kiegroup.

the class OASGenerator method pathModelDMNResult.

private void pathModelDMNResult(OpenAPI openAPI, DMNModel dmnModel, DMNOASResult dmnoas) {
    final String description = "model evaluation for structured DMNResult";
    DMNModelIOSets ioSets = dmnoas.lookupIOSetsByModel(dmnModel);
    DMNType identifyInputSet = ioSets.getInputSet();
    String inputRef = dmnoas.getNamingPolicy().getRef(identifyInputSet);
    Operation operation = buildOperationWithIORefs(description, inputRef, "#/components/schemas/" + MSConsts.MSDMNE_KOGITO_DMN_RESULT).summary(description).addTag(dmnModel.getName());
    PathItem pathItem = OASFactory.createObject(PathItem.class);
    pathItem.POST(operation);
    openAPI.getPaths().addPathItem("/server/containers/" + containerId + "/dmn/models/" + dmnModel.getName() + "/dmnresult", pathItem);
}
Also used : DMNModelIOSets(org.kie.dmn.openapi.model.DMNModelIOSets) PathItem(org.eclipse.microprofile.openapi.models.PathItem) Operation(org.eclipse.microprofile.openapi.models.Operation) DMNType(org.kie.dmn.api.core.DMNType)

Aggregations

DMNModelIOSets (org.kie.dmn.openapi.model.DMNModelIOSets)7 DMNType (org.kie.dmn.api.core.DMNType)5 Operation (org.eclipse.microprofile.openapi.models.Operation)4 PathItem (org.eclipse.microprofile.openapi.models.PathItem)3 DMNModel (org.kie.dmn.api.core.DMNModel)1 DSIOSets (org.kie.dmn.openapi.model.DMNModelIOSets.DSIOSets)1