Skip to content

Commit

Permalink
Add support for generating Structurizr legend.
Browse files Browse the repository at this point in the history
Resolves #1686.
  • Loading branch information
willson556 committed Feb 9, 2024
1 parent 29e9fca commit ab1e608
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/modules/setup/pages/diagram-options.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ empty string ("")
|_string_
|Key of the view (if the workspace contains more than one view)

|get-legend
|_flag_
|Return the view's legend rather than the view itself

|===

== Svgbob
Expand Down
11 changes: 10 additions & 1 deletion server/src/main/java/io/kroki/server/service/Structurizr.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ static byte[] convert(String source, FileFormat fileFormat, PlantumlCommand plan
} else {
throw new BadRequestException("View type is not supported: " + selectedView.getClass().getSimpleName() + ", must be a DynamicView, DeploymentView, ComponentView, ContainerView, SystemContextView or SystemLandscapeView.");
}
return plantumlCommand.convert(diagram.getDefinition(), fileFormat, new JsonObject());

String diagramPlantUML;
String includeLegend = options.getString("get-legend");
if (includeLegend != null) {
diagramPlantUML = diagram.getLegend().getDefinition();
} else {
diagramPlantUML = diagram.getDefinition();
}

return plantumlCommand.convert(diagramPlantUML, fileFormat, new JsonObject());
} catch (StructurizrDslParserException e) {
String cause = e.getMessage();
final String message;
Expand Down

0 comments on commit ab1e608

Please sign in to comment.