Support swagger module with AMD imports?
See original GitHub issueI am using swagger-codegen to generate swagger js client. However, it is hard to import the client module.
Environment
node -v
: 8.1.4npm -v
: 5.4.2yarn --version
(if you use Yarn): 1.1.0npm ls react-scripts
(if you haven’t ejected): 1.0.14
Then, specify:
- Operating system: MAC OSX
- Browser and version (if relevant): chrome
Steps to Reproduce
- install swagger-codegen and generate javascript project according to some api spec
- install local swagger module according to README.md file in the generated swagger project
- import the module in the react project ant it shows:
Module not found: Can't resolve 'ApiClient' in /path/to/API
Expected Behavior
No error
Actual Behavior
In swagger issue 3537. It discusses this issue and bring 2 solutions:
Disabling directly edit the code source :
// commenting the first IF branch
//if (typeof define === 'function' && define.amd) {
// // AMD. Register as an anonymous module.
// define(['superagent'], factory);
//} else
if (typeof module === 'object' && module.exports) {
// CommonJS-like environments that support module.exports, like Node.
module.exports = factory(require('superagent'));
}
or via Webpack configs:
npm install --save-dev imports-loader
// and then add this loader to the webpack configs
{ test: /\.js/, loader: 'imports?define=>false'}
Since, it is not advised to revise the react-scripts, could create-react-app support swagger client imports?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Micronaut Open API - OpenAPI/Swagger Support
OpenAPIDefinition; import io.swagger.v3.oas.annotations.info. ... (Swagger) YAML for built-in endpoints or paths from some other modules, such as security .
Read more >Installation - Swagger Documentation
The module, when imported, includes an absolutePath helper function that returns the absolute filesystem path to where the swagger-ui-dist module is ...
Read more >How to bundle Swagger generated code with webpack
I found a solution, I need to add the following in my webpack.config.js module: { rules: [ { test: /my_client\/.
Read more >Building REST API with Express, TypeScript and Swagger
How to build REST API server with Express & TypeScript, and auto-generate OpenAPI documentation with Swagger.
Read more >API with NestJS #60. The OpenAPI specification and Swagger
We use the OpenAPI and Swagger to create a user interface that serves as interactive API documentation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@seanlaff When it comes to node_modules, CRA only compiles standard language features (not class properties). See https://github.com/facebook/create-react-app/pull/3776
Using the
useES6
flag in the swagger generation is a way to get around the AMD problem, however Im seeing the same errors @john-goldsmith saw about class fieldsSupport for the experimental syntax 'classProperties' isn't currently enabled
Which is odd because I know CRA supports that transform