swagger-ui npm module doesn't compile with Angular 7
See original GitHub issueQ&A (please complete the following information)
- OS: Windows 10
- Browser: n/a
- Version: n/a
- Method of installation: npm
- Swagger-UI version: 3.19.4
- Swagger/OpenAPI version: n/a
- Angular version: 7.0.1
Describe the bug you’re encountering
Angular application compiles with an error:
Date: 2018-10-25T15:05:14.379Z
Hash: f05c6339336aa563f08a
Time: 11370ms
chunk {main} main.js, main.js.map (main) 12.7 kB [initial] [rendered]
ERROR in ./node_modules/xml/lib/xml.js
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 228 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.22 kB [entry] [rendered]
Module not found: Error: Can't resolve 'stream' in '.\node_modules\xml\lib'
chunk {styles} styles.js, styles.js.map (styles) 17 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.77 MB [initial] [rendered]
i 「wdm」: Failed to compile.
To reproduce…
Create a new Angular project then do npm install swagger-ui
and add code to the app.component.ts:
import { SwaggerUI } from 'swagger-ui';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.sass']
})
export class AppComponent implements OnInit {
ngOnInit() {
SwaggerUI({
dom_id: '#swagger-ui',
urls: [{
url: 'any proper url',
name: 'API name'
}]
});
}
}
then run npm start
and you will get an error
Expected behavior
Compile an application without any errors
Additional context or thoughts
I think xml
dependency requires stream
lib, which is a part of node.js core and it’s not compiled with Angular.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
swagger-ui - npm
swagger -ui-dist is a dependency-free module that includes everything you need to serve Swagger UI in a server-side project, or a single-page ...
Read more >node js error while running swagger project - Stack Overflow
Node doesn't support ES6 imports out of the box. This feature is still experimental. You have 2 solutions : Use require :.
Read more >Creating libraries - Angular
To make your solution reusable, you need to adjust it so that it does not ... Use the Angular CLI and the npm...
Read more >Swagger Editor Documentation
The Swagger Editor is an open source editor to design, define and document RESTful APIs in the Swagger Specification. The source code for...
Read more >How to add Swagger UI to an existing Node.js and Express.js ...
Swagger Inspector allows you to easily validate and test APIs with no limits on what you test. Tests are automatically saved in the...
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
Okay, I’ve forked
xml
successfully.Based on @KutsenkoA’s example repository, this appears to be fixed once I link the example project to my local version of Swagger UI, which contains the fix in the PR linked above this comment:
I’m sorry, but you do: https://github.com/swagger-api/swagger-ui/blob/9a9b63634fdbe1de0556818fdb78e211c4e2fa83/package.json#L80
Sure - https://github.com/KutsenkoA/imhotep