raml-java-parser
raml-java-parser copied to clipboard
ResourceType merge issue
Following RAML definition produces the errors below using the java parser:
#%RAML 1.0
---
title: Test
baseUri: https://example.com
version: v1
mediaType: application/json
types:
PagedQueryResponse: object
resourceTypes:
domainTemplate:
get:
responses:
200:
body:
type: <<templateType>>
/categories:
type: { domainTemplate: { templateType: PagedQueryResponse } }
displayName: Categories
description: Categories are used to organize products in a hierarchical structure.
get:
description: Query Categories
responses:
200:
body:
application/json:
example: {}
Errors:
Unexpected key 'type'. Options are : /([\w\d\.\-\_\+]+|\*)\/([\w\d\.\-\_\+]+|\*);?([\w\d\.\-\_\+]+=[\w\d\.\-\_\+]+)?(\s+[\w\d\.\-\_\+]+=[\w\d\.\-\_\+]+)*/ -- test.raml [line=15, col=15]
Unexpected key 'displayName'. Options are : /([\w\d\.\-\_\+]+|\*)\/([\w\d\.\-\_\+]+|\*);?([\w\d\.\-\_\+]+=[\w\d\.\-\_\+]+)?(\s+[\w\d\.\-\_\+]+=[\w\d\.\-\_\+]+)*/
The issue arises from the different response definitions styles. The resource type uses the statusCode -> body -> type pattern. The URI uses the statusCode -> body -> mediaType pattern.
Semantically they should be both the same especially as a default media has been specified.
Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-79