Search in sources :

Example 1 with TypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.TypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class AnnotationsTest method get.

@Test
public void get() throws Exception {
    TypeDeclaration type = buildType(this, "annotations.raml", 0);
    assertEquals("Allo", Annotations.CLASS_NAME.get(type));
}
Also used : TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Example 2 with TypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.TypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method shouldExtendingAnotherMultipleInheritance.

@Test
public void shouldExtendingAnotherMultipleInheritance() throws Exception {
    Map<String, GType> finder = finder("extendObjectMultipleIneritance.raml");
    ObjectTypeDeclaration object = (ObjectTypeDeclaration) finder.get("ObjectOne").implementation();
    TypeDeclaration extending = findProperty(object, "name");
    ObjectTypeDeclaration extended = (ObjectTypeDeclaration) finder.get(extending.type());
    assertTrue(TypeUtils.shouldCreateNewClass(extending, extended));
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Example 3 with TypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.TypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class TypeUtilsTest method shouldExtendingAnother.

@Test
public void shouldExtendingAnother() throws Exception {
    Map<String, GType> finder = finder("extendingAnother.raml");
    ObjectTypeDeclaration object = (ObjectTypeDeclaration) finder.get("ObjectOne").implementation();
    TypeDeclaration extending = findProperty(object, "name");
    ObjectTypeDeclaration extended = (ObjectTypeDeclaration) finder.get(extending.type()).implementation();
    assertFalse(TypeUtils.shouldCreateNewClass(extending, extended));
}
Also used : GType(org.raml.jaxrs.generator.ramltypes.GType) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) ObjectTypeDeclaration(org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration) TypeDeclaration(org.raml.v2.api.model.v10.datamodel.TypeDeclaration) Test(org.junit.Test)

Example 4 with TypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.TypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class V10Finder method typesInBodies.

private void typesInBodies(Resource resource, Method method, List<TypeDeclaration> body, GFinderListener listener) {
    for (TypeDeclaration typeDeclaration : body) {
        if (!isInline(typeDeclaration)) {
            continue;
        }
        V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, typeDeclaration), Names.javaTypeName(resource, method, typeDeclaration), typeDeclaration);
        listener.newTypeDeclaration(type);
    }
    for (TypeDeclaration parameterTypeDeclaration : method.queryParameters()) {
        if (!isInline(parameterTypeDeclaration)) {
            continue;
        }
        V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, parameterTypeDeclaration), Names.javaTypeName(resource, method, parameterTypeDeclaration), parameterTypeDeclaration);
        listener.newTypeDeclaration(type);
    }
    for (TypeDeclaration headerType : method.headers()) {
        if (!isInline(headerType)) {
            continue;
        }
        V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, headerType), Names.javaTypeName(resource, method, headerType), headerType);
        listener.newTypeDeclaration(type);
    }
    for (Response response : method.responses()) {
        for (TypeDeclaration typeDeclaration : response.body()) {
            if (!isInline(typeDeclaration)) {
                continue;
            }
            V10GType type = createInlineFromResourcesAndSuch(Names.ramlTypeName(resource, method, response, typeDeclaration), Names.javaTypeName(resource, method, response, typeDeclaration), typeDeclaration);
            listener.newTypeDeclaration(type);
        }
    }
}
Also used : Response(org.raml.v2.api.model.v10.bodies.Response)

Example 5 with TypeDeclaration

use of org.raml.v2.api.model.v10.datamodel.TypeDeclaration in project raml-for-jax-rs by mulesoft-labs.

the class V10Finder method goThroughLibraries.

private void goThroughLibraries(Set<String> visitedLibraries, List<Library> libraries, GFinderListener listener) {
    for (Library library : libraries) {
        if (visitedLibraries.contains(library.name())) {
            continue;
        } else {
            visitedLibraries.add(library.name());
        }
        goThroughLibraries(visitedLibraries, library.uses(), listener);
        for (TypeDeclaration typeDeclaration : library.types()) {
            V10GType type = createTypeFromLibraryPart(typeDeclaration);
            listener.newTypeDeclaration(type);
        }
    }
}
Also used : Library(org.raml.v2.api.model.v10.api.Library)

Aggregations

TypeDeclaration (org.raml.v2.api.model.v10.datamodel.TypeDeclaration)9 Test (org.junit.Test)8 ObjectTypeDeclaration (org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration)8 GType (org.raml.jaxrs.generator.ramltypes.GType)4 TypeName (com.squareup.javapoet.TypeName)2 V10RamlToPojoGType (org.raml.jaxrs.generator.v10.types.V10RamlToPojoGType)2 JSONTypeDeclaration (org.raml.v2.api.model.v10.datamodel.JSONTypeDeclaration)2 XMLTypeDeclaration (org.raml.v2.api.model.v10.datamodel.XMLTypeDeclaration)2 BodyLike (org.raml.v2.api.model.v08.bodies.BodyLike)1 Response (org.raml.v2.api.model.v08.bodies.Response)1 Library (org.raml.v2.api.model.v10.api.Library)1 Response (org.raml.v2.api.model.v10.bodies.Response)1 FileTypeDeclaration (org.raml.v2.api.model.v10.datamodel.FileTypeDeclaration)1 Method (org.raml.v2.api.model.v10.methods.Method)1 Resource (org.raml.v2.api.model.v10.resources.Resource)1