DATAREST-644 - Improvements to JSON Schema output.
Fixed JSON Schema output use "definitions" keyword instead of the previously used wrong "descriptors". We now also include the title attribute for properties, using rest.description.$type.$property._title as i18n key. Titles are now also defaulted to the camel-case property name split up, lowercased and capitalized, e.g. "orderDate" will become "Order date". JacksonMetadata now allows obtaining the Jackson serializer being used for a given type and exposes whether a property is considered read-only for Jackson. Introduced JsonSchemaPropertyCustomizer to potentially tweak the JSON schema property definition. This is helpful in case custom JsonSerializers are implemented to also reflect the change in representation in the schema.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Annotation to descibe semantics of a resource.
|
||||
* Annotation to describe semantics of a resource.
|
||||
*
|
||||
* @author Jon Brisbin
|
||||
* @author Oliver Gierke
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class SimpleResourceDescription extends ResolvableResourceDescriptionSupport {
|
||||
|
||||
protected static final String DEFAULT_KEY_PREFIX = "rest.description";
|
||||
public static final String DEFAULT_KEY_PREFIX = "rest.description";
|
||||
protected static final MediaType DEFAULT_MEDIA_TYPE = MediaType.TEXT_PLAIN;
|
||||
|
||||
private final String message;
|
||||
|
||||
@@ -47,9 +47,13 @@ public class TypedResourceDescription extends SimpleResourceDescription {
|
||||
}
|
||||
|
||||
public static ResourceDescription defaultFor(String rel, PersistentProperty<?> property) {
|
||||
return defaultFor(rel, property.getName(), property.getType());
|
||||
}
|
||||
|
||||
String message = String.format("%s.%s.%s", DEFAULT_KEY_PREFIX, rel, property.getName());
|
||||
return new TypedResourceDescription(message, DEFAULT_MEDIA_TYPE, property.getType());
|
||||
public static ResourceDescription defaultFor(String rel, String name, Class<?> type) {
|
||||
|
||||
String message = String.format("%s.%s.%s", DEFAULT_KEY_PREFIX, rel, name);
|
||||
return new TypedResourceDescription(message, DEFAULT_MEDIA_TYPE, type);
|
||||
}
|
||||
|
||||
public static ResourceDescription defaultFor(String rel, Class<?> type) {
|
||||
|
||||
Reference in New Issue
Block a user