Search in sources :

Example 1 with NullDocsProvider

use of com.linkedin.restli.internal.server.model.ResourceModelEncoder.NullDocsProvider in project rest.li by linkedin.

the class ResourceSchemaCollection method loadOrCreateResourceSchema.

/**
 * For each given {@link ResourceModel}, the classpath is checked for a .restspec.json
 * matching the name of the {@link ResourceModel},  if found it is loaded.  If a .restspec.json file
 * is not found, one is created {@link ResourceSchemaCollection} from specified root {@link ResourceModel}.
 * All resources will be recursively traversed to discover subresources.
 * Root resources not specified are excluded.
 *
 * @param rootResources root resources in ResourceModel type
 * @return constructed ResourceSchemaCollection
 */
public static ResourceSchemaCollection loadOrCreateResourceSchema(Map<String, ResourceModel> rootResources) {
    final ResourceModelEncoder encoder = new ResourceModelEncoder(new NullDocsProvider());
    final Map<String, ResourceSchema> schemaMap = new TreeMap<>();
    for (ResourceModel resource : rootResources.values()) {
        schemaMap.put(resource.getName(), encoder.loadOrBuildResourceSchema(resource));
    }
    return new ResourceSchemaCollection(schemaMap, rootResources);
}
Also used : ResourceSchema(com.linkedin.restli.restspec.ResourceSchema) ResourceModelEncoder(com.linkedin.restli.internal.server.model.ResourceModelEncoder) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) TreeMap(java.util.TreeMap) NullDocsProvider(com.linkedin.restli.internal.server.model.ResourceModelEncoder.NullDocsProvider)

Aggregations

ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)1 ResourceModelEncoder (com.linkedin.restli.internal.server.model.ResourceModelEncoder)1 NullDocsProvider (com.linkedin.restli.internal.server.model.ResourceModelEncoder.NullDocsProvider)1 ResourceSchema (com.linkedin.restli.restspec.ResourceSchema)1 TreeMap (java.util.TreeMap)1