Skip to main content

Hi experts,

 

I have designed a RAML spec that has endpoint URLs like below:

 

/test/app/ - get all app details

/test/app?id={id} - get app details based on id

/test/app?start_date={start_date}&end_date={end_date} - get app details based on id creation date range

 

I have defined Query parameters in the RAML like below:

id - required - false (optional)

start_date - required - false (optional)

end_date - required - false (optional)

 

I have 2 questions:

1) Requirement is -

When start_date will be put then end_date is also mandatory.

When id will be put , start_date and end_date should not be added.

How to make this dependency in the RAML. What is the syntax for this?

 

2) My client wants client_id and client_secret to be put to access this RAML.

How to define this security scheme in the RAML. What is the syntax?

4 risposte
  1. 4 ott 2018, 21:30

    @apudas15021990 "I have 2 questions - 1) Requirement is - When start_date will be put then end_date is also mandatory. When id will be put , start_date and end_date should not be added. How to make this dependency in the RAML. What is the syntax for this?"

     

    Put all these parameters as optional in RAML, and put all these logic in your Mule flow. RAML is not for your business implementation, it's a specification of your API structure that defines how your API looks like, how many resources will be there or what are the parameters or what will be your method format for each resource(GET, POST) etc.

     

    But all the above logic and conditions should be in your mule flow. Use Mule Choice router to implement those.

     

    "2) My client wants client_id and client_secret to be put to access this raml. How to define this security scheme in the raml. What is the syntax?"

     

    `"access this raml"` I think it should be `"access these API"` instead

     

    There can be many types of security schemes you can implement in your API.

    If you are looking to implement Oauth2 security in your API, that can be mentioned in RAML, ref: https://forum.raml.org/t/oauth-2-0-spec-defined-in-raml/673

    or

    https://github.com/raml-org/raml-examples/blob/master/others/banking-api/securitySchemes/oauth2_0.raml

     

    There is also a policy available called `Client ID Enforcement Policy` which is another security scheme, which restrict the access of your API based on Client Id and secret. But in that case, it don't require to specify `client-id` or `client_secret` in RAML. It works even without mentioning that.

    But if you still want to design your RAML with `client-id` and `client_secret` , you can do something like this:

     

    traits:

    client-id-required:

    queryParameters:

    client_id:

    type: string

    client_secret:

    type: string

    /products:

    get:

    is: [client-id-required]

    description: Gets a list of all the inventory products.

0/9000