Package org.raml.model

Examples of org.raml.model.Raml


    public void includeSequence()
    {
        String ramlSource = "org/raml/include/include-sequence.yaml";
        List<ValidationResult> validationResults = validateRaml(ramlSource);
        assertThat(validationResults.size(), is(0));
        Raml raml = parseRaml(ramlSource);

        assertThat(raml.getResources().get("/main").getAction(POST).getBody().get("application/json").getSchema(), is("main"));
        assertThat(raml.getSchemas().get(0).get("main"), containsString("employeeId"));

        assertThat(raml.getResource("/main").getAction(GET).getQueryParameters().size(), is(2));
        assertThat(raml.getResource("/main").getAction(GET).getQueryParameters().get("offset").getType(), is(INTEGER));
        assertThat(raml.getResource("/main").getAction(GET).getQueryParameters().get("limit").getType(), is(INTEGER));
        assertThat(raml.getResource("/main").getAction(GET).getHeaders().get("security").getType(), is(BOOLEAN));

        assertThat(raml.getResource("/main").getAction(PUT).getResponses().containsKey("204"), is(true));
        assertThat(raml.getResource("/main").getAction(PUT).getBody().containsKey("text/xml"), is(true));

    }
View Full Code Here


    {
        String ramlSource = "org/raml/include/include-sequence-mapping.yaml";
        List<ValidationResult> validationResults = validateRaml(ramlSource);
        assertThat(validationResults.size(), is(0));

        Raml raml = parseRaml(ramlSource);
        assertThat(raml.getResource("/main").getAction(GET).getQueryParameters().size(), is(2));
        assertThat(raml.getResource("/main").getAction(GET).getHeaders().size(), is(1));
    }
View Full Code Here

{

    @Test
    public void basicConfig()
    {
        Raml raml = parseRaml("org/raml/root-elements.yaml");

        assertThat(raml.getTitle(), is("Sample API"));
        assertThat(raml.getVersion(), is("v1"));
        assertThat(raml.getBaseUri(), is("https://sample.com/api"));

        assertThat(raml.getResources().size(), is(1));
        Resource mediaResource = raml.getResources().get("/media");
        assertThat(mediaResource.getActions().size(), is(1));
        assertThat(mediaResource.getAction(ActionType.GET), is(Action.class));
    }
View Full Code Here

    @Test
    public void absoluteClasspath()
    {
        String location = "org/raml/include/include-main-absolute-classpath.yaml";
        Raml raml = parseRaml(location);
        assertThat(raml.getResource("/main/absolute").getDescription(), is("absolute"));
        assertThat(raml.getResource("/main/absolute/relative").getDescription(), is("relative"));
    }
View Full Code Here

    @Test
    public void emitter()
    {
        RamlDocumentBuilder builder1 = new RamlDocumentBuilder();
        Raml raml1 = parseRaml(ramlSource, builder1);
        String emitted1 = YamlDocumentBuilder.dumpFromAst(builder1.getRootNode());

        RamlDocumentBuilder builder2 = new RamlDocumentBuilder();
        Raml raml2 = builder2.build(emitted1, "");

        assertThat(raml2.getResources().get("/simple").getActions().size(),
                   is(raml1.getResources().get("/simple").getActions().size()));
    }
View Full Code Here

    @Test
    public void customResolver()
    {
        RamlDocumentBuilder builder = new RamlDocumentBuilder(new DefaultResourceLoader(), new CustomTagResolver());
        Raml raml = parseRaml(RAML, builder);
        assertThat(raml.getTitle(), is("custom tag resolved"));
        assertThat(raml.getResources().get("/media").getAction(PUT).getBody().get("application/raml").getSchema(), is("custom tag resolved"));
    }
View Full Code Here

    @Test
    public void include()
    {
        RamlDocumentBuilder builder = new RamlDocumentBuilder(new DefaultResourceLoader(), new CustomTagResolver());
        Raml raml = parseRaml(RAML, builder);
        assertThat(raml.getResources().get("/file").getAction(PUT).getBody().get("application/json").getSchema(), containsString("file-json"));
    }
View Full Code Here

    }

    @Test
    public void namelessResources()
    {
        Raml raml = parseRaml(RAML);
        Map<String, Resource> namelessChildren = raml.getResource("/nameless-children").getResources();
        assertThat(namelessChildren.get("/").getRelativeUri(), is("/"));
        assertThat(namelessChildren.get("/").getUri(), is("/nameless-children/"));
        assertThat(namelessChildren.get("/").getResources().get("/").getRelativeUri(), is("/"));
        assertThat(namelessChildren.get("/").getResources().get("/").getUri(), is("/nameless-children//"));
        assertThat(raml.getResource("/nameless-children//").getRelativeUri(), is("/"));
    }
View Full Code Here

    }

    @Test
    public void namelessRootResources()
    {
        Raml raml = parseRaml(RAML);
        assertThat(raml.getResource("/").getRelativeUri(), is("/"));
        assertThat(raml.getResource("//named").getRelativeUri(), is("/named"));
        assertThat(raml.getResource("//named/").getRelativeUri(), is("/"));
        assertThat(raml.getResource("//named//").getRelativeUri(), is("/"));
        assertThat(raml.getResource("//named///named").getRelativeUri(), is("/named"));
    }
View Full Code Here

    }

    @Test
    public void resourceLikeBaseUriPath()
    {
        Raml raml = parseRaml(RAML);
        Resource resource = raml.getResource("/apis");
        assertThat(resource.getRelativeUri(), is("/apis"));
    }
View Full Code Here

TOP

Related Classes of org.raml.model.Raml

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.