Search in sources :

Example 1 with RestMethodSchema

use of com.linkedin.restli.restspec.RestMethodSchema in project rest.li by linkedin.

the class RestLiHTMLDocumentationRenderer method getDoc.

private String getDoc(Object method, boolean isSimpleResourceMethod) {
    String doc = null;
    if (method instanceof RestMethodSchema) {
        final RestMethodSchema restMethodSchema = (RestMethodSchema) method;
        doc = restMethodSchema.getDoc();
        if (// if no javadoc is supplied, fallback to generic doc string
        doc == null || doc.trim().length() == 0) {
            if (isSimpleResourceMethod) {
                doc = _restMethodDocsMapForSimpleResource.get(restMethodSchema.getMethod());
            } else {
                doc = _restMethodDocsMapForCollection.get(restMethodSchema.getMethod());
            }
            if (doc == null) {
                log.warn(String.format("No doc string for REST method %s", doc));
            }
        }
    }
    return doc;
}
Also used : RestMethodSchema(com.linkedin.restli.restspec.RestMethodSchema)

Example 2 with RestMethodSchema

use of com.linkedin.restli.restspec.RestMethodSchema in project rest.li by linkedin.

the class SnapshotGenerator method findModelsCollection.

private void findModelsCollection(ResourceSchema resourceSchema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder) {
    CollectionSchema collection = resourceSchema.getCollection();
    if (collection != null) {
        IdentifierSchema identifier = collection.getIdentifier();
        findModelsIdentifier(identifier, foundTypes, typeOrder);
        if (collection.hasFinders()) {
            for (FinderSchema restMethodSchema : collection.getFinders()) {
                findModelsFinder(restMethodSchema, foundTypes, typeOrder);
            }
        }
        if (collection.hasMethods()) {
            for (RestMethodSchema restMethodSchema : collection.getMethods()) {
                findModelsMethod(restMethodSchema, foundTypes, typeOrder);
            }
        }
        if (collection.hasActions()) {
            for (ActionSchema actionSchema : collection.getActions()) {
                findModelsAction(actionSchema, foundTypes, typeOrder);
            }
        }
        if (collection.hasEntity()) {
            EntitySchema entity = collection.getEntity();
            findModelsEntity(entity, foundTypes, typeOrder);
        }
    }
}
Also used : CollectionSchema(com.linkedin.restli.restspec.CollectionSchema) IdentifierSchema(com.linkedin.restli.restspec.IdentifierSchema) RestMethodSchema(com.linkedin.restli.restspec.RestMethodSchema) FinderSchema(com.linkedin.restli.restspec.FinderSchema) EntitySchema(com.linkedin.restli.restspec.EntitySchema) ActionSchema(com.linkedin.restli.restspec.ActionSchema)

Example 3 with RestMethodSchema

use of com.linkedin.restli.restspec.RestMethodSchema in project rest.li by linkedin.

the class ResourceModelEncoder method createRestMethods.

private RestMethodSchemaArray createRestMethods(final ResourceModel resourceModel) {
    RestMethodSchemaArray restMethods = new RestMethodSchemaArray();
    ResourceMethod[] crudMethods = { ResourceMethod.CREATE, ResourceMethod.GET, ResourceMethod.UPDATE, ResourceMethod.PARTIAL_UPDATE, ResourceMethod.DELETE, ResourceMethod.BATCH_CREATE, ResourceMethod.BATCH_GET, ResourceMethod.BATCH_UPDATE, ResourceMethod.BATCH_PARTIAL_UPDATE, ResourceMethod.BATCH_DELETE, ResourceMethod.GET_ALL };
    for (ResourceMethod method : crudMethods) {
        ResourceMethodDescriptor descriptor = resourceModel.findMethod(method);
        if (descriptor == null) {
            continue;
        }
        RestMethodSchema restMethod = new RestMethodSchema();
        restMethod.setMethod(method.toString());
        String doc = _docsProvider.getMethodDoc(descriptor.getMethod());
        if (doc != null) {
            restMethod.setDoc(doc);
        }
        ParameterSchemaArray parameters = createParameters(descriptor);
        if (parameters.size() > 0) {
            restMethod.setParameters(parameters);
        }
        final DataMap customAnnotation = descriptor.getCustomAnnotationData();
        String deprecatedDoc = _docsProvider.getMethodDeprecatedTag(descriptor.getMethod());
        if (deprecatedDoc != null) {
            customAnnotation.put(DEPRECATED_ANNOTATION_NAME, deprecateDocToAnnotationMap(deprecatedDoc));
        }
        if (!customAnnotation.isEmpty()) {
            restMethod.setAnnotations(new CustomAnnotationContentSchemaMap(customAnnotation));
        }
        if (method == ResourceMethod.GET_ALL && descriptor.isPagingSupported()) {
            restMethod.setPagingSupported(true);
        }
        restMethods.add(restMethod);
    }
    return restMethods;
}
Also used : RestMethodSchemaArray(com.linkedin.restli.restspec.RestMethodSchemaArray) RestMethodSchema(com.linkedin.restli.restspec.RestMethodSchema) ParameterSchemaArray(com.linkedin.restli.restspec.ParameterSchemaArray) CustomAnnotationContentSchemaMap(com.linkedin.restli.restspec.CustomAnnotationContentSchemaMap) ResourceMethod(com.linkedin.restli.common.ResourceMethod) DataMap(com.linkedin.data.DataMap)

Example 4 with RestMethodSchema

use of com.linkedin.restli.restspec.RestMethodSchema in project rest.li by linkedin.

the class SnapshotGenerator method findModelsAssocation.

private void findModelsAssocation(ResourceSchema resourceSchema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder) {
    AssociationSchema association = resourceSchema.getAssociation();
    if (association != null) {
        for (AssocKeySchema assocKeySchema : association.getAssocKeys()) {
            String type = assocKeySchema.getType();
            recordType(type, foundTypes, typeOrder);
        }
        if (association.hasFinders()) {
            for (FinderSchema restMethodSchema : association.getFinders()) {
                findModelsFinder(restMethodSchema, foundTypes, typeOrder);
            }
        }
        if (association.hasMethods()) {
            for (RestMethodSchema restMethodSchema : association.getMethods()) {
                findModelsMethod(restMethodSchema, foundTypes, typeOrder);
            }
        }
        if (association.hasActions()) {
            for (ActionSchema actionSchema : association.getActions()) {
                findModelsAction(actionSchema, foundTypes, typeOrder);
            }
        }
        if (association.hasEntity()) {
            EntitySchema entitySchema = association.getEntity();
            findModelsEntity(entitySchema, foundTypes, typeOrder);
        }
    }
}
Also used : AssociationSchema(com.linkedin.restli.restspec.AssociationSchema) RestMethodSchema(com.linkedin.restli.restspec.RestMethodSchema) FinderSchema(com.linkedin.restli.restspec.FinderSchema) EntitySchema(com.linkedin.restli.restspec.EntitySchema) ActionSchema(com.linkedin.restli.restspec.ActionSchema) AssocKeySchema(com.linkedin.restli.restspec.AssocKeySchema)

Example 5 with RestMethodSchema

use of com.linkedin.restli.restspec.RestMethodSchema in project rest.li by linkedin.

the class SnapshotGenerator method findModelsSimple.

private void findModelsSimple(ResourceSchema resourceSchema, Map<String, NamedDataSchema> foundTypes, List<NamedDataSchema> typeOrder) {
    SimpleSchema simple = resourceSchema.getSimple();
    if (simple != null) {
        if (simple.hasMethods()) {
            for (RestMethodSchema restMethodSchema : simple.getMethods()) {
                findModelsMethod(restMethodSchema, foundTypes, typeOrder);
            }
        }
        if (simple.hasActions()) {
            for (ActionSchema actionSchema : simple.getActions()) {
                findModelsAction(actionSchema, foundTypes, typeOrder);
            }
        }
        if (simple.hasEntity()) {
            EntitySchema entity = simple.getEntity();
            findModelsEntity(entity, foundTypes, typeOrder);
        }
    }
}
Also used : SimpleSchema(com.linkedin.restli.restspec.SimpleSchema) RestMethodSchema(com.linkedin.restli.restspec.RestMethodSchema) EntitySchema(com.linkedin.restli.restspec.EntitySchema) ActionSchema(com.linkedin.restli.restspec.ActionSchema)

Aggregations

RestMethodSchema (com.linkedin.restli.restspec.RestMethodSchema)10 ActionSchema (com.linkedin.restli.restspec.ActionSchema)4 DataMap (com.linkedin.data.DataMap)3 ResourceMethod (com.linkedin.restli.common.ResourceMethod)3 EntitySchema (com.linkedin.restli.restspec.EntitySchema)3 FinderSchema (com.linkedin.restli.restspec.FinderSchema)3 AssociationSchema (com.linkedin.restli.restspec.AssociationSchema)2 CollectionSchema (com.linkedin.restli.restspec.CollectionSchema)2 ParameterSchemaArray (com.linkedin.restli.restspec.ParameterSchemaArray)2 RestMethodSchemaArray (com.linkedin.restli.restspec.RestMethodSchemaArray)2 SimpleSchema (com.linkedin.restli.restspec.SimpleSchema)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 RecordTemplate (com.linkedin.data.template.RecordTemplate)1 ExampleRequestResponse (com.linkedin.restli.docgen.examplegen.ExampleRequestResponse)1 ExampleRequestResponseGenerator (com.linkedin.restli.docgen.examplegen.ExampleRequestResponseGenerator)1 RestLiInternalException (com.linkedin.restli.internal.server.RestLiInternalException)1 AssocKeySchema (com.linkedin.restli.restspec.AssocKeySchema)1 CustomAnnotationContentSchemaMap (com.linkedin.restli.restspec.CustomAnnotationContentSchemaMap)1