Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Problem Setting up OpenAPI

    We would like to use the OpenAPI support.
    However, i seem to be doing something wrong or overlooking something.

    I have added these lines to the server.properties:
    Code:
    openapi.info.version: 1.0.0
    openapi.info.title: sample REST API
    openapi.ds.whitelisted: v11
    The basic call to /restapi/openapi.yaml works but seems to output an example not present in the project:
    https://pastebin.com/raw/XrULt8kj

    When we call /restapi/v11.yaml we get an error:
    Code:
    java.lang.RuntimeException: java.util.NoSuchElementException
        at com.isomorphic.servlet.RESTHandler.processDocumentationRequest(RESTHandler.java:759)
        at com.isomorphic.servlet.RESTHandler.doGet(RESTHandler.java:494)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:178)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:750)
    Caused by: java.util.NoSuchElementException
        at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:721)
        at java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:747)
        at com.isomorphic.servlet.RESTHandler.processDocumentationRequest(RESTHandler.java:723)
        ... 25 more
    The following is logged on the server:
    Code:
    === 2022-11-30 15:53:32,671 [c-21] ERROR RESTHandler - DataSource 'v11' could not be loaded.
    java.lang.NullPointerException
        at java.net.URLEncoder.encode(URLEncoder.java:204)
        at com.isomorphic.openapi.SpecificationContextBuilder.buildOperationSpecs(SpecificationContextBuilder.java:352)
        at com.isomorphic.openapi.SpecificationContextBuilder.build(SpecificationContextBuilder.java:99)
        at com.isomorphic.servlet.RESTHandler.processDocumentationRequest(RESTHandler.java:673)
        at com.isomorphic.servlet.RESTHandler.doGet(RESTHandler.java:494)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:178)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:607)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:750)
    === 2022-11-30 15:53:32,672 [c-21] ERROR RESTHandler - BaseServlet Global Exception
    java.lang.RuntimeException: java.util.NoSuchElementException
        at com.isomorphic.servlet.RESTHandler.processDocumentationRequest(RESTHandler.java:759)
        at com.isomorphic.servlet.RESTHandler.doGet(RESTHandler.java:494)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
        at com.isomorphic.servlet.BaseServlet.service(BaseServlet.java:178)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:607)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:683)
        at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:750)
    Caused by: java.util.NoSuchElementException
        at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:721)
        at java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:747)
        at com.isomorphic.servlet.RESTHandler.processDocumentationRequest(RESTHandler.java:723)
        ... 25 more
    Is it because i have specified the openapi.servers.servletUrl setting incorrectly or not at all?
    The call to /restapi/v11 works without problems, so the DS can be loaded.

    This is what the example DataSource looks like:
    Code:
    <DataSource xmlns:fmt="WEB-INF/" tableName="v11" ID="v11" serverType="sql">
        <fmt:bundle basename="de.escrea.shared.util.EscreaConstants" encoding="utf-8" />
        <fields>
            <field primaryKey="true" hidden="true" name="id" type="sequence"></field>
            <field name="status" type="text">
                <title><fmt:message key="status"/></title>
            </field>
            <field name="fileName" type="text">
                <title><fmt:message key="fileName"/></title>
            </field>
            <field name="participantNumber" type="text">
                <title><fmt:message key="participantNumber"/></title>
            </field>
            <field name="amount" type="float">
                <title><fmt:message key="sum"/></title>
            </field>
            <field name="numberOfTransactions" type="integer">
                <title><fmt:message key="paymentsCount"/></title>
            </field>
            <field name="partial" type="integer" customSelectExpression="COALESCE((SELECT COUNT(*) FROM v11Transaction
                                                                        LEFT JOIN postingItem ON v11Transaction.postingItemId = postingItem.id
                                                                        LEFT JOIN payment ON payment.postingItemId = postingItem.id
                                                                        WHERE v11Transaction.v11Id = v11.id
                                                                        AND payment.cancelDate IS NULL), 0)" customSQL="true">
                <title><fmt:message key="incompleteNumber"/></title>
            </field>
            <field name="startDate" type="date">
                <title><fmt:message key="dateStart"/></title>
            </field>
            <field name="endDate" type="date">
                <title><fmt:message key="dateEnd"/></title>
            </field>
            <field name="creationDate" type="date">
                <title><fmt:message key="dateV11"/></title>
            </field>
        </fields>
    
        <operationBindings>
            <operationBinding operationType="fetch" operationId="assignV11">
                <serverObject className="de.escrea.server.BillingDMI" methodName="importV11" />
            </operationBinding>
            <operationBinding operationType="fetch">
                <customValueFields>partial</customValueFields>
                <customCriteriaFields>partial</customCriteriaFields>
                <orderClause>
                    #if($dsRequest.sortBy)
                        $defaultOrderClause, creationDate DESC
                    #else
                        creationDate DESC
                    #end
                </orderClause>
            </operationBinding>
        </operationBindings>
    </DataSource>
    Last edited by escrea; 30 Nov 2022, 08:24.

    #2
    Thanks for the detailed problem report. There's nothing wrong with your setup, but we do see what was causing your problem and have applied a patch to fix it in 13.x builds dated 2022-12-02 and later.

    Note that the unfamiliar example illustrates usage of the DataSource agnostic AdvancedREST protocol. Your actual project DataSources will be listed separately, and you should find that it works as you'd expect with the update.

    Comment


      #3
      Thank you very much for the super fast processing.
      I can confirm that everything is now working as expected.

      Comment

      Working...
      X