Search in sources :

Example 1 with RamlModelResult

use of org.raml.v2.api.RamlModelResult in project raml-module-builder by folio-org.

the class JsonSchemaPojoUtil method getSchemasFromRaml.

public static List<GlobalSchema> getSchemasFromRaml(File path2Raml) {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(path2Raml.getAbsolutePath());
    // get a list of schemas from the raml
    List<GlobalSchema> schemaListInRAML = ramlModelResult.getApiV08().schemas();
    return schemaListInRAML;
}
Also used : RamlModelBuilder(org.raml.v2.api.RamlModelBuilder) GlobalSchema(org.raml.v2.api.model.v08.api.GlobalSchema) RamlModelResult(org.raml.v2.api.RamlModelResult)

Example 2 with RamlModelResult

use of org.raml.v2.api.RamlModelResult in project raml-for-jax-rs by mulesoft-labs.

the class JustLoadTest method justLoad.

@Test
public void justLoad() throws URISyntaxException {
    /*
     * RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new
     * File(JustLoadTest.class.getResource("/jaxrs-test-resources.raml").toURI()));
     */
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new File("target/generated-sources/raml-jaxrs/jaxrs-test-resources.raml"));
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
            System.out.println(validationResult.getMessage());
        }
        fail("Cant load");
    }
    Api api = ramlModelResult.getApiV10();
/*
     * Api api = ramlModelResult.getApiV10(); ObjectTypeDeclaration otd = (ObjectTypeDeclaration) api.types().get(0);
     * ArrayTypeDeclaration atd = (ArrayTypeDeclaration) otd.properties().get(0); ObjectTypeDeclaration arrayItems =
     * (ObjectTypeDeclaration) atd.items(); System.err.println(arrayItems.type());
     */
}
Also used : RamlModelBuilder(org.raml.v2.api.RamlModelBuilder) Api(org.raml.v2.api.model.v10.api.Api) RamlModelResult(org.raml.v2.api.RamlModelResult) ValidationResult(org.raml.v2.api.model.common.ValidationResult) File(java.io.File) Test(org.junit.Test)

Example 3 with RamlModelResult

use of org.raml.v2.api.RamlModelResult 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

RamlModelBuilder (org.raml.v2.api.RamlModelBuilder)3 RamlModelResult (org.raml.v2.api.RamlModelResult)3 ValidationResult (org.raml.v2.api.model.common.ValidationResult)2 File (java.io.File)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 GFinderListener (org.raml.jaxrs.generator.GFinderListener)1 GType (org.raml.jaxrs.generator.ramltypes.GType)1 GlobalSchema (org.raml.v2.api.model.v08.api.GlobalSchema)1 Api (org.raml.v2.api.model.v10.api.Api)1