Skip to content

Commit dd92ae8

Browse files
authored
Merge pull request #9713 from swagger-api/auth-properties-apis
populate data map authMethods also for generateApi
2 parents f867b31 + 57164e8 commit dd92ae8

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/DefaultGenerator.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ public int compare(CodegenOperation one, CodegenOperation another) {
497497
});
498498
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
499499

500+
processSecurityProperties(operation);
501+
500502
operation.put("basePath", basePath);
501503
operation.put("basePathWithoutHost", basePathWithoutHost);
502504
operation.put("contextPath", contextPath);
@@ -743,12 +745,8 @@ private Map<String, Object> buildSupportFileBundle(List<Object> allOperations, L
743745
bundle.put("apiFolder", config.apiPackage().replace('.', File.separatorChar));
744746
bundle.put("modelPackage", config.modelPackage());
745747

746-
final Map<String, SecurityScheme> securitySchemeMap = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null;
747-
final List<CodegenSecurity> authMethods = config.fromSecurity(securitySchemeMap);
748-
if (authMethods != null && !authMethods.isEmpty()) {
749-
bundle.put("authMethods", authMethods);
750-
bundle.put("hasAuthMethods", true);
751-
}
748+
processSecurityProperties(bundle);
749+
752750
if (openAPI.getExternalDocs() != null) {
753751
bundle.put("externalDocs", openAPI.getExternalDocs());
754752
}
@@ -1136,4 +1134,14 @@ private Boolean getCustomOptionBooleanValue(String option) {
11361134
}
11371135
return Boolean.valueOf(optionalCodegenArgument.get().getValue());
11381136
}
1137+
1138+
protected void processSecurityProperties (Map<String, Object> bundle) {
1139+
final Map<String, SecurityScheme> securitySchemeMap = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null;
1140+
final List<CodegenSecurity> authMethods = config.fromSecurity(securitySchemeMap);
1141+
if (authMethods != null && !authMethods.isEmpty()) {
1142+
bundle.put("authMethods", authMethods);
1143+
bundle.put("hasAuthMethods", true);
1144+
}
1145+
}
1146+
11391147
}

0 commit comments

Comments
 (0)