Skip to content

fixed index out of range of the matches at swagger.go:71 #31

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/go-chi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"log"
"net/http"

httpSwagger "github.com/Dysar/http-swagger"
Copy link
Contributor

@ubogdan ubogdan Aug 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wont accept a PR based on 3'rd party packages like github.com/Dysar/http-swagger

_ "github.com/Dysar/http-swagger/example/go-chi/docs" // docs is generated by Swag CLI, you have to import it.
"github.com/go-chi/chi"
httpSwagger "github.com/swaggo/http-swagger"
_ "github.com/swaggo/http-swagger/example/go-chi/docs" // docs is generated by Swag CLI, you have to import it.
)

// @title Swagger Example API
Expand Down
4 changes: 2 additions & 2 deletions example/gorilla/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"log"
"net/http"

httpSwagger "github.com/Dysar/http-swagger"
_ "github.com/Dysar/http-swagger/example/gorilla/docs" // docs is generated by Swag CLI, you have to import it.
"github.com/gorilla/mux"
httpSwagger "github.com/swaggo/http-swagger"
_ "github.com/swaggo/http-swagger/example/gorilla/docs" // docs is generated by Swag CLI, you have to import it.
)

// @title Swagger Example API
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/swaggo/http-swagger
module github.com/Dysar/http-swagger

go 1.13

Expand Down
7 changes: 5 additions & 2 deletions swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ func Handler(configFns ...func(*Config)) http.HandlerFunc {

return func(w http.ResponseWriter, r *http.Request) {
matches := re.FindStringSubmatch(r.RequestURI)
path := matches[2]
prefix := matches[1]
var path, prefix string
if len(matches) > 2 {
path = matches[2]
prefix = matches[1]
}

h := swaggerFiles.Handler
h.Prefix = prefix
Expand Down
2 changes: 1 addition & 1 deletion swagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"net/http/httptest"
"testing"

_ "github.com/Dysar/http-swagger/example/go-chi/docs"
"github.com/go-chi/chi"
"github.com/stretchr/testify/assert"
_ "github.com/swaggo/http-swagger/example/go-chi/docs"
)

func TestWrapHandler(t *testing.T) {
Expand Down