swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.71k stars 1.2k forks source link

Swag v2.0.0-rc3 generated docs throws internal server error with echo framework #1588

Open vinodborole opened 1 year ago

vinodborole commented 1 year ago

Swag v2.0.0-rc3 generated docs throws internal server error with echo framework Internal Server Error doc.json with swag latest version and echo framework.

To Reproduce Steps to reproduce the behavior:

  1. Checkout official example - https://github.com/swaggo/echo-swagger/tree/master/example
  2. delete docs
  3. regenerate docs with latest swag v2.0.0-rc3 using swag init
  4. update the import in main.go pointing to your local docs just generated from step 3 example: [_ "github.com/vinodborole/swag-ex/docs"]
  5. go run main.go
  6. go to http://localhost:1323/swagger/index.html

Expected behavior swagger UI opens up without any error.

Screenshots Internal Server Error doc.json. Screenshot from 2023-05-22 08-28-33

Your swag version v2.0.0-rc3

Your go version 1.19

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Nerzal commented 1 year ago

Can you post the error, that is being thrown?

vinodborole commented 1 year ago

Hi @Nerzal

There is no error on the golang console, however this is what i see in the browsers developer tools

error

o-mago commented 1 year ago

I've found the same error here. I'm not using echo. Instead I was using https://github.com/swaggo/http-swagger. The problem is actually due to https://github.com/swaggo/echo-swagger/blob/master/go.mod and http-swagger depending on swag version 1.8.12. There is a open PR to solve this problem on the http-swagger: https://github.com/swaggo/http-swagger/pull/102 But I actually think they will update these dependencies only after the swag v2 stable release is available. Until then you can build your own html page (like a copy paste with the echo-swagger project, only one file)

gabrielmrts commented 1 year ago

any solution?

igorwgs commented 9 months ago

This https://github.com/swaggo/swag/issues/830#issuecomment-725587162 solved this issue.

talesmgodois commented 8 months ago

SO, just add the following line on the imports section

import (
    _ "<your_mod>/docs" // which is the generated folder after swag init
)
abdiltegar commented 7 months ago

SO, just add the following line on the imports section

import (
  _ "<your_mod>/docs" // which is the generated folder after swag init
)

Thank you so much, this solution work for me