0
votes

I have a generated an apikit-router which routes to a raml file and generated an xml flows from it.

<when expression="message.inboundProperties.role == &quot;backoffice&quot;"> <apikit:router config-ref="backoffice-config" doc:name="Backoffice APIKit Router"/></when> ...

When I started the run the project, I receieved an error

org.mule.module.apikit.exception.ApikitRuntimeException: Invalid API descriptor -- errors found: 1 Raml parser uncaught exception: null

Now, my question is: Can someone explain to me what does this exception mean? I want to determine what causes the exception.

I tried to find documentations on this kind of exceptions and I haven't found a documentation for this(If there's one, please help me find the link).

[edited]

My RAML definition is just a mock for testing:

#%RAML 1.0
title: mocktest
mediaType: application/json

/mocktest:
  description: Describes a list of Employees.

  get:
    description: Request Body for a new Employee Post Request.
    responses: 
      200:
        description: OK Responsebody for a new EMployee POst Req.
        body: 
          application/json:
            example:  |
              {
              "employeeId":2231,
              "employeeName":"Lorem Ipsum"
              }

If this helps: I didn't add an http-listener to the apikit-router flow hence, In theory(mine) it will use the main HTTP-Listener to route on to the xml-generated flows from the RAML file.

Main Objective: Is to route a message depending by an inboundProperty whether its value is 'backoffice' or 'client', the reason the apikit-router is inside a choice sub-flow.

1
It is most likely an issue with your RAML file. Can you please modify your question to include it?Jason Estevan
I edited the question sir. Thank you for the response.AspiringProgrammer

1 Answers

0
votes

Ok I see what your trying to do, thanks for the extra information.

RAML is a "contract" for clients that want to use you're service. It lays out how to call your services; what are the endpoint addresses, what methods to use, what format should my request payload be. As well as what information is expected back. With all the information in the RAML file they should be able to integrate with your service without ever having to contact the developer.

MuleSoft has tightly integrated RAML into the API development cycle they would like you to follow. One aspect of this is the APIkit Router component. It automatically routes requests between the interface(your RAML file) and the backend flows, based on the HTTP request.

However in your scenario you are are adding a http endpoint and custom logic before the APIkit. These changes break the forced linking between the RAML file and your code. Notice that your custom flow takes in the inbound properties "role" but it isn't specified in the RAML file. Your client will not be aware that this property exists when onboarding to your service. Mulesoft wants to prevent this mismatch from happening and that is why you are getting the error.

I would recommend modifying your RAML file to be:

...
get:
    description: Request Body for a new Employee Post Request.
    queryParameters:
      role: 
    responses:
...

and your flows to be

<flow name="get:/mocktest:backoffice-config">
    <choice doc:name="Choice">
        <when expression="#[message.inboundProperties.role == 'backoffice']">..</when>
        <otherwise>...</otherwise>
    </choice>
</flow>

Hopefully that makes sense.