-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swagger-ui-react broken with react-scripts 5.0.0 #7893
Comments
This is due to the dependency on the unmaintained Related issue: #6869 |
There's also a transitive dependency on Buffer.
I'm hitting errors here when I try to use Swagger UI from a Vite.js application. safe-buffer works on Node.js, but doesn't work on browsers without a polyfill. Perhaps it's possible to write a function to generate a 32 bytes of base64 randomness without pulling in two dependencies that are written to run on Node.js? // adapted from https://auth0.com/docs/flows/guides/auth-code-pkce/includes/create-code-verifier
export function generateCodeVerifier() {
return b64toB64UrlEncoded(
randomBytes(32).toString("base64")
)
} Edit: made a PR that removes the dependency on |
So in your CreateReactApp project, you need to manually include these dependencies |
@tim-lai I'm really surprised this issue got closed. Are you saying a component, swagger-ui-react, clearly made specifically for react, is not meant to work out of the box with the standard way of creating react applications (react-scripts)? At the very least, there's some missing documentation telling people how to make use of it. (No, the links you provided are not that helpful). |
@haavardw I was having the same issue, and the best "solution" that I found is install
EDIT: There is another dependencies that I forgot to mention: "is-plain-object": "^5.0.0", |
I did some testing, and removing the dependency on Buffer from Node.js shouldn't is an option: #7898. That would let us avoid the polyfills. Note - there may be more work required. I only ran Swagger UI's unit tests, I expect more problems might show up when building. Tim commented that he'd welcome contributions to documentation - for the fix/walkaround. I went with something similar with @DanielFrontD's "solution" (:smile:). |
Q&A
To reproduce...
Steps to reproduce the behavior:
Expected behavior
Successful build
Actual behaviour
The text was updated successfully, but these errors were encountered: