|
14 | 14 | import io.swagger.v3.oas.models.media.ObjectSchema;
|
15 | 15 | import io.swagger.v3.oas.models.media.Schema;
|
16 | 16 | import io.swagger.v3.oas.models.media.StringSchema;
|
| 17 | +import io.swagger.v3.oas.models.parameters.HeaderParameter; |
17 | 18 | import io.swagger.v3.oas.models.parameters.Parameter;
|
18 | 19 | import io.swagger.v3.oas.models.parameters.RequestBody;
|
19 | 20 | import io.swagger.v3.oas.models.responses.ApiResponse;
|
|
32 | 33 | import org.springframework.context.ApplicationContextAware;
|
33 | 34 | import org.springframework.http.HttpMethod;
|
34 | 35 | import org.springframework.http.HttpStatus;
|
| 36 | +import org.springframework.security.oauth2.core.AuthorizationGrantType; |
35 | 37 | import org.springframework.security.oauth2.core.OAuth2Error;
|
36 | 38 | import org.springframework.security.oauth2.core.endpoint.OAuth2ParameterNames;
|
37 | 39 | import org.springframework.security.oauth2.server.authorization.web.NimbusJwkSetEndpointFilter;
|
@@ -202,8 +204,28 @@ private void getOAuth2TokenEndpoint(OpenAPI openAPI, SecurityFilterChain securit
|
202 | 204 | buildApiResponsesOnBadRequest(apiResponses, openAPI);
|
203 | 205 | buildOAuth2Error(openAPI, apiResponses, HttpStatus.UNAUTHORIZED);
|
204 | 206 | Operation operation = buildOperation(apiResponses);
|
205 |
| - Schema<?> schema = new ObjectSchema().additionalProperties(new StringSchema()); |
206 |
| - operation.addParametersItem(new Parameter().name("parameters").in(ParameterIn.QUERY.toString()).schema(schema)); |
| 207 | + |
| 208 | + Schema<?> requestSchema = new ObjectSchema() |
| 209 | + .addProperty(OAuth2ParameterNames.GRANT_TYPE, |
| 210 | + new StringSchema() |
| 211 | + .addEnumItem(AuthorizationGrantType.AUTHORIZATION_CODE.getValue()) |
| 212 | + .addEnumItem(AuthorizationGrantType.REFRESH_TOKEN.getValue()) |
| 213 | + .addEnumItem(AuthorizationGrantType.CLIENT_CREDENTIALS.getValue())) |
| 214 | + .addProperty(OAuth2ParameterNames.CODE, new StringSchema()) |
| 215 | + .addProperty(OAuth2ParameterNames.REDIRECT_URI, new StringSchema()) |
| 216 | + .addProperty(OAuth2ParameterNames.REFRESH_TOKEN, new StringSchema()) |
| 217 | + .addProperty(OAuth2ParameterNames.SCOPE, new StringSchema()) |
| 218 | + .addProperty(OAuth2ParameterNames.CLIENT_ID, new StringSchema()) |
| 219 | + .addProperty(OAuth2ParameterNames.CLIENT_SECRET, new StringSchema()) |
| 220 | + .addProperty(OAuth2ParameterNames.CLIENT_ASSERTION_TYPE, new StringSchema()) |
| 221 | + .addProperty(OAuth2ParameterNames.CLIENT_ASSERTION, new StringSchema()) |
| 222 | + .addProperty("additionalParameters", new ObjectSchema().additionalProperties(new StringSchema())); |
| 223 | + |
| 224 | + String mediaType = org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; |
| 225 | + RequestBody requestBody = new RequestBody().content(new Content().addMediaType(mediaType, new MediaType().schema(requestSchema))); |
| 226 | + operation.setRequestBody(requestBody); |
| 227 | + operation.addParametersItem(new HeaderParameter().name("Authorization")); |
| 228 | + |
207 | 229 | buildPath(oAuth2EndpointFilter, "tokenEndpointMatcher", openAPI, operation, HttpMethod.POST);
|
208 | 230 | }
|
209 | 231 | }
|
|
0 commit comments