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

Add a way to display multiple APIs together #91

Closed
serut opened this issue Sep 20, 2021 · 18 comments · Fixed by #180
Closed

Add a way to display multiple APIs together #91

serut opened this issue Sep 20, 2021 · 18 comments · Fixed by #180
Assignees
Labels
enhancement New feature or request

Comments

@serut
Copy link
Contributor

serut commented Sep 20, 2021

Hello,

I would like to know if there is a way to display the docusaurus left sidebar.

Currently, using your plugin, I have a full page displaying the swagger doc :
Screenshot from 2021-09-20 10-38-05

But since I have a lot of microservices, I would like my user be able to access the left sidebar to choose the microservice he wants to view the API.
Screenshot from 2021-09-20 10-39-03

Overall, I'm looking an integration of redoc with the versionning and the page system of docusaurus.
I've seen that if I create an empty page that has the same URL than what I specified in the docusaurus.config.js file, redocusaurus has an higher priority than the empty page. So if I'm not wrong, I can simulate the versionning of the API using an empty page.

In the screenshot above, the link Processing > API > Overview is the empty page that has the same URL than what is in my conf. It works great so far.

Any help would be appreciated.

@rohit-gohri
Copy link
Owner

This seems like it would be difficult (or impossible to do). As the API docs are rendered as a single React component. We don't have the content of the sidebar to integrate with the Docusaurus sidebar.

You could create your own React component that wraps the @theme/Redoc component and add custom header navigation elements maybe? I think it will be difficult to merge complex sidebars

@rohit-gohri rohit-gohri added the question QnA label Sep 20, 2021
@rohit-gohri
Copy link
Owner

If you want to version your API then just have multiple YAML files, each for each version of your API

@serut
Copy link
Contributor Author

serut commented Sep 20, 2021

I have no idea how React component are rendered by docusaurus.
Maybe the page itself should have everything related to redoc so it renders the sidebar then as the main content it renders the redoc in the center of the page. Currently from the docusaurus.config.js file it's pretty impossible to do it
Yes, for versonned API I think the "fake page" is good enough, but I didn't try it

@rohit-gohri
Copy link
Owner

Maybe the page itself should have everything related to redoc so it renders the sidebar then as the main content it renders the redoc in the center of the page. Currently from the docusaurus.config.js file it's pretty impossible to do it

I don't think that would look good, but I'll keep the issue open if anyone wants to give this a try or to see if there is demand for this.

@rohit-gohri rohit-gohri added enhancement New feature or request and removed question QnA labels Oct 5, 2021
@serut
Copy link
Contributor Author

serut commented Oct 5, 2021

How would you display 10 microservices API, if you don't have a sidebar ?

If there is another way, I'm open to that. :)

@rohit-gohri
Copy link
Owner

How would you display 10 microservices API, if you don't have a sidebar ?

Sidebar is a good idea, but not a nested sidebar because redoc would have it's own sidebar. Maybe a dropdown would look better, below the header?

@serut
Copy link
Contributor Author

serut commented Oct 5, 2021

Either a dropdown or a line bar with all microservice API next to each other

@rohit-gohri rohit-gohri changed the title Display the sidebar Add a way to display multiple APIs together Oct 5, 2021
@DatStorm
Copy link

DatStorm commented Nov 9, 2021

Have there been any progress on this? Looking to document 8 different microservices each with their own endpoint.

@rohit-gohri
Copy link
Owner

rohit-gohri commented Nov 19, 2021

How about just adding a dropdown to the navbar (navbar-dropdowns) and grouping all the docs there?

See example I just added :

{
label: 'Examples',
position: 'left',
items: [
{
label: 'All',
to: '/examples',
},
{
label: 'Custom Page',
to: '/examples/custom-page/',
},
{
label: 'Custom Layout',
to: '/examples/custom-layout/',
},
{
label: 'Using Spec URL',
to: '/examples/using-spec-url/',
},
{
label: 'Using Spec YAML',
to: '/examples/using-spec-yaml/',
},
],
},

@DatStorm
Copy link

Really nice example I like that. The way I had it working right now was:

  1. Create a file with x-tagGroups and then (https://redoc.ly/docs/api-reference-docs/specification-extensions/x-tag-groups/)
  2. Merge all files with https://www.npmjs.com/package/openapi-merge

But I like your example solution more. Will do that instead

@serut
Copy link
Contributor Author

serut commented Nov 22, 2021

Your solution does not fit on my layout. I have already too much content on the navbar...

image

Will try to develop something appropriate when I get some spare time. (with versionning, which matters for us)

@serut
Copy link
Contributor Author

serut commented Feb 25, 2022

I've created a new React component that I use to display the documentation with double sidebars :
image
Ok, on small screens it would be hard to use. Maybe I can tweak the theme, when #129 is deployed, to make it more attractive, as the center does not have much space on 22" screens.
As I'm using mdx file to run redoc and not the specs parameter inside docusaurus.config.js file, my API is versionned 🎉 .

@rohit-gohri
Copy link
Owner

As I'm using mdx file to run redoc and not the specs parameter inside docusaurus.config.js file, my API is versionned 🎉 .

That is genius!! 🎉

Ok, on small screens it would be hard to use.

You can modify the breakpoints in the theme to keep the view always single pane? That sounds like a good compromise

@serut
Copy link
Contributor Author

serut commented Feb 25, 2022

That is genius!! 🎉

Thanks !

You can modify the breakpoints in the theme to keep the view always single pane?

Which property are you talking about ?

I'm going to make two more PR : the component that I use to make it possible, as it can be stored on your theme package https://github.com/RegardsOss/RegardsOss.github.io/blob/master/src/redoc/RegardsApiDoc.jsx

And add https://github.com/RegardsOss/RegardsOss.github.io as user of your lib

@rohit-gohri
Copy link
Owner

You can modify the breakpoints in the theme to keep the view always single pane?

Which property are you talking about ?

https://github.com/Redocly/redoc#redoc-theme-object -> breakpoints

breakpoints # breakpoints for switching three/two and mobile view layouts

small: '50rem'
medium: '85rem'
large: '105rem'

We can force the 2 pane view with this I think (moves examples/code-samples below schema).

And add RegardsOss/RegardsOss.github.io as user of your lib

Would be great!

@serut
Copy link
Contributor Author

serut commented Feb 25, 2022

We can force the 2 pane view with this I think (moves examples/code-samples below schema).

It works great ! Thanks

@rohit-gohri
Copy link
Owner

rohit-gohri commented May 15, 2022

This is now possible to do with a new ApiDocMdx component in v1.1.0. See the guide here: https://redocusaurus.vercel.app/docs/guides/multiple-apis

And example here: https://redocusaurus.vercel.app/docs/nested/nested-1

@rohit-gohri
Copy link
Owner

This was done thanks to the ideas from the community! Pretty cool to see all the different usages in the wild.

Thanks to @serut for the initial request and work. And this MDX example with existing components by @TheCatLady here: https://github.com/someengineering/resoto.com/blob/7494b135d87533e54372e2f632f570dab3d06d6d/docs/reference/api.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants