PaloAltoNetworks / docusaurus-openapi-docs

🦝 OpenAPI plugin for generating API reference docs in Docusaurus v3.
https://docusaurus-openapi.tryingpan.dev
MIT License
651 stars 224 forks source link

Question regarding importing the MDX file into another MDX file and displaying two components in one file #925

Closed metsaleht closed 1 week ago

metsaleht commented 3 weeks ago

Hi,

I am well aware of the functionality of importing one MDX file into another in docusaurus, and that works great; however, I can't get it to work with the openapi mdx files. The usecase why I am trying to do it is because we have two different openapi specifications and it would be great if I could import components from two different specifications into a markdown file where I write and add additional information and then for context add the component. Is this a fantasy, or would it be possible?

This is a very crude visualization, what I mean. example

metsaleht commented 2 weeks ago

It seems that Redocusaurus can more or less do this. Would this be possible with this plugin as well? https://redocusaurus.vercel.app/docs/guides/schema-imports

sserrata commented 1 week ago

Hi @metsaleht, this is certainly possible today for *.schema.mdx files:

For example:

import PartialExample from './petstore/schemas/pet.schema.mdx';
import BrowserWindow from '@site/src/components/BrowserWindow';

## Here's my Pet Schema!

<BrowserWindow bodyStyle={{height: 300, overflow: "auto"}}>

<PartialExample />

</BrowserWindow>

...results in:

Screenshot 2024-09-05 at 11 20 44 AM

Note that I copied the BrowserWindow component used in the docusaurus.io website

However. this doesn't work as nicely for *.api.mdx partials, for a couple of reasons:

  1. There is currently no way to selectively hide the ApiExplorer panel.
  2. The api front matter would need to be copied into the target doc
sserrata commented 1 week ago

Hi @metsaleht, I went ahead and added a doc covering this use case: https://docusaurus-openapi-36b86--pr945-w54smjhg.web.app/advanced#importing-mdx