Comments (9)
@jellydn Thanks for responding.
That is because the api-doc is using the static generated file swagger.json which is the 3rd option.
Same with the playground for example if you where using the 2nd to generate an api/doc probably because you want 3rd parties UI with the schemas you would use it like:
<APIDocumentUI
apiDescriptionUrl="/api/doc"
layout="sidebar"
router="hash"
/>
Instead of the static one https://github.com/jellydn/next-swagger-doc/blob/main/examples/example/pages/playground.tsx#L51
A good way to test it is looking the api/doc endpoint I posted https://next-swagger-doc-demo.productsway.com/api/doc
when you run locally you will see the data will be in place when going localhost:3000/api/doc, even if you run yarn build
and then yarn start
api/doc will have the components schema there, which is really weird that got removed when deployed on vercel.
Spent my day yesterday testing different approach to try to see if I could make the api/doc append the schemas as local without good luck :( .
Let me know if you need some other info or I can help in any way, I will keep fighting it and post here if I realize something else.
Thanks!!
from next-swagger-doc.
Also because is working on local with "yarn build" and not in vercel (that runs by default the same command) which is very strange my high guess is have something todo with async code on the server taking more time than local and for that not being appended. But again, really high guess.
Adding also my project urls just in case
https://public-api-git-feat-swagger-windranger.vercel.app/api-doc (working fine)
https://public-api-git-feat-swagger-windranger.vercel.app/api/doc (empty component on prod)
https://public-api-git-feat-swagger-windranger.vercel.app/playground (use api/doc so on prod no schema are showed)
from next-swagger-doc.
Interesting I tried with vercel-cli to avoid deploying each time, and worked, but now that Im thinking I didn't remove the folders created by yarn dev, so maybe on my local is working because still fetching from the other folders previously created.
edit: from tests I did nextjs doesn't seems to remove comments so seems that is not the problem I believe the problem is on the path to the files. api-doc page works perfectly as it fetch the data on build time, is able to read the files and generate the static data served. The reason of that working is because is using getStaticProps which looks into the public folder /files without problem.
from next-swagger-doc.
Thanks, @octavioamu it does work on the demo https://next-swagger-doc-demo.productsway.com/api-doc. I will check tonight or so for the API endpoint.
from next-swagger-doc.
I think I know what is going on, you are using process.cwd() https://github.com/jellydn/next-swagger-doc/blob/main/src/swagger.ts#L39 I added a console log on the /api/doc endpoint and this is what cwd is on vercel as function are actually edge functions /var/task
so the problem is how is being routed to find paths, the public folder is already "/" so probably doesn't need pwd to find the path and could go relative instead of absolute
more about this topic
vercel/next.js#36031
https://nextjs.org/docs/advanced-features/output-file-tracing
diff approach to go around this issue
vercel/next.js#32236
from next-swagger-doc.
I keep digging on this, one little suggestion is change join() to resolve() at least seems will be more secure if people input '/models/' on schemaFolders
from next-swagger-doc.
no, resolve doesn't solve it, this is the server log of urls getting generated with resolve
[GET] /api/doc
15:55:31:07
process.cwd() 1 /var/task
apiss [
'/var/task/pages/api/**/*.ts',
'/var/task/pages/api/**/*.tsx',
'/var/task/pages/api/**/*.jsx',
'/var/task/pages/api/**/*.js',
'/var/task/pages/api/**/*.json',
'/var/task/pages/api/**/*.swagger.yaml',
'/var/task/.next/server/pages/api/**/*.js',
'/var/task/.next/server/pages/api/**/*.swagger.yaml',
'/var/task/.next/server/pages/api/**/*.json',
'/var/task/public/**/*.swagger.yaml',
'/var/task/public/**/*.json',
'/types/**/*.ts',
'/types/**/*.tsx',
'/types/**/*.jsx',
'/types/**/*.js',
'/types/**/*.json',
'/types/**/*.swagger.yaml',
'/types/**/*.js',
'/types/**/*.swagger.yaml',
'/types/**/*.json',
'/var/task/public/**/*.swagger.yaml',
'/var/task/public/**/*.json'
]
The created structure on vercel
from next-swagger-doc.
I think we could have possible solutions here:
- 1st solution: as far I as know, NextJs will remove comment on build project (
next build
) so we need to find a way to keep the comment code for generate swagger spec - 2nd solution: write a custom Webpack plugin to generate swagger file on build
from next-swagger-doc.
Hi @octavioamu I've just released version from #639 Could you take a try again? Thanks.
Also updated example aps.
0106836
from next-swagger-doc.
Related Issues (20)
- Module not found: Can't resolve '#apg-lite' HOT 1
- Issue with parameters and swcMinify HOT 2
- Example or Docs required to explain how to specify params?
- Compatibility issues with NodeJS 16+ (version 19.7.0 / 16.19.1) on Windows, Ubuntu, and Heroku
- `Argument of type 'Promise<typeof import("...@types/swagger-ui-react/index")>' is not assignable to parameter of type 'DynamicOptions<{ spec: any; }> | Loader<{ spec: any; }>'. HOT 1
- Authorize using Bearer or OAuth2 HOT 1
- How to manage multiple HTTP methods
- Theme | no light mode support ? HOT 1
- Next13 example project running issue HOT 4
- Swagger annotations $ref as string HOT 1
- Automated doc generation HOT 8
- Where to keep the schema.json file in next.js project?
- Not working on Next 13 HOT 1
- Issue when using different directory such as src HOT 1
- Swagger Specs Never Read HOT 4
- Empty paths in rendered JSON in Production (on Vercel) but not in Dev with NextJS 14 HOT 1
- README Documentation has a missing dependency HOT 2
- Error with yarn build with Next 14 HOT 3
- Error on build - Next.js 14 - TypeError: Class extends value undefined is not a constructor or null HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-swagger-doc.