swagger-api / swagger-ui

Swagger UI is a collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API.
https://swagger.io
Apache License 2.0
26.56k stars 8.96k forks source link

swagger-ui npm module doesn't compile with Angular 8 #5797

Open jonathan-silva opened 4 years ago

jonathan-silva commented 4 years ago

Q&A (please complete the following information) Browser: n/a Method of installation: npm Swagger-UI version: 3.19.5 Swagger/OpenAPI version: n/a Angular version: 8.2.14

Angular application compiles with an error: image

then run npm start and you will get an error

Additional context or thoughts A buffer@5.2.1 dependency was added because it was complaining about another mistake. Added, complained about this error

"Uncaught TypeError: Cannot read property 'slice' of undefined"

Anyone with an idea of ​​the problem would be very grateful for the help.

Thanks

zdavis commented 4 years ago

Seeing the same issue, same error trying to import this into a React app (with a Webpack build process)

zdavis commented 4 years ago

I was able to work around this by mocking process.version in the browser. Any attempt to import swagger-ui (directly or implicitly through swagger-ui-react) would lead to the error above. Our application mocks the process object that's present in a Node application, and I was able to work around this error by adding process.version to that mocked object. I got there via this issue: https://github.com/nodejs/readable-stream/issues/313