Skip to content
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
2 changes: 1 addition & 1 deletion builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
package swag

import "github.com/savaki/swag/swagger"
import "github.com/ctwyw/swag/swagger"

// Builder uses the builder pattern to generate a swagger definition
type Builder struct {
Expand Down
5 changes: 3 additions & 2 deletions endpoint/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"strconv"
"strings"

"github.com/savaki/swag/swagger"
"github.com/ctwyw/swag/swagger"
)

// Builder uses the builder pattern to generate swagger endpoint definitions
Expand Down Expand Up @@ -101,13 +101,14 @@ func Path(name, typ, description string, required bool) Option {

// Query defines a query parameter for the endpoint; name, typ, description, and required correspond to the matching
// swagger fields
func Query(name, typ, description string, required bool) Option {
func Query(name, typ, description, def string, required bool) Option {
p := swagger.Parameter{
Name: name,
In: "query",
Type: typ,
Description: description,
Required: required,
Default: def,
}
return parameter(p)
}
Expand Down
6 changes: 3 additions & 3 deletions swagger/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func (a *API) AddEndpoint(e *Endpoint) {

// Handler is a factory method that generates an http.HandlerFunc; if enableCors is true, then the handler will generate
// cors headers
func (a *API) Handler(enableCors bool) http.HandlerFunc {
func (a *API) Handler(host string, enableCors bool) http.HandlerFunc {
mux := &sync.Mutex{}
byHostAndScheme := map[string]*API{}

Expand Down Expand Up @@ -364,8 +364,8 @@ func (a *API) Handler(enableCors bool) http.HandlerFunc {
v, ok := byHostAndScheme[hostAndScheme]
if !ok {
v = a.clone()
v.Host = req.Host
v.Schemes = []string{scheme}
v.Host = host
v.Schemes = []string{"https", "http"}
byHostAndScheme[hostAndScheme] = v
}
mux.Unlock()
Expand Down
1 change: 1 addition & 0 deletions swagger/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ type Parameter struct {
Schema *Schema `json:"schema,omitempty"`
Type string `json:"type,omitempty"`
Format string `json:"format,omitempty"`
Default string `json:"default,omitempty"`
}

// Endpoint represents an endpoint from the swagger doc
Expand Down