Open schmkr opened 9 years ago
Unfortunately this has been a long running issue with the JavaScript parser (https://github.com/raml-org/raml-js-parser/issues/115) and there's currently no solution available. This is something will definitely be fixed in future versions of the RAML specification itself.
Hi Alwin.
I have found that the most reliable way to make use of the $ref element (which, as Blake says, is not directly supported in RAML) is to use a single schema for all elements and to add a unique "id" element to each schema element. This appears to be the only guarantee currently of unambiguous addressing.
Is this a possibility for you?
Thanks Barbara, I'll give that a try.
I'm having a similar problem, when using a reference to the schema with the name. Assume you have the schemas included as follows
- player: !include schemas/player-schema.json
- team: !include schemas/team-schema.json
Then in player you have defined a property
"currentTeam": {
"$ref": "team",
"description": "Team the player is playing right now"
},
When running osprey-mock-service I get:
Unable to compile JSON schema for post /player: can't resolve reference team from id #
The problem is that we work with quite large RAML definitions and we definitely need to keep the schemas in different files.
Any idea how this can be adressed?
EDIT 2015-02-08: just figured out this is only happening when the schema is in the body for the request. Therefore affects mainly POST and PUT, when using a schema with a reference in the response, seems to be working OK
@dmalanij The $ref
implementation is specific to JSON schema. It doesn't resolve to RAML schemas, and doing so would be a change in the current specification (though, probably worth it honestly). Unfortunately it's impossible to really use $ref
property because of the limitations in the RAML 0.8 specification such as how to resolve JSON references (information which is currently lost from the parser output).
Is there any update on this? This is currently the only issue I have with the package.
Hi,
We're using this project for mocking api calls and we've set up json schemas with references to definitions in another file, like so:
schemas/authentication/login.json
schemas/definitions.json
When we run the
osprey-mock-service
these refered definitions seem not to do anything with the validation, whereas when we inline the type and pattern from thedefinitions.json
in thelogin.json
the validation does happen.Is there a way to make the
$ref
property work for the schemas?Thanks!