swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
778 stars 525 forks source link

DeserializationUtils in 2.1.13 with SnakeYaml 2 no longer loads large YAML files #1912

Closed StevenWallTR closed 1 year ago

StevenWallTR commented 1 year ago

I am trying to use 2.1.13 with Snakeyaml 2 and our large (4+ MB) YAML file will no longer load.

This code was working with 2.1.11 and Snakeyaml 1.33:

int maxCodePoints = 5 * 1024 * 1024;  //5MB
System.setProperty("maxYamlCodePoints", Integer.toString(maxCodePoints));
OpenAPIV3Parser v3parser = new OpenAPIV3Parser();
openApi = v3parser.read(OPEN_API_SPECIFICATION);

Now with 2.1.13 and Snakeyaml 2, I receive this error: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.

The issue is with this commit to the DeserializationUtils class. Prior to the commit, line ~266 would set the maxYamlCodePoints on the LoaderOptions class. That code was replaced by the buildLoaderOptions() method, which does not set the maxYamlCodePoints property.

frantuma commented 1 year ago

Thanks for reporting this!

Fixed by #1914