echo-swagger icon indicating copy to clipboard operation
echo-swagger copied to clipboard

two or more swagger html on the same app

Open srPuebla opened this issue 2 years ago • 5 comments

Hi,

In my app, i have endpoints published in the main app ( at the URL /swagger/ ) and i have another one, with admin endpoints (for example)

import (
echoSwagger "github.com/swaggo/echo-swagger"
...
)
On the main...:

	url := echoSwagger.URL("admin.json")
	echo.GET("/admin/swagger/*", echoSwagger.EchoWrapHandler(url))
	echo.GET("/swagger/*", echoSwagger.WrapHandler)

I am finding problems with this solution, cause each time that i load something of "/admin/swagger/", the main swagger stops to work.

Is posible to perform this?

Thanks!!

srPuebla avatar Oct 27 '21 12:10 srPuebla

try

	url := echoSwagger.URL("admin.json")
	echo.GET("/admin/swagger/*", echoSwagger.EchoWrapHandler(url))
	echo.GET("/swagger/*", echoSwagger.EchoWrapHandler())

ubogdan avatar Oct 27 '21 13:10 ubogdan

try

	url := echoSwagger.URL("admin.json")
	echo.GET("/admin/swagger/*", echoSwagger.EchoWrapHandler(url))
	echo.GET("/swagger/*", echoSwagger.EchoWrapHandler())

Hi, thanks for reply so quickly.

I tried it, but when i load "admin" swagger on browser, the "main" swagger stops to works and it drops 404. Maybe with this part of code is the problem: https://github.com/swaggo/echo-swagger/blob/f298ba3e5d9a0cfe087b463b285dc648978a6b7a/swagger.go#L53

Thats why i am asking.

srPuebla avatar Oct 27 '21 14:10 srPuebla

:smile: Not really, the problem is caused by the fact we are reusing swaggerFiles.Handler.

ubogdan avatar Oct 27 '21 17:10 ubogdan

Thanks ubogdan for the fast reply!

srPuebla avatar Oct 27 '21 18:10 srPuebla

The issue was addressed and the fix will be included in v1.1.5.

ubogdan avatar Oct 27 '21 18:10 ubogdan