Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Micronaut Server Generator refactor the x-roles String variable
  • Loading branch information
andriy-dmytruk committed Mar 28, 2022
commit 06eaeca49d9ba564075f6d2b06d3e65f31c15131
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
List<CodegenOperation> allOperations = (List<CodegenOperation>) operations.get("operation");
if (useAuth) {
for (CodegenOperation operation : allOperations) {
if (!operation.vendorExtensions.containsKey("x-roles")) {
if (!operation.vendorExtensions.containsKey(EXTENSION_ROLES)) {
String role = operation.hasAuthMethods ? AUTHORIZED_ROLE : ANONYMOUS_ROLE;
operation.vendorExtensions.put("x-roles", Collections.singletonList(role));
operation.vendorExtensions.put(EXTENSION_ROLES, Collections.singletonList(role));
} else {
List<String> roles = (List<String>) operation.vendorExtensions.get("x-roles");
List<String> roles = (List<String>) operation.vendorExtensions.get(EXTENSION_ROLES);
roles = roles.stream().map(role -> {
switch (role) {
case ANONYMOUS_ROLE_KEY:
Expand All @@ -213,7 +213,7 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
return "\"" + escapeText(role) + "\"";
}
}).collect(Collectors.toList());
operation.vendorExtensions.put("x-roles", roles);
operation.vendorExtensions.put(EXTENSION_ROLES, roles);
}
}
}
Expand Down