plantuml / plantuml-server

PlantUML Online Server
https://plantuml.com/
GNU General Public License v3.0
1.59k stars 463 forks source link

Add diagram indexing support for all formats #302

Closed DRKV333 closed 1 year ago

DRKV333 commented 1 year ago

Currently, the only format that properly supports the idx parameter is base64. All other formats only let you select which image you want to export from the first multi-image diagram.

So if you have:

@startuml
class a
newpage
class b
@enduml

And POST it to /svg/1, you do get a class b in the output.

But if you have:

@startuml
class a
@enduml
@startuml
class b
@enduml

POSTing that to /svg/1 results in a class a. But POSTing it to /base64/1 does result in class b correctly.

This is unfortunate, since it makes exporting diagrams that use @startdef in svg completely impossible, since the @startdef always has to come first. To fix the issue, I have partially copied some of this code: https://github.com/plantuml/plantuml/blob/21461b83fc96a733f6879f18a7f0687d6e2ce456/src/net/sourceforge/plantuml/SourceStringReader.java#L154-L177 The solution is a little bit different from the base64 case, returning a 400 result, if the requested image index doesn't exist. Base64 returns 200 with an empty image, which I didn't change, but I think a 400 is more appropriate here.

arnaudroques commented 1 year ago

Thanks for your contribution!