Skip to content

Commit cd16feb

Browse files
committed
Polish "Support link extraction with official HAL and HAL-FORMS media types"
See gh-965
1 parent 9144684 commit cd16feb

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/ContentTypeLinkExtractor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2019 the original author or authors.
2+
* Copyright 2014-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ class ContentTypeLinkExtractor implements LinkExtractor {
3838

3939
ContentTypeLinkExtractor() {
4040
this.linkExtractors.put(MediaType.APPLICATION_JSON, new AtomLinkExtractor());
41-
4241
LinkExtractor halLinkExtractor = new HalLinkExtractor();
4342
this.linkExtractors.put(HalLinkExtractor.HAL_MEDIA_TYPE, halLinkExtractor);
4443
this.linkExtractors.put(HalLinkExtractor.VND_HAL_MEDIA_TYPE, halLinkExtractor);

spring-restdocs-core/src/main/java/org/springframework/restdocs/hypermedia/HalLinkExtractor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,11 +30,14 @@
3030
* format.
3131
*
3232
* @author Andy Wilkinson
33+
* @author Oliver Drotbohm
3334
*/
3435
class HalLinkExtractor extends AbstractJsonLinkExtractor {
3536

3637
static final MediaType HAL_MEDIA_TYPE = new MediaType("application", "hal+json");
38+
3739
static final MediaType VND_HAL_MEDIA_TYPE = new MediaType("application", "vnd.hal+json");
40+
3841
static final MediaType HAL_FORMS_MEDIA_TYPE = new MediaType("application", "prs.hal-forms+json");
3942

4043
@Override

spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/ContentTypeLinkExtractorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void extractorCalledWithCompatibleContextType() throws IOException {
7676
}
7777

7878
@Test
79-
public void extractsLinksFromVndHalMediaType() throws IOException {
79+
void extractsLinksFromVndHalMediaType() throws IOException {
8080
HttpHeaders httpHeaders = new HttpHeaders();
8181
httpHeaders.setContentType(MediaType.parseMediaType("application/vnd.hal+json"));
8282
OperationResponse response = this.responseFactory.create(HttpStatus.OK, httpHeaders, this.halBody.getBytes());
@@ -85,7 +85,7 @@ public void extractsLinksFromVndHalMediaType() throws IOException {
8585
}
8686

8787
@Test
88-
public void extractsLinksFromHalFormsMediaType() throws IOException {
88+
void extractsLinksFromHalFormsMediaType() throws IOException {
8989
HttpHeaders httpHeaders = new HttpHeaders();
9090
httpHeaders.setContentType(MediaType.parseMediaType("application/prs.hal-forms+json"));
9191
OperationResponse response = this.responseFactory.create(HttpStatus.OK, httpHeaders, this.halBody.getBytes());

0 commit comments

Comments
 (0)