#665 - Make sure Alps API stays compatible.
Tweaked the changes made to Alps and Descriptor builders so that they only affect the representation rendered by Jackson, not the actual API.
This commit is contained in:
@@ -24,6 +24,7 @@ import org.springframework.hateoas.alps.Descriptor.DescriptorBuilder;
|
||||
import org.springframework.hateoas.alps.Doc.DocBuilder;
|
||||
import org.springframework.hateoas.alps.Ext.ExtBuilder;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
@@ -37,12 +38,12 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
*/
|
||||
@Value
|
||||
@Builder(builderMethodName = "alps")
|
||||
@JsonPropertyOrder({"version", "doc", "descriptor"})
|
||||
@JsonPropertyOrder({ "version", "doc", "descriptor" })
|
||||
public class Alps {
|
||||
|
||||
private final String version = "1.0";
|
||||
private final Doc doc;
|
||||
private final List<Descriptor> descriptor;
|
||||
private final @JsonProperty("descriptor") List<Descriptor> descriptors;
|
||||
|
||||
/**
|
||||
* Returns a new {@link DescriptorBuilder}.
|
||||
|
||||
@@ -20,6 +20,7 @@ import lombok.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
@@ -32,7 +33,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
*/
|
||||
@Value
|
||||
@Builder
|
||||
@JsonPropertyOrder({"id", "href", "name", "type", "doc", "descriptor", "ext"})
|
||||
@JsonPropertyOrder({ "id", "href", "name", "type", "doc", "descriptor", "ext" })
|
||||
public class Descriptor {
|
||||
|
||||
private final String id, href, name;
|
||||
@@ -40,5 +41,5 @@ public class Descriptor {
|
||||
private final Type type;
|
||||
private final Ext ext;
|
||||
private final String rt;
|
||||
private final List<Descriptor> descriptor;
|
||||
private final @JsonProperty("descriptor") List<Descriptor> descriptors;
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ public class JacksonSerializationTest {
|
||||
|
||||
Alps alps = alps().//
|
||||
doc(doc().href("http://example.org/samples/full/doc.html").build()). //
|
||||
descriptor(Arrays.asList(//
|
||||
descriptors(Arrays.asList(//
|
||||
descriptor().id("search").type(Type.SAFE).//
|
||||
doc(new Doc("A search form with two inputs.", Format.TEXT)).//
|
||||
descriptor(Arrays.asList( //
|
||||
descriptors(Arrays.asList( //
|
||||
descriptor().href("#resultType").build(), //
|
||||
descriptor().id("value").name("search").type(Type.SEMANTIC).build())//
|
||||
).build(), //
|
||||
|
||||
Reference in New Issue
Block a user