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 middleware_builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (he *httpError) StatusCode() int {
}

func (he *httpError) ErrorMessage() interface{} {
return he
return he.Message
}

func (he *httpError) Error() string {
Expand Down
2 changes: 1 addition & 1 deletion v3/middleware_builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (he *httpError) StatusCode() int {
}

func (he *httpError) ErrorMessage() interface{} {
return he
return he.Message
}

func (he *httpError) Error() string {
Expand Down
7 changes: 6 additions & 1 deletion v3/swagger/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ type HandlerInfo struct {

// Options is a container of optional settings to configure a plugin.
type Options struct {
SwaggerJSONPath string
Object *Object
DefinitionNameModifier func(refT reflect.Type, defName string) string
IgnoreRoute func(rd *ucon.RouteDefinition) bool
Expand All @@ -143,6 +144,10 @@ func NewPlugin(opts *Options) *Plugin {
opts = &Options{}
}

if opts.SwaggerJSONPath == "" {
opts.SwaggerJSONPath = "/api/swagger.json"
}

so := opts.Object

if so == nil {
Expand Down Expand Up @@ -187,7 +192,7 @@ func (p *Plugin) HandlersScannerProcess(m *ucon.ServeMux, rds []*ucon.RouteDefin
}

// supply swagger.json endpoint
m.HandleFunc("GET", "/api/swagger.json", func(w http.ResponseWriter, r *http.Request) *Object {
m.HandleFunc("GET", p.options.SwaggerJSONPath, func(w http.ResponseWriter, r *http.Request) *Object {
return soConstructor.object
})

Expand Down