Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 1.53 KB

File metadata and controls

25 lines (16 loc) · 1.53 KB

#Building API model from RAML

AML features common model on top of RAML 0.8 and RAML 1.0. This model is tightly binded to typesystem implementation located at TypeSystem

and is modeled by the following interfaces CommonInterfaces

This model is not and AST (this means that it is not possible to get back to orginal RAML text from it), and was primary built with a convinience of usage in a most common usecases (generating RAML from some other model, or analizying API or Library structure/types)

Building an API model is handled by org.aml.typesystem.yaml artifact and is as simple as following sample

Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"some.raml");

Key class here is TopLevelRamlModelBuilder

browsing model is as simple as

IProperty ps=build.getResource("/world/states/{stateId}").method("get").response("200").body("application/json").getTypeModel().toPropertiesView().property("abbr");
Pattern oneMeta = ps.range().oneMeta(Pattern.class);
ps=build.getResource("/world/states/{stateId}").method("put").body("application/json").getTypeModel().toPropertiesView().property("abbr");
		oneMeta = ps.range().oneMeta(Pattern.class);