-
-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to pass options to the underlying diagram libraries #827
Comments
@Mogztter this is a great idea and I agree with the precedence order too! |
It's important to note that HTTP headers are case-insensitive whereas query parameters and JSON keys are case-sensitive. As a result, I think we should use all lower case when declaring options as query parameters or as attributes in the JSON body:
{
"diagram_options": {
"viewkey": "SignIn"
}
} When declaring options as HTTP headers, the key will be converted to lower case. In other words, the following will be equivalent:
It will translate to As an alternative, we could use camel case instead of all lower case. Arguably, camel case is more readable but might be more error-prone? |
@Mogztter you could use the HTML5 web components naming rules:
|
kebab-case is fine but I have two small concerns:
People might ask "Why
"The key name is
That's a good point but I don't know if we will need to convert from one casing to another. I think I need to experiment to see what fits best. |
Good points @Mogztter but I actually like this ambiguation -- everything with kebab-case would be internal to a tool while underscores could be specific to Kroki.
And this is pretty readable to me:
|
Very slick @Mogztter hopefully our friend from the Structurizr project will add to his project when this is released! |
This is very nice, from the functionality down to the internal naming conventions of lower-kebab-case. Perhaps it can be used to nominate the theme used for PlantUML? |
Sure, could you please open a new issue? Speaking of themes,I wonder if we should also include themes from https://plantumlstyler.netlify.app/. We should probably open another issue to discuss it. |
Some 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:
POST requests
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:
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
The text was updated successfully, but these errors were encountered: