Allow to pass options to the underlying diagram libraries
See original GitHub issueSome diagram libraries relies on options declared outside of the diagram definition. These options are usually used to configure the output: margin, padding, size, style, font, layout…
For instance, when using Mermaid, we can define a configuration object to configure the font size, the layout direction or the maxium width and height: https://mermaid-js.github.io/mermaid/#/./Setup?id=configuration
The goal of this issue is to define a generic format to pass these options using the API. Then, in a seconde phase, we will progressively add support for options on each diagram libraries (potentially disabling options that might be harmful in safe mode).
Query parameters
For GET requests, it makes sense to use query parameters:
GET /graphviz/svg/eNpLyUwvSizIUHBXqPZIzcnJ17ULzy_KSanlAgB1EAjQ?key=value
POST requests
POST /
{
"diagram_source": "digraph G {Hello->World}",
"diagram_type": "graphviz",
"output_format": "svg",
"diagram_options": {
"key": "value"
}
}
If the same option is defined as both a query parameter and as an attribute in the JSON body, I think the option defined in the JSON body should have an higher precedence.
HTTP headers
Since we can also send diagrams as plain text, we should also support HTTP headers:
POST /graphviz
Accept: image/svg+xml
Content-Type: text/plain
Kroki-Diagram-Options-Key: value
digraph G {
Hello->World
}
In this case, it’s important to use a prefix to disambiguate option names from other header names. Again, if the same option is defined as both a query parameter and as a request header, I think the option defined as a request header should have an higher precedence.
Precedence order
- JSON body
- HTTP header
- Query parameter
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:9 (5 by maintainers)
Top GitHub Comments
Sneak peek with GraphViz:
Sure, could you please open a new issue?
Speaking of themes,I wonder if we should also include themes from https://plantumlstyler.netlify.app/.
Gray tone
Isaac
Deep sea
Black and white
We should probably open another issue to discuss it.