raml-dotnet-tools icon indicating copy to clipboard operation
raml-dotnet-tools copied to clipboard

Does the tool support $ref to another json file?

Open oliu321 opened this issue 6 years ago • 3 comments

For example, if I have in the raml: { "type": "array" "items": { "$ref": "test.json" } }

Then it seems the code generated will not reference the test.json at all?

oliu321 avatar Dec 08 '17 13:12 oliu321

Hmm, I can see that the $ref is totally not supported, since in the RAML.Parse, it's trying to read every json in and if there is a $ref, it will be read in at that time, later on when RAML.Tools is trying to use Newtonsoft to generate schema, it will fail there. And the who RAML.Tools seem to be not taking the $ref into consideration, for example if 2 refs are pointing to the same place then we will better only generate 1 C# classes instead of 2.

oliu321 avatar Dec 14 '17 22:12 oliu321

Another similar problem is when the test.json referenced is also using $ref to another say base.json as well (makes things worse, if there is an test2.json referencing base.json/xxx and base.json is not in the raml file at all)

oliu321 avatar Dec 14 '17 22:12 oliu321

It does not support $ref from a json file to another json file. It does support $ref inside the same json, or to an external json, but that schema must be declared in "schemas" of the RAML, this is an example: https://github.com/mulesoft-labs/raml-dotnet-tools/blob/master/Raml.Tools.Tests/files/external-refs.raml In that example the schema is declared inline, but could also be an include to an external json file.

woodp avatar Dec 21 '17 13:12 woodp