Skip to content
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

Got error: Uncaught Invariant Violation: Minified React error #37, possible fix is provided. #69

Open
yeehenchen opened this issue May 3, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@yeehenchen
Copy link

yeehenchen commented May 3, 2022

Versions:

swaggo/swag v1.8.1
swaggo/http-swagger v1.2.7

Describe the bug:

Recently I am trying to initiate a project with swaggo then encountered this error Uncaught Invariant Violation: Minified React error #37

image

I couldn't provide complete steps to reproduce this error because it's a new project that generated from a template automatically. But the main steps are:
First go get github.com/swaggo/swag, then swag init to generate /docs/swagger directory with docs.go, swagger.json and swagger.yaml files.

// routes.go setup
router.Mount("/docs/", httpSwagger.WrapHandler)

Then go to http://localhost:_port_/docs/index.html to see the blank page.
So there's actually no too much customization.

Solution

After searching a bit I found a similar issue in swagger-ui: swagger-api/swagger-ui#5608.

I've successfully fixed this error locally by changing the default dom_id here to #swagger-ui:

DomID: "swagger-ui",

e.g.

func newConfig(configFns ...func(*Config)) *Config {
	config := Config{
		...
		DomID:                "#swagger-ui",
		...
	}

	...
}

Please let me know if any concerns, it will not block my progress since I'll switch to edit the swagger doc manually, so not urgent here. 😄

@ubogdan
Copy link
Contributor

ubogdan commented May 3, 2022

I'm aware of this issue. Hopefully, I will be able to write a PR and push a release this week.

@ubogdan ubogdan added the bug Something isn't working label May 3, 2022
@yeehenchen
Copy link
Author

@ubogdan Thanks for your quick response and your work!!

@ubogdan
Copy link
Contributor

ubogdan commented May 3, 2022

fix added to v1.2.8 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants