diff --git a/middleware/context.go b/middleware/context.go index 87c6ea38..f2cade3c 100644 --- a/middleware/context.go +++ b/middleware/context.go @@ -307,6 +307,9 @@ type contentTypeValue struct { // BasePath returns the base path for this API func (c *Context) BasePath() string { + if c.spec == nil { + return "" + } return c.spec.BasePath() }