Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.openapitools.jackson.dataformat.hal.annotation.EmbeddedResource;
import io.openapitools.jackson.dataformat.hal.annotation.Link;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -127,6 +128,10 @@ public FilteredProperties(Object bean, SerializerProvider provider,
addLinks(relation, (Collection<HALLink>) prop.get(bean), curie);
} else if (value instanceof HALLink) {
addLink(relation, (HALLink) prop.get(bean), curie);
} else if (value instanceof String) {
addLink(relation, new HALLink.Builder((String) value).build(), curie);
} else if (value instanceof URI) {
addLink(relation, new HALLink.Builder((URI) value).build(), curie);
}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -28,7 +29,9 @@ public void testSerialization() throws Exception {
+ "\"child\":[{\"href\":\"/top/1/child/1\"},{\"href\":\"/top/1/child/2\"}],"
+ "\"empty:list\":[],"
+ "\"self\":{\"href\":\"/top/1\"},"
+ "\"templated\":{\"href\":\"/uri/{id}\",\"templated\":true}"
+ "\"stringLink\":{\"href\":\"http://something.com\",\"templated\":false},"
+ "\"templated\":{\"href\":\"/uri/{id}\",\"templated\":true},"
+ "\"uriLink\":{\"href\":\"http://something.else.com\"}"
+ "},"
+ "\"_embedded\":{"
+ "\"child\":["
Expand All @@ -50,6 +53,12 @@ public static class TopResource {
@Link("child")
public HALLink childLink = new HALLink.Builder(URI.create("/should/be/overridden")).build();

@Link
public String stringLink = "http://something.com";

@Link
public URI uriLink = new URI("http://something.else.com");

@Link
public HALLink templated = new HALLink.Builder("/uri/{id}").build();

Expand All @@ -75,6 +84,9 @@ public static class TopResource {

@EmbeddedResource
public String nullString = null;

public TopResource() throws URISyntaxException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add the default constructor?

}
}

@Resource
Expand Down