Skip to content

Commit 6111073

Browse files
committed
code review
1 parent 6da720a commit 6111073

File tree

4 files changed

+49
-19
lines changed

4 files changed

+49
-19
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>3.4.5</version>
14+
<version>3.5.0</version>
1515
</parent>
1616

1717
<licenses>

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocSecurityConfiguration.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
6767
import org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter;
6868
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
69+
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
6970
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
71+
import org.springframework.security.web.util.matcher.RequestMatcher;
72+
import org.springframework.web.util.pattern.PathPattern;
7073

7174
import static org.springdoc.core.utils.Constants.SPRINGDOC_SHOW_LOGIN_ENDPOINT;
7275
import static org.springdoc.core.utils.Constants.SPRINGDOC_SHOW_OAUTH2_ENDPOINTS;
@@ -155,8 +158,25 @@ OpenApiCustomizer springSecurityLoginEndpointCustomizer(ApplicationContext appli
155158
operation.addTagsItem("login-endpoint");
156159
PathItem pathItem = new PathItem().post(operation);
157160
try {
158-
AntPathRequestMatcher requestMatcher = (AntPathRequestMatcher)FieldUtils.readField(usernamePasswordAuthenticationFilter, "requiresAuthenticationRequestMatcher", true);
159-
String loginPath = requestMatcher.getPattern();
161+
RequestMatcher requestMatcher = (RequestMatcher) FieldUtils.readField(
162+
usernamePasswordAuthenticationFilter,
163+
"requiresAuthenticationRequestMatcher",
164+
true
165+
);
166+
167+
String loginPath = null;
168+
169+
if (requestMatcher instanceof AntPathRequestMatcher) {
170+
loginPath = ((AntPathRequestMatcher) requestMatcher).getPattern();
171+
} else if (requestMatcher instanceof PathPatternRequestMatcher) {
172+
PathPattern pathPattern = (PathPattern) FieldUtils.readField(
173+
requestMatcher,
174+
"pattern",
175+
true
176+
);
177+
loginPath = pathPattern.getPatternString();
178+
}
179+
160180
openAPI.getPaths().addPathItem(loginPath, pathItem);
161181
}
162182
catch (IllegalAccessException |

springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app22.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@
143143
"$ref": "#/components/schemas/Person"
144144
}
145145
},
146+
"application/vnd.hal+json": {
147+
"schema": {
148+
"$ref": "#/components/schemas/Person"
149+
}
150+
},
146151
"application/json": {
147152
"schema": {
148153
"$ref": "#/components/schemas/Person"
@@ -227,12 +232,6 @@
227232
}
228233
}
229234
},
230-
"Links": {
231-
"type": "object",
232-
"additionalProperties": {
233-
"$ref": "#/components/schemas/Link"
234-
}
235-
},
236235
"RepresentationModelObject": {
237236
"type": "object",
238237
"properties": {
@@ -337,6 +336,12 @@
337336
"type": "boolean"
338337
}
339338
}
339+
},
340+
"Links": {
341+
"type": "object",
342+
"additionalProperties": {
343+
"$ref": "#/components/schemas/Link"
344+
}
340345
}
341346
}
342347
}

springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app22.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"description": "Zero-based page index (0..N)",
2626
"required": false,
2727
"schema": {
28-
"minimum": 0,
2928
"type": "integer",
30-
"default": 0
29+
"default": 0,
30+
"minimum": 0
3131
}
3232
},
3333
{
@@ -36,9 +36,9 @@
3636
"description": "The size of the page to be returned",
3737
"required": false,
3838
"schema": {
39-
"minimum": 1,
4039
"type": "integer",
41-
"default": 20
40+
"default": 20,
41+
"minimum": 1
4242
}
4343
},
4444
{
@@ -143,6 +143,11 @@
143143
"$ref": "#/components/schemas/Person"
144144
}
145145
},
146+
"application/vnd.hal+json": {
147+
"schema": {
148+
"$ref": "#/components/schemas/Person"
149+
}
150+
},
146151
"application/json": {
147152
"schema": {
148153
"$ref": "#/components/schemas/Person"
@@ -227,12 +232,6 @@
227232
}
228233
}
229234
},
230-
"Links": {
231-
"type": "object",
232-
"additionalProperties": {
233-
"$ref": "#/components/schemas/Link"
234-
}
235-
},
236235
"RepresentationModelObject": {
237236
"type": "object",
238237
"properties": {
@@ -337,6 +336,12 @@
337336
"type": "boolean"
338337
}
339338
}
339+
},
340+
"Links": {
341+
"type": "object",
342+
"additionalProperties": {
343+
"$ref": "#/components/schemas/Link"
344+
}
340345
}
341346
}
342347
}

0 commit comments

Comments
 (0)