From fed5f6c313657c42781c960e9d84eef3e7979442 Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Mon, 6 Nov 2017 15:58:39 -0600 Subject: [PATCH] #340 - Patch ALPS serialization property order. Side effect of upgrading Jackson appears to be arbitrary change in order of property serialization. This commit forces the order to match the spec and fixes the related test cases. --- src/main/java/org/springframework/hateoas/alps/Alps.java | 3 +++ .../resources/org/springframework/hateoas/alps/reference.json | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/springframework/hateoas/alps/Alps.java b/src/main/java/org/springframework/hateoas/alps/Alps.java index 9596222d..63b7e807 100644 --- a/src/main/java/org/springframework/hateoas/alps/Alps.java +++ b/src/main/java/org/springframework/hateoas/alps/Alps.java @@ -24,6 +24,8 @@ 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.JsonPropertyOrder; + /** * An ALPS document. * @@ -34,6 +36,7 @@ import org.springframework.hateoas.alps.Ext.ExtBuilder; */ @Value @Builder(builderMethodName = "alps") +@JsonPropertyOrder({"version", "doc", "descriptors"}) public class Alps { private final String version = "1.0"; diff --git a/src/test/resources/org/springframework/hateoas/alps/reference.json b/src/test/resources/org/springframework/hateoas/alps/reference.json index 6875af1c..c68937b0 100644 --- a/src/test/resources/org/springframework/hateoas/alps/reference.json +++ b/src/test/resources/org/springframework/hateoas/alps/reference.json @@ -1,4 +1,5 @@ { + "version" : "1.0", "doc" : { "href" : "http://example.org/samples/full/doc.html" }, @@ -27,6 +28,5 @@ "href" : "http://alps.io/ext/range", "value" : "summary,detail" } - } ], - "version" : "1.0" + } ] } \ No newline at end of file