@@ -66,6 +66,26 @@ public static LinksSnippet links(LinkDescriptor... descriptors) {
6666Arrays .asList (descriptors ));
6767}
6868
69+ /**
70+ * Returns a new {@code Snippet} that will document the links in the API operation's
71+ * response. Links will be extracted from the response automatically based on its
72+ * content type and will be documented using the given {@code descriptors}.
73+ * <p>
74+ * If a link is documented, is not marked as optional, and is not present in the
75+ * response, a failure will occur. Any undocumented links will be ignored.
76+ * <p>
77+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
78+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
79+ * link does not have a title a failure will occur.
80+ *
81+ * @param descriptors the descriptions of the response's links
82+ * @return the snippet that will document the links
83+ */
84+ public static LinksSnippet relaxedLinks (LinkDescriptor ... descriptors ) {
85+ return new LinksSnippet (new ContentTypeLinkExtractor (),
86+ Arrays .asList (descriptors ), true );
87+ }
88+
6989/**
7090 * Returns a new {@code Snippet} that will document the links in the API call's
7191 * response. The given {@code attributes} will be available during snippet generation.
@@ -80,6 +100,10 @@ public static LinksSnippet links(LinkDescriptor... descriptors) {
80100 * If you do not want to document a link, a link descriptor can be marked as
81101 * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
82102 * generated snippet while avoiding the failure described above.
103+ * <p>
104+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
105+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
106+ * link does not have a title a failure will occur.
83107 *
84108 * @param attributes the attributes
85109 * @param descriptors the descriptions of the response's links
@@ -91,6 +115,29 @@ public static LinksSnippet links(Map<String, Object> attributes,
91115Arrays .asList (descriptors ), attributes );
92116}
93117
118+ /**
119+ * Returns a new {@code Snippet} that will document the links in the API call's
120+ * response. The given {@code attributes} will be available during snippet generation.
121+ * Links will be extracted from the response automatically based on its content type
122+ * and will be documented using the given {@code descriptors}.
123+ * <p>
124+ * If a link is documented, is not marked as optional, and is not present in the
125+ * response, a failure will occur. Any undocumented links will be ignored.
126+ * <p>
127+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
128+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
129+ * link does not have a title a failure will occur.
130+ *
131+ * @param attributes the attributes
132+ * @param descriptors the descriptions of the response's links
133+ * @return the snippet that will document the links
134+ */
135+ public static LinksSnippet relaxedLinks (Map <String , Object > attributes ,
136+ LinkDescriptor ... descriptors ) {
137+ return new LinksSnippet (new ContentTypeLinkExtractor (),
138+ Arrays .asList (descriptors ), attributes , true );
139+ }
140+
94141/**
95142 * Returns a new {@code Snippet} that will document the links in the API operation's
96143 * response. Links will be extracted from the response using the given
@@ -104,6 +151,10 @@ public static LinksSnippet links(Map<String, Object> attributes,
104151 * If you do not want to document a link, a link descriptor can be marked as
105152 * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
106153 * generated snippet while avoiding the failure described above.
154+ * <p>
155+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
156+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
157+ * link does not have a title a failure will occur.
107158 *
108159 * @param linkExtractor used to extract the links from the response
109160 * @param descriptors the descriptions of the response's links
@@ -114,6 +165,27 @@ public static LinksSnippet links(LinkExtractor linkExtractor,
114165return new LinksSnippet (linkExtractor , Arrays .asList (descriptors ));
115166}
116167
168+ /**
169+ * Returns a new {@code Snippet} that will document the links in the API operation's
170+ * response. Links will be extracted from the response using the given
171+ * {@code linkExtractor} and will be documented using the given {@code descriptors}.
172+ * <p>
173+ * If a link is documented, is not marked as optional, and is not present in the
174+ * response, a failure will occur. Any undocumented links will be ignored.
175+ * <p>
176+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
177+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
178+ * link does not have a title a failure will occur.
179+ *
180+ * @param linkExtractor used to extract the links from the response
181+ * @param descriptors the descriptions of the response's links
182+ * @return the snippet that will document the links
183+ */
184+ public static LinksSnippet relaxedLinks (LinkExtractor linkExtractor ,
185+ LinkDescriptor ... descriptors ) {
186+ return new LinksSnippet (linkExtractor , Arrays .asList (descriptors ), true );
187+ }
188+
117189/**
118190 * Returns a new {@code Snippet} that will document the links in the API operation's
119191 * response. The given {@code attributes} will be available during snippet generation.
@@ -128,6 +200,10 @@ public static LinksSnippet links(LinkExtractor linkExtractor,
128200 * If you do not want to document a link, a link descriptor can be marked as
129201 * {@link LinkDescriptor#ignored}. This will prevent it from appearing in the
130202 * generated snippet while avoiding the failure described above.
203+ * <p>
204+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
205+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
206+ * link does not have a title a failure will occur.
131207 *
132208 * @param attributes the attributes
133209 * @param linkExtractor used to extract the links from the response
@@ -139,6 +215,30 @@ public static LinksSnippet links(LinkExtractor linkExtractor,
139215return new LinksSnippet (linkExtractor , Arrays .asList (descriptors ), attributes );
140216}
141217
218+ /**
219+ * Returns a new {@code Snippet} that will document the links in the API operation's
220+ * response. The given {@code attributes} will be available during snippet generation.
221+ * Links will be extracted from the response using the given {@code linkExtractor} and
222+ * will be documented using the given {@code descriptors}.
223+ * <p>
224+ * If a link is documented, is not marked as optional, and is not present in the
225+ * response, a failure will occur. Any undocumented links will be ignored.
226+ * <p>
227+ * If a descriptor does not have a {@link LinkDescriptor#description(Object)
228+ * description}, the {@link Link#getTitle() title} of the link will be used. If the
229+ * link does not have a title a failure will occur.
230+ *
231+ * @param attributes the attributes
232+ * @param linkExtractor used to extract the links from the response
233+ * @param descriptors the descriptions of the response's links
234+ * @return the snippet that will document the links
235+ */
236+ public static LinksSnippet relaxedLinks (LinkExtractor linkExtractor ,
237+ Map <String , Object > attributes , LinkDescriptor ... descriptors ) {
238+ return new LinksSnippet (linkExtractor , Arrays .asList (descriptors ), attributes ,
239+ true );
240+ }
241+
142242/**
143243 * Returns a {@code LinkExtractor} capable of extracting links in Hypermedia
144244 * Application Language (HAL) format where the links are found in a map named
0 commit comments