davidmoten / openapi-to-plantuml

Converts OpenAPI 3.0 definitions to Plant UML text for visualisation of your API.
Apache License 2.0
92 stars 18 forks source link

Half of the diagram is missing if you have a big *.yaml source file #161

Closed zappee closed 1 year ago

zappee commented 1 year ago

First, I would like to mention that this is a really nice tool, I like it so much. Recently I have found a bug in it. Please see the details below.

I use the following command to generate the PNG: java -jar openapi-to-plantuml-0.1.20-jar-with-dependencies.jar my-api.yaml PNG my-api.png

Unfortunately, my *.yaml is quite huge and the generated image dimension is not big enough to show the whole picture.

I uploaded the result (image) here and you can check it.

The yaml file we have is not public so I can not share it on the internet but I can send it to you in a private channel but you are not allowed to share/publish it.

Could you please fix this issue? Thanks.

davidmoten commented 1 year ago

Glad you like the tool. This rings a bell. I can have a look but from memory for large openapi files you are best to produce an svg. The svg won't be cropped and also is crisply rendered at any zoom level.

davidmoten commented 1 year ago

The size limits for PNG are determined by the plantuml library. I found this link:

https://plantuml.com/en/faq#e689668a91b8d065

It suggests to set a system property (and possibly increase memory too).

So you would do this:

java -DPLANTUML_LIMIT_SIZE=8192 -jar openapi-to-plantuml-0.1.20-jar-with-dependencies.jar my-api.yaml PNG my-api.png

and adjust the value up till your diagram fits.

I'll add this info to the README.md

PlantUML limits image width and height to 4096. There is an environment variable that you can set to override this limit: PLANTUML_LIMIT_SIZE. You have to define this variable before launching PlantUML, something like:

set PLANTUML_LIMIT_SIZE=8192 or

setenv PLANTUML_LIMIT_SIZE 8192 Another way is an option in the command line:

java -DPLANTUML_LIMIT_SIZE=8192 -jar /path/to/plantuml.jar ... Note that if you generate very big diagrams, (for example, something like 20 000 x 10 000 pixels), you can have some memory issues. The solution is to add this parameter to the java vm : -Xmx1024m.

zappee commented 1 year ago

Thanks for your quick and helpful response. Changing the PLANTUML_LIMIT_SIZE helped a little bit, but using PLANTUML_LIMIT_SIZE=32768 was also not enough to generate the full PNG. Then I switched to SVG format as you suggested and that works great.

This command generated the full diagram properly: java -jar openapi-to-plantuml-0.1.20-jar-with-dependencies.jar my.yaml SVG my.svg

The generated diagram resolution is giant big (the file size is normal, 1.6MB) and humans are not able to read it :) I 100% agree that this "rings a bell". The reason for generating this giant diagram is to present the "rings a bell" situation :)

Thanks a lot. This tool is a great tool, I am going to use it often.

zappee commented 1 year ago

close