frankframework / frankframework

The Frank!Framework is an easy-to-use, stateless integration framework which allows (transactional) messages to be modified and exchanged between different systems.
https://frankframework.org
Apache License 2.0
130 stars 78 forks source link

OpenAPi specification does not pick up the response xsd to create the output schema in the content #1706

Closed jjansenvr closed 1 month ago

jjansenvr commented 3 years ago

Describe the issue OpenAPi specification does not pickup the response xsd to create the output schema in the content {}

This adapter has two output validators, 1 for the normal and 1 for the error response, this might be the cause of this problem?

Reporter Jeroen Jansen van Rosendaal

To Reproduce Steps to reproduce the behavior:

  1. Go to the webservices menu and find the openapi spec for the adapter
  2. Scroll down to the respose and observe the empty content {} block

Screenshots openapi result snippit

"responses": {
"200": {
"description": "OK",
"content": {}
},
"304": {
"description": "Not Modified"
},
"400": {
"description": "Bad Request",
"content": {}
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Forbidden"
},
"500": {
"description": "Internal Server Error",
"content": {}
}
}

Configuration

    <Adapter name="FindDocuments(GET)" description="REST adapter for finding a document in the NN Archive and retrieving the metadata and link to the attachment." active="${active.FindDocuments_4_GET}">

        <Receiver name="FindDocuments_GET">
            <ApiListener name="FD_GET" uriPattern="archiving/documents" method="GET" produces="JSON" authenticationMethod="AUTHROLE" authenticationRoles="IbisWebService"/>
        </Receiver>

        <Pipeline firstPipe="Create_Request">

            <Json2XmlValidatorPipe name="Create_Request" schema="FindDocuments_GET_4/xsd/Archiving_Document_4_FindDocuments_1_GET.xsd" root="FindDocuments_Request" deepSearch="true">
                <Param name="schemaName" sessionKey="schemaName"/>
                <Param name="requestUserId" sessionKey="requestUserId"/>
                <Param name="includeMedicalDocuments" sessionKey="includeMedicalDocuments"/>
                <Param name="maxItems" sessionKey="maxItems" type="integer"/>
                <Param name="skipCount" sessionKey="skipCount"/>
                <Param name="sortAttribute" sessionKey="sortAttribute"/>
                <Param name="agreementNumber" sessionKey="agreementNumber"/>
                <Param name="agreementNumberType" sessionKey="agreementNumberType"/>
                <Param name="birthDate" sessionKey="birthDate"/>
                <Param name="claimNumber" sessionKey="claimNumber"/>
                <Param name="contractNumber" sessionKey="contractNumber"/>
                <Param name="descriptionProductGroup" sessionKey="descriptionProductGroup"/>
                <Param name="documentDetail" sessionKey="documentDetail"/>
                <Param name="documentRelationId" sessionKey="documentRelationId"/>
                <Param name="documentRouting" sessionKey="documentRouting"/>
                <Param name="documentTitle" sessionKey="documentTitle"/>
                <Param name="documentType" sessionKey="documentType"/>
                <Param name="externalDocumentId" sessionKey="externalDocumentId"/>
                <Param name="nameInsured" sessionKey="nameInsured"/>
                <Param name="namePolicyHolder" sessionKey="namePolicyHolder"/>
                <Param name="partnerGold" sessionKey="partnerGold"/>
                <Param name="partnerIntermediary" sessionKey="partnerIntermediary"/>
                <Param name="partnerSilver" sessionKey="partnerSilver"/>
                <Param name="quotationNumber" sessionKey="quotationNumber"/>
                <Param name="VTA_ID" sessionKey="VTA_ID"/>
                <Param name="year" sessionKey="year"/>
                <Param name="archiveDateBegin" sessionKey="archiveDateBegin"/>
                <Param name="archiveDateEnd" sessionKey="archiveDateEnd"/>
                <Param name="issuedDateBegin" sessionKey="issuedDateBegin"/>
                <Param name="issuedDateEnd" sessionKey="issuedDateEnd"/>
                <Param name="referenceDateBegin" sessionKey="referenceDateBegin"/>
                <Param name="referenceDateEnd" sessionKey="referenceDateEnd"/>

                <Forward name="success" path="Build_query"/>
                <Forward name="parserError" path="NotWellFormed"/>
                <Forward name="illegalRoot" path="IllegalRoot"/>
                <Forward name="failure" path="InvalidXml"/>
            </Json2XmlValidatorPipe>

            <XsltPipe name="Build_query" styleSheetName="FindDocuments_GET_4/xsl/TransformRequest.xsl">

                <Forward name="success" path="Call CMIS Find"/>
            </XsltPipe>

            <!-- use the NPA active for retrieving only documents with documentStatus Actief -->
            <pipe name="Call CMIS Find" className="nl.nn.adapterframework.pipes.GenericMessageSendingPipe" active="${active.cmis}" storeResultInSessionKey="CMIS_Output">
                <sender className="nl.nn.adapterframework.extensions.cmis.CmisSender" name="callCmisFind" url="${cmis.titan.url}" repository="${cmis.titan_nn.repository}" action="find" bindingType="${cmis.titan.bindingtype}" useRootFolder="false" maxConnections="${titan.cmis.maxConnections}" username="${cmis.titan.user}" password="${cmis.titan.password}" authAlias="${cmis.titan.active.authalias}">
                </sender>

                <forward name="success" path="Transform_Response"/>
                <forward name="timeout" path="ServerError"/>
                <forward name="illegalResult" path="ServerError"/>
                <forward name="exception" path="Error:ReturnSealError"/>
            </pipe>

            <XsltPipe name="Transform_Response" getInputFromSessionKey="CMIS_Output" styleSheetName="FindDocuments_GET_4/xsl/TransformResponse.xsl" skipEmptyTags="true">
                <Param name="skipCount" sessionKey="skipCount"/>

                <Forward name="success" path="Response_To_Json"/>
            </XsltPipe>

            <Json2XmlValidatorPipe name="Response_To_Json" outputFormat="json" schema="FindDocuments_GET_4/xsd/Archiving_Document_4_FindDocuments_1_GET.xsd" root="FindDocuments_Response">

                <Forward name="success" path="READY"/>
                <Forward name="failure" path="ServerError"/>
                <Forward name="exception" path="ServerError"/>
            </Json2XmlValidatorPipe>

    <!-- Error handling -->

            <PutParametersInSessionPipe name="Error:ReturnSealError">
                <Param name="errorCode" value="500"/>
                <Param name="errorReason" value="Document not found"/>
                <Param name="errorDetailCode" value="ERR6999"/>
                <Param name="errorDetailText" sessionKey="CMIS_Output" xpathExpression="normalize-space(substring-after(errorMessage/@message, ': '))"/>

                <Forward name="success" path="createResponseError"/>
            </PutParametersInSessionPipe>

            <PutParametersInSessionPipe name="InvalidXml">
                <Param name="errorCode" value="400"/>
                <Param name="errorReason" value="INVALID_XML"/>
                <Param name="errorDetailsXml" sessionKey="xmlFailureReason"/>
                <Forward name="success" path="createResponseError"/>
            </PutParametersInSessionPipe>

            <PutParametersInSessionPipe name="IllegalRoot">
                <Param name="errorCode" value="400"/>
                <Param name="errorReason" value="ILLEGALROOT"/>
                <Param name="errorDetailsXml" sessionKey="xmlFailureReason"/>
                <Forward name="success" path="createResponseError"/>
            </PutParametersInSessionPipe>

            <PutParametersInSessionPipe name="NotWellFormed">
                <Param name="errorCode" value="400"/>
                <Param name="errorReason" value="NOT_WELL_FORMED_XML"/>
                <Param name="errorDetailsXml" sessionKey="xmlFailureReason"/>
                <Forward name="success" path="createResponseError"/>
            </PutParametersInSessionPipe>

            <XsltPipe name="createResponseError" styleSheetName="FindDocuments_GET_4/xsl/TransformErrorResponse.xsl" getInputFromFixedValue="&lt;FindDocuments_Response/&gt;">
                <Param name="errorCode" sessionKey="errorCode"/>
                <Param name="errorReason" sessionKey="errorReason"/>
                <Param name="errorDetailsXml" sessionKey="errorDetailsXml" type="domdoc"/>
                <Param name="errorDetailCode" sessionKey="errorDetailCode"/>
                <Param name="errorDetailText" sessionKey="errorDetailText"/>

                <Forward name="success" path="Response_To_Json_Error"/>
            </XsltPipe>

            <Json2XmlValidatorPipe name="Response_To_Json_Error" outputFormat="json" schema="FindDocuments_GET_4/xsd/Archiving_Document_4_FindDocuments_1_GET.xsd" root="FindDocuments_Response">

                <Forward name="success" path="BadRequest"/>
                <Forward name="failure" path="ServerError"/>
                <Forward name="exception" path="ServerError"/>
            </Json2XmlValidatorPipe>

            <Exit path="READY" state="success" code="200"/>
            <Exit path="NotModified" state="success" code="304" empty="true"/>
            <Exit path="BadRequest" state="error" code="400"/>
            <Exit path="NotAuthorized" state="error" code="401" empty="true"/>
            <Exit path="NotAllowed" state="error" code="403" empty="true"/>
            <Exit path="ServerError" state="error" code="500"/>

        </Pipeline>

    </Adapter>

Input

no input needed 

Environment

FF! 7.6-20201118.153744: Ibis4Titan 378-82d4bc8a-master
Running on srtzzapp0401.insim.biz using IBM WebSphere Application Server/8.5
Java Version: Java(TM) SE Runtime Environment (8.0.6.0 - pxa6480sr6-20191107_01(SR6))
Heap size: 994M, total JVM memory: 1536M
Free disk space: 9GB, total disk space: 10GB
Up since: 2021-03-25 10:46:17 (19d)

Additional Environment

Additional Context the xsd used in this adapter

Archiving_Document_4_FindDocuments_1_GET.zip

gvanbrakel commented 3 years ago

The problem is that the Json2XmlValidators that are used to convert the response messages are configured as a Pipe (Json2XmlValidatorPipe), and not as an OutputValidator (Json2XmlOutputValidator).

If configured as Json2XmlOutputValidator the two Pipes can be combined into a single OutputValidator. Also the first Pipe of this configuration, also a Json2XmlValidators, is preferably configured as a Json2XmlInputValidator

jjansenvr commented 3 years ago

Thanks, I sugested this aproach to Richard (before your comment) The only question is do we need to make this work or is documentation adding about this subject sufficient?

jjansenvr commented 7 months ago

nice to have