Skip to content

Commit e14f975

Browse files
committed
Merge branch 'footaku-pass-components-calling-annotation-utils'
2 parents ed2cfb1 + 5f3fe3a commit e14f975

File tree

5 files changed

+150
-3
lines changed

5 files changed

+150
-3
lines changed

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ private Map<String, ApiResponse> computeResponseFromDoc(Components components, M
397397
apiResponse.extensions(extensions);
398398
}
399399
}
400-
AnnotationsUtils.getHeaders(apiResponseAnnotations.headers(), methodAttributes.getJsonViewAnnotation(), openapi31)
400+
AnnotationsUtils.getHeaders(apiResponseAnnotations.headers(), components, methodAttributes.getJsonViewAnnotation(), openapi31)
401401
.ifPresent(apiResponse::headers);
402402
apiResponsesOp.addApiResponse(httpCode, apiResponse);
403403
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OperationService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* *
44
* * *
55
* * * *
6-
* * * * * Copyright 2019-2022 the original author or authors.
6+
* * * * * Copyright 2019-2024 the original author or authors.
77
* * * * *
88
* * * * * Licensed under the Apache License, Version 2.0 (the "License");
99
* * * * * you may not use this file except in compliance with the License.
@@ -412,7 +412,7 @@ private Optional<ApiResponses> getApiResponses(
412412

413413
buildResponseContent(methodAttributes, components, classProduces, methodProduces, apiResponsesOp, response, apiResponseObject);
414414

415-
AnnotationsUtils.getHeaders(response.headers(), null, propertyResolverUtils.isOpenapi31()).ifPresent(apiResponseObject::headers);
415+
AnnotationsUtils.getHeaders(response.headers(), components, null, propertyResolverUtils.isOpenapi31()).ifPresent(apiResponseObject::headers);
416416
// Make schema as string if empty
417417
calculateHeader(apiResponseObject);
418418
if (isResponseObject(apiResponseObject)) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2024 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*/
22+
23+
package test.org.springdoc.api.v30.app218;
24+
25+
26+
import io.swagger.v3.oas.annotations.Operation;
27+
import io.swagger.v3.oas.annotations.headers.Header;
28+
import io.swagger.v3.oas.annotations.media.Schema;
29+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
30+
import org.springframework.http.HttpHeaders;
31+
import org.springframework.web.bind.annotation.GetMapping;
32+
import org.springframework.web.bind.annotation.RequestMapping;
33+
import org.springframework.web.bind.annotation.RestController;
34+
35+
import java.net.URI;
36+
37+
38+
@RestController
39+
@RequestMapping("/")
40+
public class HelloController {
41+
42+
@Operation(
43+
summary = "Summary",
44+
description = "This is description.",
45+
tags = {"Sample"},
46+
responses = {
47+
@ApiResponse(
48+
responseCode = "201",
49+
description = "201 (Created)",
50+
headers =
51+
@Header(
52+
name = HttpHeaders.LOCATION,
53+
description = "Sample endpoint",
54+
schema = @Schema(implementation = URI.class)
55+
)
56+
)
57+
}
58+
)
59+
@GetMapping
60+
public String get() {
61+
return "Hello World!";
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
*
3+
* * Copyright 2019-2024 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.api.v30.app218;
20+
21+
import org.springdoc.core.customizers.SpecPropertiesCustomizer;
22+
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.boot.test.context.SpringBootTest;
24+
import test.org.springdoc.api.v30.AbstractSpringDocV30Test;
25+
26+
/**
27+
* <p>
28+
* A test for {@link SpecPropertiesCustomizer}
29+
*/
30+
@SpringBootTest
31+
public class SpringDocApp218Test extends AbstractSpringDocV30Test {
32+
33+
@SpringBootApplication
34+
static class SpringDocTestApp {}
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"openapi": "3.0.1",
3+
"info": {
4+
"title": "OpenAPI definition",
5+
"version": "v0"
6+
},
7+
"servers": [
8+
{
9+
"url": "http://localhost",
10+
"description": "Generated server url"
11+
}
12+
],
13+
"paths": {
14+
"/": {
15+
"get": {
16+
"tags": [
17+
"Sample"
18+
],
19+
"summary": "Summary",
20+
"description": "This is description.",
21+
"operationId": "get",
22+
"responses": {
23+
"201": {
24+
"description": "201 (Created)",
25+
"headers": {
26+
"Location": {
27+
"description": "Sample endpoint",
28+
"style": "simple",
29+
"schema": {
30+
"type": "string",
31+
"format": "uri"
32+
}
33+
}
34+
},
35+
"content": {
36+
"*/*": {
37+
"schema": {
38+
"type": "string"
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
},
47+
"components": {}
48+
}

0 commit comments

Comments
 (0)