Skip to content

Commit e477538

Browse files
authored
better checking for security definitions (#11335)
1 parent b2b077f commit e477538

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4849,10 +4849,13 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
48494849
// This scheme may have to be changed when it is officially registered with IANA.
48504850
cs.isHttpSignature = true;
48514851
once(LOGGER).warn("Security scheme 'HTTP signature' is a draft IETF RFC and subject to change.");
4852+
} else {
4853+
once(LOGGER).warn("Unknown scheme `{}` found in the HTTP security definition.", securityScheme.getScheme());
48524854
}
48534855
codegenSecurities.add(cs);
48544856
} else if (SecurityScheme.Type.OAUTH2.equals(securityScheme.getType())) {
48554857
final OAuthFlows flows = securityScheme.getFlows();
4858+
boolean isFlowEmpty = true;
48564859
if (securityScheme.getFlows() == null) {
48574860
throw new RuntimeException("missing oauth flow in " + key);
48584861
}
@@ -4862,28 +4865,38 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
48624865
cs.isPassword = true;
48634866
cs.flow = "password";
48644867
codegenSecurities.add(cs);
4868+
isFlowEmpty = false;
48654869
}
48664870
if (flows.getImplicit() != null) {
48674871
final CodegenSecurity cs = defaultOauthCodegenSecurity(key, securityScheme);
48684872
setOauth2Info(cs, flows.getImplicit());
48694873
cs.isImplicit = true;
48704874
cs.flow = "implicit";
48714875
codegenSecurities.add(cs);
4876+
isFlowEmpty = false;
48724877
}
48734878
if (flows.getClientCredentials() != null) {
48744879
final CodegenSecurity cs = defaultOauthCodegenSecurity(key, securityScheme);
48754880
setOauth2Info(cs, flows.getClientCredentials());
48764881
cs.isApplication = true;
48774882
cs.flow = "application";
48784883
codegenSecurities.add(cs);
4884+
isFlowEmpty = false;
48794885
}
48804886
if (flows.getAuthorizationCode() != null) {
48814887
final CodegenSecurity cs = defaultOauthCodegenSecurity(key, securityScheme);
48824888
setOauth2Info(cs, flows.getAuthorizationCode());
48834889
cs.isCode = true;
48844890
cs.flow = "accessCode";
48854891
codegenSecurities.add(cs);
4892+
isFlowEmpty = false;
4893+
}
4894+
4895+
if (isFlowEmpty) {
4896+
once(LOGGER).error("Invalid flow definition defined in the security scheme: {}", flows);
48864897
}
4898+
} else {
4899+
once(LOGGER).error("Unknown type `{}` found in the security definition `{}`.", securityScheme.getType(), securityScheme.getName());
48874900
}
48884901
}
48894902

0 commit comments

Comments
 (0)