OpenAPI 3.1 support - unable to resolve es modules
tim-lai opened this issue · 2 comments
Q&A (please complete the following information)
- OS: macOS
- Environment: node v16.16
- Method of installation: npm
- Swagger-Client version: 3.19.0-alpha.3
- Swagger/OpenAPI version: n/a
Content & configuration
Swagger/OpenAPI definition:
# your YAML here
Swagger-Client usage:
SwaggerClient({
// your config options here
})
Describe the bug you're encountering
when npm install swagger-client@3.19.0-alpha.3
,
ERROR in ./src/core/containers/OperationContainer.jsx 6:0-49
Module not found: Error: Can't resolve 'swagger-client/es/helpers' in '/Users/timothy.lai/Repos/swagger-ui/src/core/containers'
@ ./src/core/presets/base.js 20:0-66 166:6-24
@ ./src/core/presets/apis.js 3:0-32 11:2-12
@ ./src/core/index.js 6:0-40 87:4-14 223:8-18
ERROR in ./src/core/plugins/swagger-js/index.js 3:0-49
Module not found: Error: Can't resolve 'swagger-client/es/resolver' in '/Users/timothy.lai/Repos/swagger-ui/src/core/plugins/swagger-js'
@ ./src/core/plugins/ sync \.jsx?$ ./swagger-js/index.js core/plugins/swagger-js/index.js
@ ./src/core/plugins/all.js 6:16-53
@ ./src/core/index.js 7:0-39 227:20-30
ERROR in ./src/core/plugins/swagger-js/index.js 4:0-66
Module not found: Error: Can't resolve 'swagger-client/es/execute' in '/Users/timothy.lai/Repos/swagger-ui/src/core/plugins/swagger-js'
@ ./src/core/plugins/ sync \.jsx?$ ./swagger-js/index.js core/plugins/swagger-js/index.js
@ ./src/core/plugins/all.js 6:16-53
@ ./src/core/index.js 7:0-39 227:20-30
ERROR in ./src/core/plugins/swagger-js/index.js 5:0-70
Module not found: Error: Can't resolve 'swagger-client/es/http' in '/Users/timothy.lai/Repos/swagger-ui/src/core/plugins/swagger-js'
@ ./src/core/plugins/ sync \.jsx?$ ./swagger-js/index.js core/plugins/swagger-js/index.js
@ ./src/core/plugins/all.js 6:16-53
@ ./src/core/index.js 7:0-39 227:20-30
ERROR in ./src/core/plugins/swagger-js/index.js 6:0-64
Module not found: Error: Can't resolve 'swagger-client/es/subtree-resolver' in '/Users/timothy.lai/Repos/swagger-ui/src/core/plugins/swagger-js'
@ ./src/core/plugins/ sync \.jsx?$ ./swagger-js/index.js core/plugins/swagger-js/index.js
@ ./src/core/plugins/all.js 6:16-53
@ ./src/core/index.js 7:0-39 227:20-30
ERROR in ./src/core/plugins/swagger-js/index.js 7:0-49
Module not found: Error: Can't resolve 'swagger-client/es/helpers' in '/Users/timothy.lai/Repos/swagger-ui/src/core/plugins/swagger-js'
@ ./src/core/plugins/ sync \.jsx?$ ./swagger-js/index.js core/plugins/swagger-js/index.js
@ ./src/core/plugins/all.js 6:16-53
@ ./src/core/index.js 7:0-39 227:20-30
``
### To reproduce...
Steps to reproduce the behavior:
1. Access local `swagger-ui`
2. update `swagger-ui` `package.json` to use swagger-client@3.19.0-alpha.3
3. `npm i`
4. observer npm error
### Expected behavior
<!-- A clear and concise description of what you expected to happen. -->
no npm errors
### Screenshots
<!-- If applicable, add screenshots to help explain your problem. -->
### Additional context or thoughts
<!-- Add any other context about the problem here. -->
I think this is a build issue. `npm link` to local `swagger-client@3.19.0-alpha.3` was previously working for me. Also need to add npm script: `"link:apidom": "npm link @swagger-api/apidom-core @swagger-api/apidom-reference @swagger-api/apidom-ns-openapi-3-1 @swagger-api/apidom-ns-openapi-3-0 @swagger-api/apidom-ns-json-schema-draft-4 @swagger-api/apidom-json-pointer",`
supporting SwaggerUI branch: https://github.com/swagger-api/swagger-ui/tree/feat/oas31-support
supporting SwaggerUI draft PR: swagger-api/swagger-ui#8361 (will get superceded into next
branch)
Hi @tim-lai,
I've tested swagger-client@3.19.0-alpha.3 before it was published to npmjs.com and after against SwaggerUI master
branch. I've tested on Node.js=16.8.0
and there have been no issues.
Nevertheless, I've tested on also on Node.js=16.16.0
as you suggested, and had no issues installing nor running the npm run dev
. The webpack succuessfully built the code and run the SwaggerUI in browser on http://localhost:3200/
.
I'm attaching logs of running npm i --verbose
and npm run dev
on Node.js=16.16.0
.
install_log.txt
dev_script_log.txt
Conclusion
To prove my claims above, I've created following PR which triggered the CI and run following GA workflows jobs successfully: https://github.com/swagger-api/swagger-ui/actions/runs/4032722526/jobs/6932783574. The issue must be local to your dev env.
NOTE: in CI jobs,
build
fails on webpack bundle size limit which is exceeded by 120KB, as we're now pulling ApiDOM into SwaggerUI. Webpack optimization config needs to be re-configured to suppress this warning, but that's not important.