raml-java-parser
raml-java-parser copied to clipboard
Should the default mediaType be taken into account for the validation of included library files ?
Affects 1.0.0
Issue
When using the example below, the parser fails with an "Invalid element {\ntype: myBody\n} error, because no mediaType is defined in the lib.raml file.
If the contents of the two files are merged, the parser works as expected.
Should the default mediaType declared in the api.raml file be taken into account when validating the content of the lib.raml file ?
How to reproduce
file api.ram
#%RAML 1.0
title: My API
mediaType: application/json
uses:
lib: lib.raml
/resource:
type: lib.collection
file lib.raml
#%RAML 1.0 Library
types:
myBody:
properties:
property: string
resourceTypes:
collection:
get:
responses:
200:
body:
type: myBody
Java File
import org.raml.v2.api.RamlModelBuilder;
import org.raml.v2.api.RamlModelResult;
public class Test {
@org.junit.Test
public void testRaml10Import() throws Exception {
String savedRamlLocation = Test.class.getResource("your/path/api.raml").toString();
RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(savedRamlLocation);
}
}
Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-117
IMH, it should work, because the API is valid, whatever how it was spread to several files or not. It seems that's a bug