0

Can you tell me how to set in RAML 1.0, if its even possible, multiple requests and its responses as examples. I have in anypoint studio 5 api's and I want to merge them into one. I wanted to merge all raml files but dont know how to do it. In every raml is only one post method with one request and one response. So, If I POST one request in ARC, I want to get appropriate response.

BorisM
  • 1
  • 1
  • Hi Boris. This question needs to be much much refined. It's not clear exactly what your requirement might be. From what I have understood, if all you have is so many RAML files each with one request body and a response example, attributed to a single post method, then you need to merge them using any editor of your choice; Notepad++ or Platform design center. Try using libraries or resources types in your master RAML for better readability and `DRY` https://en.m.wikipedia.org/wiki/Don%27t_repeat_yourself – Thinker-101 Oct 13 '20 at 10:49
  • I'll try to clear it. In anypoint studio I have five apis and five soap services. The purpose of all of them is same, just request/response examples are differente.Untill now, I was running in the same time one api and one soap. Now I want to merge them all somehow and to send one request and to receive appropriate response. Hope that was better. – BorisM Oct 13 '20 at 14:44
  • Use @Aled's answer for multiple examples ready to be referenced at multiple methods or resources for your requests and responses. What's still not clear is whether you have five different resources in these five APIs, or the same resource repeating everywhere.You can use named examples for just reference purposes at relevant places, but sending just one request and receiving an appropriate response can also be achieved by a single resource call ! That's what RAML do ! The only change you need for each unique request for THE RESOURCE is a change in request body, queryParams or uriParams. – Thinker-101 Oct 13 '20 at 17:18
  • It would be great if you can edit the question and put some snapshots of the idea. – Thinker-101 Oct 13 '20 at 17:24
  • Thanks for the effort so far. I'v got five different resources and I'd like to have only one now. If I send on http://localhost:8083/api/something request 1 to get response 1, if I send request 5 to get response 5 and so on. – BorisM Oct 14 '20 at 07:30
  • Since this is much specific to your need but does not relate with the title , I cannot put this in as an answer but still, consider this as an answer. There is something called as Round-Robin router, which needs to be done in your mule studio App rather than in RAML. What it does is to let you make the calls using to same URL every time without any change. But will return you different responses for each call you make. The responses you need must be separated for each route. Since you have 5 responses in total, you need 5 different Round-Robin routes.This will solve your problem.But not ideal. – Thinker-101 Oct 14 '20 at 17:54
  • You can also implement an object store which takes the count of each call you make and keep storing and incrementing the count value by 1. Send the relevant responses for each unique orderly calls by using some count-key value relationship. – Thinker-101 Oct 14 '20 at 18:07

1 Answers1

0

There is a guide to defines examples in the documentation.

For multiple examples you can use Named Examples with the examples: facet in RAML. Do confuse with example: which is for a single example. Named Examples require an identifier.

...
examples:
   MyExample1:
      ...
   AnotherExample:
      ...

You can just use the examples: facet to include the examples from another file.

aled
  • 21,330
  • 3
  • 27
  • 34
  • This is ok but If I send request 1 I want to get response 1, if I send request 4 to get response 4, not random. And to have only one resource. – BorisM Oct 14 '20 at 07:36
  • It's probably outside RAML scope to define that semantic. – aled Oct 14 '20 at 17:16