Search in sources :

Example 1 with RestLiJSONDocumentationRenderer

use of com.linkedin.restli.docgen.RestLiJSONDocumentationRenderer in project rest.li by linkedin.

the class TestCustomDocumentationHandler method initClass.

@BeforeClass
public void initClass() throws Exception {
    RestLiConfig config = new RestLiConfig();
    config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler() {

        @Override
        protected RestLiDocumentationRenderer getJsonDocumentationRenderer(DataSchemaResolver schemaResolver, RestLiResourceRelationship relationships) {
            return new RestLiJSONDocumentationRenderer(relationships) {

                @Override
                public void renderDataModel(NamedDataSchema schema, DataMap output, Map<String, String> requestHeaders) throws IOException {
                    super.renderDataModel(schema, output, requestHeaders);
                    DataMap schemaData = _codec.stringToMap(schema.toString());
                    String customName = schema.getFullName() + CUSTOM_SUFFIX;
                    schemaData.put("name", customName);
                    output.put(customName, schemaData);
                }
            };
        }
    });
    super.init(false, config);
}
Also used : NamedDataSchema(com.linkedin.data.schema.NamedDataSchema) RestLiJSONDocumentationRenderer(com.linkedin.restli.docgen.RestLiJSONDocumentationRenderer) DataSchemaResolver(com.linkedin.data.schema.DataSchemaResolver) DefaultDocumentationRequestHandler(com.linkedin.restli.docgen.DefaultDocumentationRequestHandler) RestLiResourceRelationship(com.linkedin.restli.docgen.RestLiResourceRelationship) IOException(java.io.IOException) RestLiDocumentationRenderer(com.linkedin.restli.docgen.RestLiDocumentationRenderer) RestLiConfig(com.linkedin.restli.server.RestLiConfig) DataMap(com.linkedin.data.DataMap) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

DataMap (com.linkedin.data.DataMap)1 DataSchemaResolver (com.linkedin.data.schema.DataSchemaResolver)1 NamedDataSchema (com.linkedin.data.schema.NamedDataSchema)1 DefaultDocumentationRequestHandler (com.linkedin.restli.docgen.DefaultDocumentationRequestHandler)1 RestLiDocumentationRenderer (com.linkedin.restli.docgen.RestLiDocumentationRenderer)1 RestLiJSONDocumentationRenderer (com.linkedin.restli.docgen.RestLiJSONDocumentationRenderer)1 RestLiResourceRelationship (com.linkedin.restli.docgen.RestLiResourceRelationship)1 RestLiConfig (com.linkedin.restli.server.RestLiConfig)1 IOException (java.io.IOException)1 BeforeClass (org.testng.annotations.BeforeClass)1