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

Bundle don't conform with linting #1507

Closed
flaviotruzzi opened this issue Jan 26, 2021 · 2 comments
Closed

Bundle don't conform with linting #1507

flaviotruzzi opened this issue Jan 26, 2021 · 2 comments

Comments

@flaviotruzzi
Copy link

Hi,

I ran into what it looks like a bug on the bundle method. I am working with multifile specification, and using the openapi-cli linter.

When splitting into multiple files, paths with the same root that contain parameters will not bundle, under this testing case:

» tree test                                                                                                                                                                                                                                                                              130 ↵ REDACTED@ip-192-168-0-29
test
├── components
│   └── parameters
│       └── param.yaml
├── openapi.yaml
└── paths
    ├── api@param@stuff.yaml
    └── api@param@stuff2.yaml

openapi.yaml:

openapi: 3.0.1
info:
  title: Test
  description: Test
  version: 1.0.0
paths:
  /api/{param}/stuff:
    $ref: paths/api@param@stuff.yaml
  /api/{param}/stuff2:
    $ref: paths/api@param@stuff2.yaml

Both paths api@param@stuff.yaml and api@param@stuff2.yaml with:

get:
  parameters:
    $ref: ../components/parameters/param.yaml
  
  responses:
    204:
      description: Empty Response just for the test.

And the components/parameter/param.yaml with:

- name: param
  in: path
  description: param
  required: true
  schema:
    type: string

When trying to run bundle, it will fail with:

» ./node_modules/.bin/redoc-cli bundle test/openapi.yaml                                                                                                                                                                                                                                 130 ↵ REDACTED@ip-192-168-0-29
Prerendering docs
TypeError: operationParams.forEach is not a function
    at mergeParams (/Users/REDACTED/devel/docs/api/node_modules/redoc/bundles/redoc.lib.js:8307:21)
    at OperationModel.get (/Users/REDACTED/devel/docs/api/node_modules/redoc/bundles/redoc.lib.js:9740:31)
    at OperationModel.get (/Users/REDACTED/devel/docs/api/node_modules/redoc/bundles/redoc.lib.js:8600:42)
    at Object.children (/Users/REDACTED/devel/docs/api/node_modules/redoc/bundles/redoc.lib.js:14129:97)
    at ReactDOMServerRenderer.render (/Users/REDACTED/devel/docs/api/node_modules/react-dom/cjs/react-dom-server.node.development.js:3635:55)
    at ReactDOMServerRenderer.read (/Users/REDACTED/devel/docs/api/node_modules/react-dom/cjs/react-dom-server.node.development.js:3373:29)
    at Object.renderToString (/Users/REDACTED/devel/rdocs/api/node_modules/react-dom/cjs/react-dom-server.node.development.js:3988:27)
    at /Users/REDACTED/devel/docs/api/node_modules/redoc-cli/index.js:215:29
    at Generator.next (<anonymous>)
    at fulfilled (/Users/REDACTED/devel/docs/api/node_modules/redoc-cli/index.js:6:58)

To fix this I can add the parameter entry in only one of the files, linter is asking to add the parameter to each file, which, for me, make sense when they are split.

I am not sure if this is a bug with redoc-cli or if it is a bug on the openapi-cli.

@RomanHotsiy
Copy link
Member

We still do not use openapi-core in redoc. This is in-progress: #1500

@RomanHotsiy
Copy link
Member

To workaround, please bundle the definition first and then pass it to redoc-cli:

openapi-cli bundle test/openapi.yaml -o bundle.yaml
redoc-cli bundle bundle.yaml

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

No branches or pull requests

2 participants