No operations defined in spec! error #450
-
Describe the bugWhile trying to add swagger to my project I faced error: Docs folder: My code looks like this: api-doc.tsx
And here's my spec definition in Reproductionnpm run dev System InfoSystem:
OS: macOS 12.5.1
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 312.75 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.15.0/bin/npm
Watchman: 2022.03.21.00 - /usr/local/bin/watchman
Browsers:
Brave Browser: 91.1.26.74
Chrome: 105.0.5195.102
Firefox: 102.0.1
Safari: 15.6.1
Safari Technology Preview: 16.0
package.json:
"next": "^12.2.5",
"next-swagger-doc": "0.3.6",
"swagger-ui-react": "4.14.0",
"typescript": "4.8.2" Used Package Managernpm Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
Quick question here. Did you check the example app? Is that same setup? If not, could you create a reproduce repository so I could take a look? Thanks. |
Beta Was this translation helpful? Give feedback.
-
I was facing the same error trying to generate the specs both from api-doc page and from api/doc route. It turns out the 'apiFolder' property uses an absolute path to find the api routes with the swagger comments. That said, with a projet structure like someNextProject/src/pages/api you must set the swaggerOptions object to something like this:
Also, since this concerns the structure of the project, maybe it should described in the README example and/or in the type definitions that 'apiProperty' uses an absolute path of the next projet. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much for this. Been struggling for the last couple of hours |
Beta Was this translation helpful? Give feedback.
-
Also ensure that the following is typed exactly, wasted hours figuring the issue. replace
|
Beta Was this translation helpful? Give feedback.
Quick question here. Did you check the example app? Is that same setup? If not, could you create a reproduce repository so I could take a look? Thanks.