Search in sources :

Example 1 with GFinderListener

use of org.raml.jaxrs.generator.GFinderListener in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method finder.

private Map<String, GType> finder(String raml) {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new InputStreamReader(this.getClass().getResourceAsStream(raml)), ".");
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
            System.out.println(validationResult.getMessage());
        }
        throw new AssertionError();
    } else {
        final Map<String, GType> decls = new HashMap<>();
        new V10Finder(null, ramlModelResult.getApiV10()).findTypes(new GFinderListener() {

            @Override
            public void newTypeDeclaration(GType type) {
                decls.put(type.name(), type);
            }
        });
        return decls;
    }
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) GFinderListener(org.raml.jaxrs.generator.GFinderListener) InputStreamReader(java.io.InputStreamReader) RamlModelBuilder(org.raml.v2.api.RamlModelBuilder) HashMap(java.util.HashMap) RamlModelResult(org.raml.v2.api.RamlModelResult) ValidationResult(org.raml.v2.api.model.common.ValidationResult)

Aggregations

InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 GFinderListener (org.raml.jaxrs.generator.GFinderListener)1 GType (org.raml.jaxrs.generator.ramltypes.GType)1 RamlModelBuilder (org.raml.v2.api.RamlModelBuilder)1 RamlModelResult (org.raml.v2.api.RamlModelResult)1 ValidationResult (org.raml.v2.api.model.common.ValidationResult)1