Skip to content

Commit a0b5104

Browse files
author
Badr NASS LAHSEN
authored
Merge pull request #255 from marronef/classlevelhiddenannotation
Added ability to ignore param with @hidden annotation at class level
2 parents d933974 + 480d0be commit a0b5104

File tree

6 files changed

+139
-1
lines changed

6 files changed

+139
-1
lines changed

springdoc-openapi-webmvc-core/src/main/java/org/springdoc/core/RequestBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package org.springdoc.core;
22

3+
import io.swagger.v3.oas.annotations.Hidden;
34
import io.swagger.v3.oas.models.Operation;
5+
import org.springframework.core.annotation.AnnotationUtils;
46
import org.springframework.http.HttpMethod;
57
import org.springframework.stereotype.Component;
68
import org.springframework.validation.BindingResult;
@@ -36,7 +38,8 @@ protected boolean isParamTypeToIgnore(Class<?> paramType) {
3638
|| org.springframework.ui.Model.class.equals(paramType)
3739
|| org.springframework.ui.ModelMap.class.equals(paramType) || RedirectAttributes.class.equals(paramType)
3840
|| Errors.class.equals(paramType) || BindingResult.class.equals(paramType)
39-
|| SessionStatus.class.equals(paramType) || UriComponentsBuilder.class.equals(paramType);
41+
|| SessionStatus.class.equals(paramType) || UriComponentsBuilder.class.equals(paramType)
42+
|| (AnnotationUtils.findAnnotation(paramType, Hidden.class) != null);
4043
}
4144

4245
@Override
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package test.org.springdoc.api.app66;
2+
3+
import io.swagger.v3.oas.annotations.Operation;
4+
import io.swagger.v3.oas.annotations.tags.Tag;
5+
import org.springframework.http.MediaType;
6+
import org.springframework.http.ResponseEntity;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.RestController;
9+
10+
@Tag(name = "Health" , description = "Health check / ping API")
11+
@RestController
12+
public class HelloController {
13+
14+
@Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.")
15+
@GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE)
16+
public ResponseEntity<String> ping(UndocumentedClass possiblyInjectedByAspect) {
17+
return ResponseEntity.ok("Healthy");
18+
}
19+
20+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package test.org.springdoc.api.app66;
2+
3+
import test.org.springdoc.api.AbstractSpringDocTest;
4+
5+
public class SpringDocApp66Test extends AbstractSpringDocTest {
6+
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package test.org.springdoc.api.app66;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class SpringDocTestApp {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(SpringDocTestApp.class, args);
11+
}
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package test.org.springdoc.api.app66;
2+
3+
import io.swagger.v3.oas.annotations.Hidden;
4+
5+
@Hidden
6+
public class UndocumentedClass {
7+
8+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
"tags": [
14+
{
15+
"name": "Health",
16+
"description": "Health check / ping API"
17+
}
18+
],
19+
"paths": {
20+
"/ping": {
21+
"get": {
22+
"tags": [
23+
"Health"
24+
],
25+
"summary": "Check server status",
26+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
27+
"operationId": "ping",
28+
"responses": {
29+
"200": {
30+
"description": "default response",
31+
"content": {
32+
"text/plain": {
33+
"schema": {
34+
"type": "string"
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}
41+
},
42+
"/health": {
43+
"get": {
44+
"tags": [
45+
"Health"
46+
],
47+
"summary": "Check server status",
48+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
49+
"operationId": "ping_1",
50+
"responses": {
51+
"200": {
52+
"description": "default response",
53+
"content": {
54+
"text/plain": {
55+
"schema": {
56+
"type": "string"
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
},
64+
"/": {
65+
"get": {
66+
"tags": [
67+
"Health"
68+
],
69+
"summary": "Check server status",
70+
"description": "Check server status, will return 200 with simple string if alive. Do nothing else.",
71+
"operationId": "ping_2",
72+
"responses": {
73+
"200": {
74+
"description": "default response",
75+
"content": {
76+
"text/plain": {
77+
"schema": {
78+
"type": "string"
79+
}
80+
}
81+
}
82+
}
83+
}
84+
}
85+
}
86+
},
87+
"components": {}
88+
}

0 commit comments

Comments
 (0)