Polish "Support link extraction with official HAL and HAL-FORMS media types"

See gh-965
This commit is contained in:
Andy Wilkinson
2025-06-03 19:24:18 +01:00
parent 9144684768
commit cd16feba50
3 changed files with 7 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,6 @@ class ContentTypeLinkExtractor implements LinkExtractor {
ContentTypeLinkExtractor() {
this.linkExtractors.put(MediaType.APPLICATION_JSON, new AtomLinkExtractor());
LinkExtractor halLinkExtractor = new HalLinkExtractor();
this.linkExtractors.put(HalLinkExtractor.HAL_MEDIA_TYPE, halLinkExtractor);
this.linkExtractors.put(HalLinkExtractor.VND_HAL_MEDIA_TYPE, halLinkExtractor);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,11 +30,14 @@ import org.springframework.http.MediaType;
* format.
*
* @author Andy Wilkinson
* @author Oliver Drotbohm
*/
class HalLinkExtractor extends AbstractJsonLinkExtractor {
static final MediaType HAL_MEDIA_TYPE = new MediaType("application", "hal+json");
static final MediaType VND_HAL_MEDIA_TYPE = new MediaType("application", "vnd.hal+json");
static final MediaType HAL_FORMS_MEDIA_TYPE = new MediaType("application", "prs.hal-forms+json");
@Override

View File

@@ -76,7 +76,7 @@ class ContentTypeLinkExtractorTests {
}
@Test
public void extractsLinksFromVndHalMediaType() throws IOException {
void extractsLinksFromVndHalMediaType() throws IOException {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.parseMediaType("application/vnd.hal+json"));
OperationResponse response = this.responseFactory.create(HttpStatus.OK, httpHeaders, this.halBody.getBytes());
@@ -85,7 +85,7 @@ class ContentTypeLinkExtractorTests {
}
@Test
public void extractsLinksFromHalFormsMediaType() throws IOException {
void extractsLinksFromHalFormsMediaType() throws IOException {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.parseMediaType("application/prs.hal-forms+json"));
OperationResponse response = this.responseFactory.create(HttpStatus.OK, httpHeaders, this.halBody.getBytes());