Java parser and Libraries


#1

Hi there.
i have a question about using libraries with the java parser.

In my main RAML file i have added some libraries for defining types and annotations.

uses:
  myTypes: types.raml
  annotation: annotations.raml

in the types.raml the first lines are:

#%RAML 1.0 Library
---
types:
  ResourceType:
...

If i parse the api.raml with the java parser (even with the 1.0.1-SNAPSHOT) i get no errors. But if i want to get a list of all types i get an empty list.

List<TypeDeclaration> types = apiV10.types();

Did i something wrong? Can anyone help?


#2

Maybe raise the issue on the java-parser repo on Github. There you have a high chance to get some help from the development team directly :wink:


#3

The uses in the API file is what you are looking for:

Api api = ramlModelResult.getApiV10();
api.uses().forEach(l -> {
  handleTypes(l.types());
}


   void handleTypes(List<TypeDeclaration> types) {
    types.forEach(t -> {
      ... do something here with it...
    });
  }
}

#4

Thanks, that helps a lot.