我们的 Quarkus 生成的 OpenAPI 文档很大。 当我尝试使用 Swagger UI 查看时,出现此错误:
'
Caused by: com.fasterxml.jackson.dataformat.yaml.JacksonYAMLParseException: The incoming YAML document exceeds the limit: 3145728 code points.
at [Source: (InputStreamReader); line: 87426, column: 100]
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:456)
at com.fasterxml.jackson.core.JsonParser.nextFieldName(JsonParser.java:1151)
at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer._deserializeContainerNoRecursion(JsonNodeDeserializer.java:539)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:100)
at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:25)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
at com.fasterxml.jackson.databind.ObjectMapper._readTreeAndClose(ObjectMapper.java:4959)
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:3270)
at io.smallrye.openapi.runtime.io.JacksonJsonIO.fromReader(JacksonJsonIO.java:293)
... 76 more
Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
at org.yaml.snakeyaml.parser.ParserImpl$ParseFlowMappingKey.produce(ParserImpl.java:889)
at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:162)
at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:172)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.getEvent(YAMLParser.java:590)
at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:450)
... 84 more
'
我知道snakeyaml最大文件大小可以通过以下方式配置:
'
LoaderOptions loadingConfig = new LoaderOptions();
loadingConfig.setCodePointLimit(maxYamlCodePointSize);
Yaml yaml = new Yaml(loadingConfig);
'
如何使用 quarkus-smallrye-openapi 在 Quarkus 应用程序中进行配置?
这可以通过属性进行配置: 议员: 开放API: 扩展名: 小黑麦: 最大静态文件大小: