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.44k stars 8.94k forks source link

Add support for PnP, fix deps #7722

Closed simPod closed 5 months ago

simPod commented 2 years ago

Is your feature request related to a problem?

I'm using Yarn PnP and swagger ui seems not to support it as it complains about missing dependencies, e.g.

Module not found: Error: Can't resolve 'cookie' in '/path/.yarn/virtual/swagger-ui-react-virtual-559452a1d4/0/cache/swagger-ui-react-npm-4.1.3-89d3cb5de1-dd02f1193d.zip/node_modules/swagger-ui-react'

I've stumbled upon https://github.com/swagger-api/swagger-ui/issues/7556 where other people already mentioned the same problem with

autolinker
btoa
cookie
fast-json-patch
formdata-node
isarray
qs
regenerator-runtime
traverse

Describe the solution you'd like

Support Yarn PnP, fix project deps.

Describe alternatives you've considered

The suggested solution in the linked issue was to use old node_modules way but that's not a solution but workaround and no because it burns my laptop alive.

image

JeremyKennedy commented 2 years ago

Six months since I last looked into this. Today, I was hoping to switch my project to PnP. Swagger is the only blocker. I'm sad to see this still isn't fixed. To get it working, I have to use swagger-ui-react@4.1.3 - 4.2.1 breaks it, and future versions (4.12.0) don't fix it. I also have to yarn add the dependencies mentioned above. Super lame.

I've given up on swagger-ui-react after finding a workaround that works for me, using UNPKG rather than including the dependency in my project: https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/installation.md#unpkg

It works well and means I don't need any of the swagger deps in my project anymore. I just include a static html file and I can pass my configs just like I did with the regular package.

simPod commented 1 year ago

Now only Module not found: Error: Can't resolve 'repeat-string' is to be fixed. The rest is resolved.

simPod commented 5 months ago

This seems to no longer be the case.