Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[codegen] Use once(LOGGER) to reduce amount of identical warning messages #5808

Merged
merged 2 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.openapitools.codegen.utils.OneOfImplementorAdditionalData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.openapitools.codegen.utils.OnceLogger.once;

import java.io.File;
import java.util.*;
Expand Down Expand Up @@ -1654,7 +1655,7 @@ public void setParameterExampleValue(CodegenParameter codegenParameter, RequestB

if (content.size() > 1) {
// @see ModelUtils.getSchemaFromContent()
LOGGER.warn("Multiple MediaTypes found, using only the first one");
once(LOGGER).warn("Multiple MediaTypes found, using only the first one");
}

MediaType mediaType = content.values().iterator().next();
Expand Down Expand Up @@ -3530,7 +3531,7 @@ public CodegenParameter fromParameter(Parameter parameter, Set<String> imports)
} else if (parameter.getContent() != null) {
Content content = parameter.getContent();
if (content.size() > 1) {
LOGGER.warn("Multiple schemas found in content, returning only the first one");
once(LOGGER).warn("Multiple schemas found in content, returning only the first one");
}
MediaType mediaType = content.values().iterator().next();
s = mediaType.getSchema();
Expand Down Expand Up @@ -3884,7 +3885,7 @@ public List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> securitySc
// As of January 2020, the "signature" scheme has not been registered with IANA yet.
// This scheme may have to be changed when it is officially registered with IANA.
cs.isHttpSignature = true;
LOGGER.warn("Security scheme 'HTTP signature' is a draft IETF RFC and subject to change.");
once(LOGGER).warn("Security scheme 'HTTP signature' is a draft IETF RFC and subject to change.");
}
} else if (SecurityScheme.Type.OAUTH2.equals(securityScheme.getType())) {
cs.isKeyInHeader = cs.isKeyInQuery = cs.isKeyInCookie = cs.isApiKey = cs.isBasic = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ private static Schema getSchemaFromContent(Content content) {
if (content.size() > 1) {
// Other content types are currently ignored by codegen. If you see this warning,
// reorder the OAS spec to put the desired content type first.
LOGGER.warn("Multiple schemas found in the OAS 'content' section, returning only the first one ({})",
once(LOGGER).warn("Multiple schemas found in the OAS 'content' section, returning only the first one ({})",
entry.getKey());
}
return entry.getValue().getSchema();
Expand Down