Skip to content
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

Support Redoc options #12

Merged
merged 3 commits into from
Jan 10, 2023
Merged

Conversation

timothyvanderaerden
Copy link
Contributor

@timothyvanderaerden timothyvanderaerden commented Nov 30, 2022

Implements all options as described here: https://github.com/Redocly/redoc#redoc-options-object.

Not sure if this is the way you want to go but this is a fast way and easy to do so.

TODO

  • Add some documentation for available options.
    • (Should this be a full list grabbed from Redoc's README or a comment: See all available options: REDOC_LINK)?

Related #7.

@timothyvanderaerden timothyvanderaerden changed the title Support redoc options object Support Redoc options Nov 30, 2022
Comment on lines 111 to 116
Enum.reduce(opts, [], fn {key, value}, acc ->
case Enum.member?(@redoc_options, key) do
true -> [{to_kebab_case(key), value} | acc]
false -> acc
end
end)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done by using Keyword.take/2:

Keyword.take(opts, @redoc_options)
|> Enum.map(fn {key, value} -> {to_kebab_case(key), value} end)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's much better!

@impl true
def init(opts) do
spec_url = Keyword.fetch!(opts, :spec_url)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would cause breaking change due to spec_url is missing. We should warn it and merge to redoc_opts if it's set.

@wingyplus wingyplus merged commit 0f54a30 into wingyplus:main Jan 10, 2023
@timothyvanderaerden timothyvanderaerden deleted the options branch January 11, 2023 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants