|
1 | 1 | /* |
2 | | - * Copyright (c) 2020, 2022 Oracle and/or its affiliates. |
| 2 | + * Copyright (c) 2020, 2023 Oracle and/or its affiliates. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
86 | 86 | import org.jboss.jandex.IndexView; |
87 | 87 | import org.yaml.snakeyaml.TypeDescription; |
88 | 88 | import org.yaml.snakeyaml.introspector.Property; |
| 89 | +import org.yaml.snakeyaml.introspector.PropertySubstitute; |
89 | 90 |
|
90 | 91 | import static io.helidon.webserver.cors.CorsEnabledServiceHelper.CORS_CONFIG_KEY; |
91 | 92 |
|
@@ -148,6 +149,11 @@ MediaType mediaType() { |
148 | 149 |
|
149 | 150 | private static final JsonReaderFactory JSON_READER_FACTORY = Json.createReaderFactory(Collections.emptyMap()); |
150 | 151 |
|
| 152 | + // As a static we keep a reference to the logger, thereby making sure any changes we make are persistent. (JUL holds |
| 153 | + // only weak references to loggers internally.) |
| 154 | + private static final Logger SNAKE_YAML_INTROSPECTOR_LOGGER = |
| 155 | + Logger.getLogger(PropertySubstitute.class.getPackage().getName()); |
| 156 | + |
151 | 157 | /** |
152 | 158 | * The SnakeYAMLParserHelper is generated by a maven plug-in. |
153 | 159 | */ |
@@ -262,6 +268,11 @@ private void registerJsonpSupport(ServerRequest req, ServerResponse res) { |
262 | 268 | static SnakeYAMLParserHelper<ExpandedTypeDescription> helper() { |
263 | 269 | return access(HELPER_ACCESS, () -> { |
264 | 270 | if (helper == null) { |
| 271 | + Config config = Config.create(); |
| 272 | + boolean allowSnakeYamlWarnings = (config.get("openapi.parsing.warnings.enabled").asBoolean().orElse(false)); |
| 273 | + if (SNAKE_YAML_INTROSPECTOR_LOGGER.isLoggable(Level.WARNING) && !allowSnakeYamlWarnings) { |
| 274 | + SNAKE_YAML_INTROSPECTOR_LOGGER.setLevel(Level.SEVERE); |
| 275 | + } |
265 | 276 | helper = SnakeYAMLParserHelper.create(ExpandedTypeDescription::create); |
266 | 277 | adjustTypeDescriptions(helper.types()); |
267 | 278 | } |
|
0 commit comments