diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java
index c073484e..a4fbf42d 100644
--- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java
+++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HypermediaDocumentation.java
@@ -51,6 +51,10 @@ public abstract class HypermediaDocumentation {
* descriptors, a failure will occur when the snippet is invoked. Similarly, if a link
* is documented, is not marked as optional, and is not present in the response, a
* failure will also occur.
+ *
+ * If you do not want to document a link, a link descriptor can be marked as
+ * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
+ * generated snippet while avoiding the failure described above.
*
* @param descriptors the descriptions of the response's links
* @return the snippet that will document the links
@@ -70,6 +74,10 @@ public abstract class HypermediaDocumentation {
* descriptors, a failure will occur when the snippet is invoked. Similarly, if a link
* is documented, is not marked as optional, and is not present in the response, a
* failure will also occur.
+ *
+ * If you do not want to document a link, a link descriptor can be marked as
+ * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
+ * generated snippet while avoiding the failure described above.
*
* @param attributes the attributes
* @param descriptors the descriptions of the response's links
@@ -90,6 +98,10 @@ public abstract class HypermediaDocumentation {
* descriptors, a failure will occur when the snippet is invoked. Similarly, if a link
* is documented, is not marked as optional, and is not present in the response, a
* failure will also occur.
+ *
+ * If you do not want to document a link, a link descriptor can be marked as
+ * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
+ * generated snippet while avoiding the failure described above.
*
* @param linkExtractor used to extract the links from the response
* @param descriptors the descriptions of the response's links
@@ -110,6 +122,10 @@ public abstract class HypermediaDocumentation {
* descriptors, a failure will occur when the snippet is invoked. Similarly, if a link
* is documented, is not marked as optional, and is not present in the response, a
* failure will also occur.
+ *
+ * If you do not want to document a link, a link descriptor can be marked as
+ * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
+ * generated snippet while avoiding the failure described above.
*
* @param attributes the attributes
* @param linkExtractor used to extract the links from the response
diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java
index 810a5244..8876cf7d 100644
--- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java
+++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinkDescriptor.java
@@ -16,7 +16,7 @@
package org.springframework.restdocs.hypermedia;
-import org.springframework.restdocs.snippet.AbstractDescriptor;
+import org.springframework.restdocs.snippet.IgnorableDescriptor;
/**
* A description of a link found in a hypermedia API.
@@ -24,7 +24,7 @@ import org.springframework.restdocs.snippet.AbstractDescriptor;
* @author Andy Wilkinson
* @see HypermediaDocumentation#linkWithRel(String)
*/
-public class LinkDescriptor extends AbstractDescriptor {
+public class LinkDescriptor extends IgnorableDescriptor {
private final String rel;
diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java
index 8b5a04d4..79ae0ee2 100644
--- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java
+++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/LinksSnippet.java
@@ -74,8 +74,12 @@ public class LinksSnippet extends TemplatedSnippet {
super("links", attributes);
this.linkExtractor = linkExtractor;
for (LinkDescriptor descriptor : descriptors) {
- Assert.hasText(descriptor.getRel());
- Assert.notNull(descriptor.getDescription());
+ Assert.notNull(descriptor.getRel(), "Link descriptors must have a rel");
+ if (!descriptor.isIgnored()) {
+ Assert.notNull(descriptor.getDescription(), "The descriptor for link '"
+ + descriptor.getRel() + "' must either have a description or be"
+ + " marked as " + "ignored");
+ }
this.descriptorsByRel.put(descriptor.getRel(), descriptor);
}
}
@@ -131,7 +135,10 @@ public class LinksSnippet extends TemplatedSnippet {
private List