Example usage for org.springframework.data.rest.webmvc.json JsonSchema JsonSchema

List of usage examples for org.springframework.data.rest.webmvc.json JsonSchema JsonSchema

Introduction

In this page you can find the example usage for org.springframework.data.rest.webmvc.json JsonSchema JsonSchema.

Prototype

public JsonSchema(String title, String description, Collection<AbstractJsonSchemaProperty<?>> properties,
        Definitions definitions) 

Source Link

Document

Creates a new JsonSchema instance for the given title, description, AbstractJsonSchemaProperty s and Definitions .

Usage

From source file:org.springframework.data.rest.webmvc.json.PersistentEntityToJsonSchemaConverter.java

@Override
public JsonSchema convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {

    final PersistentEntity<?, ?> persistentEntity = entities.getPersistentEntity((Class<?>) source);
    final ResourceMetadata metadata = associations.getMappings().getMetadataFor(persistentEntity.getType());

    Definitions definitions = new Definitions();
    List<AbstractJsonSchemaProperty<?>> propertiesFor = getPropertiesFor(persistentEntity.getType(), metadata,
            definitions);/* w w w .  ja v a  2s. c  o m*/

    String title = resolveMessageWithDefault(new ResolvableType(persistentEntity.getType()));

    return new JsonSchema(title, resolveMessage(metadata.getItemResourceDescription()), propertiesFor,
            definitions);
}