rohit-gohri / redocusaurus

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

Can't retrieve spec from a private Nexus repository #252

Closed aleksimo closed 1 year ago

aleksimo commented 1 year ago

Hello there,

I am trying to integrate an API spec from a Nexus repo via Redocusaurus. In Docusaurus, I have the following config:

'redocusaurus',
      {
        // Plugin Options for loading OpenAPI files
        specs: [
          {
            id: 'api',
            config: 'redocly.yaml',
            spec: 'https://repository.mycompany.com/content/groups/bla-bla/0.0.9/openapi.yaml',
            route: '/api/',
          },
}

As the Nexus repo requires authentication, in the root, I have added redocly.yaml with the resolve object and provided credentials. But this solution still results in error 401.

resolve:
  http:
    headers:
      - matches: https://repository.mycompany.com/**
        name: Authorization
        envVariable: Basic SOMEKEY

The logs from NODE_DEBUG=http,http2 npm start show that the header is empty and that the config is not attached. Though, when creating both redocly.yaml and .redocly.yaml in the project's root, I get the anticipated error.

What can be the problem here? Thank you in advance.

rohit-gohri commented 1 year ago

It's a bug/missing feature. We don't pass the redocly options when loading specs - https://github.com/rohit-gohri/redocusaurus/blob/e94fc14255993467f73f839af86af8437139293d/packages/docusaurus-plugin-redoc/src/index.ts#LL66C42-L66C42

Will have to update that

aleksimo commented 1 year ago

Wow, thank you for such a quick reply. I will be waiting for the fix.

rohit-gohri commented 1 year ago

I don't actively use this package now so it may be a while before I can fix this. But will be happy to merge a PR if you want to try your hand at it.

aleksimo commented 1 year ago

No problem, we are already resolving this via a CI/CD tool but I hoped there could be a documented option working. I'm a techwriter, so it'll take some time for a PR from me to appear:)

rohit-gohri commented 1 year ago

Can you try the test release in this PR - https://github.com/rohit-gohri/redocusaurus/pull/264#issuecomment-1424978062 ?

aleksimo commented 1 year ago

I tried, and it worked. Thank you so much! Be aware that when running a website via npm start and with the applied config, the API pages that fetch specs from authenticated remote sources may not be rendered. But, when I execute npm run build and run the built website with npm run serve, everything works just fine. I've left a comment about that in your repo.

rohit-gohri commented 1 year ago

Should be live in v1.5.1