add options parameter to add redoc options and theming capacity.#21
add options parameter to add redoc options and theming capacity.#21youenchene wants to merge 2 commits intomvrilo:masterfrom
Conversation
redoc.go
Outdated
| SpecFS *embed.FS | ||
| Title string | ||
| Description string | ||
| Options string |
There was a problem hiding this comment.
Not a big fan of expecting a json string here.
It also seems that json.Valid doesn't ensure the string is an actual object.
https://go.dev/play/p/gmBO0XamJob
I see the redoc's Config type is quite extensive - so supporting all of these in a struct type might be overkill.
So why not use a map[string]any as type then later json.Marshal it?
That would ensure we're always receiving an object.
Your example would look like this:
Options: map[string]any{
"disableSearch": true,
"theme": map[string]any{
"colors": `{"primary":{"main":"#297b21"}}`,
},
}There was a problem hiding this comment.
Also instead of naming it Options, maybe we could name it Config or Settings?
There was a problem hiding this comment.
Also instead of naming it
Options, maybe we could name itConfigorSettings?
Hello?
I've chosen options because this is the name on redocly side : https://redocly.com/docs/redoc/deployment/html#the-redoc-object
There was a problem hiding this comment.
@mvrilo themap[string]anyis legit and make it stronger.
I have to upgrade to go 1.18 to handle the any type.
There was a problem hiding this comment.
@mvrilo if you have 5mn for the PR. It would be delightful.
…ing. Updated `Options` field from a JSON string to a `map[string]any` for better type safety and readability. Adjusted related logic, tests, and documentation to reflect this change. Removed redundant test for invalid JSON in options.
Small contributions to add a options parameter to handle redoc configuration : https://github.com/Redocly/redoc/blob/main/docs/config.md
Also added documentation for understanding quicker the different parameters of go-redoc.