Closed pies closed 8 years ago
If you'd like to re-create the issue here's the directory structure:
item/item.raml
item/item.json
shared/shared.json
api.raml
Make it so that:
api.raml
!includes item/item.raml
item/item.raml
!includes item.json
item/item.json
references ../shared/shared.json
Hi Michał,
This is great - thank you. Are you able to write unit tests for it? Helps me to validate the change, and also prevents regressions in the future.
@alecsammon Here you go :)
This one took a bit of work.
RAML !include'd schemas are resolved simply by replacing their contents with contents of referenced files. JSON-Schema references, however are resolved by separate parsers which can rely on relative paths. For example, a RAML file may refer to
foo/bar.json
which in turn contains a reference to../baz.json
.foo/bar.json
needs no know that it's working fromfoo/
to know what to resolve../baz.json
into.The problem arises, however, when !included RAML files refer via to relative paths to JSON-Schema files that refer to relative paths. The JSON-Schema loader is being fed the directory the main RAML file was included from, instead of the path of the included RAML file the JSON schema is being referenced from.
This path fixes it in a somewhat crude way. I don't see a better way to do it without re-engineering how RAML references are resolved.