rohit-gohri / redocusaurus

OpenAPI for Docusaurus with Redoc
https://redocusaurus.vercel.app/
MIT License
629 stars 114 forks source link

Generated link allowing to download OpenAPI specification uses 'plugin-redoc-0.yaml' as name of the file instead of the original name #255

Closed vamadou closed 1 year ago

vamadou commented 1 year ago

Hi, I am using docusaurus 2.2.0 and redocusaurus 1.4.0 to generate a nice website and API documentation. I am super happy with the result but wit one caveat: the generated link allowing to download OpenAPI specification uses 'plugin-redoc-0.yaml' as name of the file instead of the original specification file name. In the documentation, I can see: "We will also automatically generate a single downloadable YAML and add it as a static asset to be used as the download url." but I don't find information about how to change (or just preserve) the name of the original specification file ... could you help me? I probably missed something obvious, sorry about that

Thanks Vincent

rohit-gohri commented 1 year ago

You can customize the name of the file by specifying an id in the spec:

module.exports = {
  presets: [
    [
      'redocusaurus',
      {
        specs: [
          {
            id: 'your-api-name',
            spec: 'openapi/openapi.yaml',
            route: '/api/',
          },
        ],
        theme: {
          primaryColor: '#1890ff',
        },
      },
    ],
  ],
};

By default the id is generated using index of array so that is why it was plugin-redoc-0.yaml. Feel free to re-open the issue if it doesn't work.