Reuse schema, but pass different string


#1

I created a json file named failedExample, it is like {“ok”:false, “message”…}. But I want to reuse the schema in every resource since they have same for format except the message.
For example

400:
body:
application/json:
example: |
<<\exampleFailure>>
422:
body:
application/json:
example: |
<<\exampleFailure>>
But I want something like
400:
body:
application/json:
example: |
<<\exampleFailure>>({message:‘ip doesn’t exist’})
422:
body:
application/json:
example: |
<<\exampleFailure>>({message:‘wrong …’})

any idea??


#2

I am not entirely sure what you are asking? You are showing an example which I assume you are hard coding in your RAML. Are you using the schemas: array at the top of the RAML file to give your schema an alias that you are then reusing in the <<\exampleFailure>>?? You say the name of the json file is failedExample, but I dont see it referenced in your example, so I am assuming the <<\exampleFailure>> is supposed to be something like !include pathToJSON/failedExample.json ?? If so, what you want to do is use the schema: !include pathToJSON/failedExample.json in the application/json: section.

I am also not clear on your message issue. Sorry, its not make much sense what you are listing.