Can anyone please suggest/correct me here on how to get APIkit Router working with baseUriParameter
. If the path in the HTTP Listener Connector is hardcoded like /api/process/30001/*
, it all works fine. APIKit Router is able to route the requested resource path. But, when there is a placeholder in the HTTP Listener Connector path like /api/process/{clientID}/*
, an error is thrown at APIkit Router as No resource found
.
From the stacktrace below, I could see that the request resource path is truncated, for example, /sample
becomes just ple
and I couldn't find the reason why. Through debugging, I could see the complete request URI. Image from debug mode to see the complete request path.
I have tried a few other options like:
- Checking 'keep raml base uri' in router config
- Unchecking box 'parse Request' in Advanced tab of HTTP Listener Connector
I have checked through this, too, to be sure that my RAML conform with raml-template-uris and uriparams.
I found this in the MuleSoft docs:
In API Gateway Runtime 2.x and earlier, APIkit is designed to work very tightly with RAML interfaces, but does not automatically import the following items from the RAML definition:
securitySchemes
protocols
baseUriParameters
So, how do I import baseUriParameters
? How do I make it work?
I've been stuck with this issue for quite a long time, so any help is greatly appreciated. Please correct me if I missed something. Thanks a lot!
#%RAML 1.0
title: Test API
baseUri: /api/process/{clientID}
baseUriParameters:
clientID:
type: number
example: 300001
/sample:
get:
responses:
200:
body:
application/json:
flow:
<http:listener-config xmlns:http="http://www.mulesoft.org/schema/mule/http" name="baseuriprameter-apikit-httpListenerConfig" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration" />
<apikit:config xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" name="baseuriprameter-apikit-config" raml="baseuriprameter-apikit.raml" consoleEnabled="false" doc:name="Router" keepRamlBaseUri="false"/>
<flow name="baseuriprameter-apikit-main">
<http:listener xmlns:http="http://www.mulesoft.org/schema/mule/http" config-ref="baseuriprameter-apikit-httpListenerConfig" path="/api/process/{clientID}/*" doc:name="HTTP" parseRequest="false"/>
<apikit:router xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" config-ref="baseuriprameter-apikit-config" doc:name="APIkit Router"/>
<exception-strategy ref="baseuriprameter-apikit-apiKitGlobalExceptionMapping" doc:name="Reference Exception Strategy"/>
</flow>
<flow name="baseuriprameter-apikit-console">
<http:listener xmlns:http="http://www.mulesoft.org/schema/mule/http" config-ref="baseuriprameter-apikit-httpListenerConfig" path="/console/*" doc:name="HTTP" parseRequest="false"/>
<apikit:console xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" config-ref="baseuriprameter-apikit-config" doc:name="APIkit Console"/>
</flow>
<flow name="get:/sample:baseuriprameter-apikit-config">
<set-payload value="Hello World!" doc:name="Set Payload"/>
</flow>
stacktrace:
WARN 2018-06-11 19:52:27,452 [[baseuriprameter-apikit].baseuriprameter-
apikit-httpListenerConfig.worker.01] org.mule.module.apikit.Configuration:
No matching patterns for URI ple
ERROR 2018-06-11 19:52:28,082 [[baseuriprameter-apikit].baseuriprameter-
apikit-httpListenerConfig.worker.01]
org.mule.module.apikit.MappingExceptionListener:
**************************************************
Message : ple
Payload : {NullPayload}
Payload Type : org.mule.transport.NullPayload
Element : /baseuriprameter-apikit-main/processors/0 @
baseuriprameter-apikit:baseuriprameter-apikit.xml:11 (APIkit Router)
Element XML : <apikit:router
xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" config-
ref="baseuriprameter-apikit-config" doc:name="APIkit Router">
</apikit:router>
--------------------------------------------------------
Root Exception stack trace:
org.mule.module.apikit.exception.NotFoundException: ple
atorg.mule.module.apikit.AbstractConfiguration$2.load(AbstractConfiguration.java:178)atorg.mule.module.apikit.AbstractConfiguration$2.load(AbstractConfiguration.java:169)
atcom.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)atcom.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
atcom.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at org.mule.module.apikit.AbstractRouter.processRouterRequest(AbstractRouter.java:177)
at org.mule.module.apikit.AbstractRouter.processBlockingRequest(AbstractRouter.java:104)
at org.mule.module.apikit.AbstractRouter.processBlocking(AbstractRouter.java:98)