quarkiverse / quarkus-openapi-generator

OpenAPI Generator - REST Client Generator
Apache License 2.0
124 stars 86 forks source link

Support larger YAML files #786

Closed ElaiShalevRH closed 2 months ago

ElaiShalevRH commented 2 months ago

We've encountered an issue using large (over 3MB) input YAML files in our quarkus projects. Apparently the custom maximum size for YAML parsing (using SnakeYAML implementation) can be configured using the approach presented in the following:. Thus, there is a way to allow using larger YAML files.

We would like to suggest a change to this function,

    private File convertToJSON(Path yamlPath) throws CodeGenException {
        try {
            ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory());
            Object obj = yamlReader.readValue(yamlPath.toFile(), Object.class);
            ObjectMapper jsonWriter = new ObjectMapper();
            File jsonFile = File.createTempFile(yamlPath.toFile().getName(), ".json");
            jsonFile.deleteOnExit();
            jsonWriter.writeValue(jsonFile, obj);
            return jsonFile;
        } catch (Exception e) {
            throw new CodeGenException("Error converting YAML to JSON", e);
        }
    }

and allow to either increase the Maximum YAML size or allow for adding a parameter for controlling the size. I can go in depth for suggesting a code change and open a PR if this issue seems valid.

We would like to refer to this reproducer that demonstrates the issue, the error messages, and more on the approach for improvement.

If there is a fault or mistake in anything, please let me know. Thanks

ricardozanini commented 2 months ago

Hey @ElaiShalevRH! This request makes a lot of sense to me. Can you open the PR with the proposed changes?

ElaiShalevRH commented 2 months ago

Hey @ricardozanini, sure thing. I'll keep you posted, thanks!

ElaiShalevRH commented 2 months ago

Hey @ricardozanini, I've opened a PR on this issue :)

ricardozanini commented 2 months ago

@ElaiShalevRH I think this problem was on the client side, too. I misread your issue when we aligned offline. We were talking about the client side that SonataFlow is using. We are not using the server-side extension. It's good to fix on both sides, but please be aware of that in your PR.

ElaiShalevRH commented 2 months ago

Hey @ricardozanini, After further investigation, we found a way to configure that YAML input maximum on the client side without any code change (just by passing a build time parameter). This solves the issue for us, so I'll be closing the PR and the issue :) Thanks