refactor(ext-oidc): replace auth modules with security extensions #17

Merged
Relism merged 12 commits from feature/ext-auth/split-oidc-into-auth-core into master 2026-09-16 16:00:15 +00:00
2 changed files with 39 additions and 1 deletions
Showing only changes of commit 096098b33c - Show all commits
@@ -176,7 +176,8 @@ public final class OpenApiBuilder {
}
if (responseByCode.isEmpty()) {
responseByCode.put(200, Map.of("description", "OK"));
// Mutable: contributors merge descriptions and headers into it.
responseByCode.put(200, new LinkedHashMap<>(Map.of("description", "OK")));
}
applyContributorResponses(responseByCode, cls);
@@ -101,6 +101,15 @@ class OpenApiBuilderTest {
}
}
@GET("/plain")
@ApiOperation(summary = "Plain")
static class PlainHandler extends RequestHandler {
@Override
public Object handle(Request request, Response response) {
return null;
}
}
@Schema(name = "UserDTO", title = "User model", description = "DTO", deprecated = true)
@JsonIgnoreProperties({"ignoredByType"})
static class UserDto {
@@ -341,6 +350,34 @@ class OpenApiBuilderTest {
assertEquals("new", header.get("description"));
}
@Test
void contributor_merges_into_the_default_response_of_an_operation_without_annotations() {
OpenApiBuilder b = new OpenApiBuilder();
OpenApiContributorRegistry registry = new OpenApiContributorRegistry();
registry.add(new OpenApiContributor() {
@Override
public OpenApiOperationContribution operationFor(Class<?> handlerClass) {
return OpenApiOperationContribution.builder()
.allResponses(OpenApiResponseContribution.builder()
.header("X-Trace", Map.of("schema", Map.of("type", "string")))
.build())
.response(401, OpenApiResponseContribution.of("Authentication required"))
.build();
}
});
b.setContributorRegistry(registry);
b.addOperation(OpenApiBuilder.routeOf(PlainHandler.class), PlainHandler.class.getAnnotation(ApiOperation.class), PlainHandler.class);
Map<String, Object> spec = b.build();
Map<String, Object> responses = cast(getOperation(spec, "/plain", "get").get("responses"));
Map<String, Object> resp200 = cast(responses.get("200"));
Map<String, Object> resp401 = cast(responses.get("401"));
Map<String, Object> headers = cast(resp200.get("headers"));
assertEquals("OK", resp200.get("description"));
assertTrue(headers.containsKey("X-Trace"));
assertEquals("Authentication required", resp401.get("description"));
}
private static Map<String, Object> getOperation(Map<String, Object> spec, String path, String method) {
Map<String, Object> paths = cast(spec.get("paths"));
Map<String, Object> pathItem = cast(paths.get(path));