raml-js-parser-2 icon indicating copy to clipboard operation
raml-js-parser-2 copied to clipboard

`Types` is not an alias of `schemas`

Open wdullaer opened this issue 8 years ago • 2 comments

The description of the top level schemas key says that it is a deprecated alias for the new types key. This means that I would expect the types key to be present if the raml file contains a schemas key.

This is not the case in the output of raml2obj / raml-js-parser right now (you get one or the other).

Furthermore, the content of these keys is also not identical. schemas will return an array of objects:

"schemas": [
  {
    "myType": {
      "description": "some stuff",
      "name": "myType",
      "type": "actual json schema content"
    }
  }
]

types will return a map:

"types": {
  "myType": {
    "description": "some stuff",
    "name": "myType",
    "type": "json",
    "content": "actual json schema content"
  }
}

The content of an included json schema will also be in different properties of the objects depending on whether the top level key is schemas or types. I still need to try with inline schema definitions to see what the differences are there.

This means that I have to treat both keys seperately when rendering them in raml2html-slate-theme. Is there a reason for these differences, or can the structure be brought in line so that schemas really behaves like an alias of types?

I've moved this issue here from raml2html/raml2obj#42

wdullaer avatar Jul 26 '17 13:07 wdullaer

There should only be types or type in the final output! there shouldn't be schemas or schema. Agree.

sichvoge avatar Jul 26 '17 13:07 sichvoge

Note that raml-js-parser-2 has been deprecated, the new official parser is webapi-parser. Feel free to attempt to reproduce this issue with webapi-parser and report any issue you may have on that repository.

postatum avatar Sep 25 '19 09:09 postatum