Closed xaka closed 8 years ago
Should we not try to use the same structure for both or is this on purpose? cc' @svacas @KonstantinSviridov
IMO resource type references should be serialized like the examples below, no need to serialize the referenced resource type. If the referenced resource type does not exist, or is declared more than once that should be reported as an error (the same logic applies to traits and security schemes)
/no-param:
type: one
"type": "one"
/with-param:
type:
two:
param: hi
"type": {
"two": {
"param": "hi"
}
}
Ok, the formats are as follows:
Current TCK JSON:
{
"methods": [
{ method object1 },
{ method object2 },
]
}
Old JS Praser: in resource types:
{
"methodName1": {
method object
},
"methodName2": {
method object
},
}
At the same time the Old JS parsers serializes methods of resources just the same way, as in TCK JSON:
{
"methods": [
{ method object1 },
{ method object2 },
]
}
Thus, in case of resource, the old JS parser output contains all methods as elements of "methods" array, while in case of resource type it directly reflects YAML content. As I understand, the reason is that resource type YAML node can contain subnodes under parametrized keys, and one can not determine type of such nodes.
For TCK I would use a special field for children under parametrized keys, and I would continue serializing methods into an array. For example, serialize
get:
responses:
200:
<<updateMethod>>:
body:
application/json:
as
{
methods:[{
method: get
responses: {
200:{}
}
}],
underParametrizedKeys:{
<<updateMethod>>: {
body: {
application/json: {}
}
}
}
}
But let's take approach of the old JS parser, if we have to be compatible with it.
RAML 0.8:
RAML 1.0: