cybertk / abao

REST API automated testing tool based on RAML
MIT License
353 stars 59 forks source link

Add $ref support relative to CWD #165

Closed coltonlw closed 8 years ago

coltonlw commented 8 years ago

This PR adds support for automatically resolving $ref's in jsonschema.

URL $ref's are properly resolved, and relative file $ref's are resolved relative to the current working directory of the abao process.

Replaces PR #163

This does not properly resolve $ref's relative to the referring document, for that the RAML parser must pass the path of the schema file that was !included or the path to the RAML file for an inline schema. That path needs to be fed to the $ref parser as the starting resolution scope. In the future, the RAML parser could be updated to provide de-referencing as a feature so this functionality can work. In the meantime, this PR allows projects using relative file paths in $ref's to work with abao, as is not currently possible with --schemas option. The limitation is all $ref's which are relative $ref's must be relative to the working directory of abao. In the future it would be easy to add a --schema-dir command line option to allow setting this directory, instead of changing where the abao command runs. I still wanted to submit this PR because it is working and somewhat useful. Thanks @plroebuck and @cybertk for your time on this issue and I look forward to your feedback!

coltonlw commented 8 years ago

I'm going to close this because I think people relying on the current behavior of --schemas might have an issue where the ref parser will try to load those $ref's from files. I'm going to add the --schema-dir argument and make the addition ref parsing behavior optional and enabled only by this argument. I will also add some tests.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.2%) to 88.825% when pulling fcaa3531d7f612e6eacd2c9da89fdadfd4c7e382 on flywheel-io:better-jsonschema-ref into 04a4d3011746ab33fca8291f834e543a4759b92a on cybertk:master.