Skip to content

Commit

Permalink
rename swagger_definition -> openapi_file (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Koch committed Sep 18, 2020
1 parent a970df9 commit 11d4d8b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions config/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Backend struct {
Path string `hcl:"path,optional"`
Timeout string `hcl:"timeout,optional"`
TTFBTimeout string `hcl:"ttfb_timeout,optional"`
SwaggerDef string `hcl:"swagger_definition,optional"`
OpenAPIFile string `hcl:"openapi_file,optional"`
ValidateReq bool `hcl:"validate_request,optional"`
ValidateRes bool `hcl:"validate_response,optional"`
}
Expand Down Expand Up @@ -65,8 +65,8 @@ func (b *Backend) Merge(other *Backend) (*Backend, []hcl.Body) {
result.TTFBTimeout = other.TTFBTimeout
}

if other.SwaggerDef != "" {
result.SwaggerDef = other.SwaggerDef
if other.OpenAPIFile != "" {
result.OpenAPIFile = other.OpenAPIFile
}

if other.ValidateReq {
Expand Down
8 changes: 4 additions & 4 deletions config/runtime/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func BuildEntrypointHandlers(conf *config.Gateway, httpConf *HTTPConfig, log *lo
Path: beConf.Path,
Timeout: t,
TTFBTimeout: ttfbt,
SwaggerDef: beConf.SwaggerDef,
OpenAPIFile: beConf.OpenAPIFile,
ValidateReq: beConf.ValidateReq,
ValidateRes: beConf.ValidateRes,
}, log, conf.Context)
Expand Down Expand Up @@ -196,7 +196,7 @@ func BuildEntrypointHandlers(conf *config.Gateway, httpConf *HTTPConfig, log *lo
Path: beConf.Path,
Timeout: t,
TTFBTimeout: ttfbt,
SwaggerDef: beConf.SwaggerDef,
OpenAPIFile: beConf.OpenAPIFile,
ValidateReq: beConf.ValidateReq,
ValidateRes: beConf.ValidateRes,
}, log, conf.Context)
Expand Down Expand Up @@ -268,7 +268,7 @@ func BuildEntrypointHandlers(conf *config.Gateway, httpConf *HTTPConfig, log *lo
Path: beConf.Path,
Timeout: t,
TTFBTimeout: ttfbt,
SwaggerDef: beConf.SwaggerDef,
OpenAPIFile: beConf.OpenAPIFile,
ValidateReq: beConf.ValidateReq,
ValidateRes: beConf.ValidateRes,
}, log, conf.Context)
Expand Down Expand Up @@ -452,7 +452,7 @@ func newInlineBackend(evalCtx *hcl.EvalContext, inlineDef hcl.Body, cors *config
Path: beConf.Path,
Timeout: t,
TTFBTimeout: ttfbt,
SwaggerDef: beConf.SwaggerDef,
OpenAPIFile: beConf.OpenAPIFile,
ValidateReq: beConf.ValidateReq,
ValidateRes: beConf.ValidateRes,
}, log, evalCtx)
Expand Down
2 changes: 1 addition & 1 deletion couper.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ server "couperConnect" {
endpoint "/httpbin/**" {
backend "httpbin" {
path = "/**"
swagger_definition = "./upstream/httpbin.yaml"
openapi_file = "./upstream/httpbin.yaml"
validate_request = true
validate_response = true

Expand Down
4 changes: 2 additions & 2 deletions handler/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type ProxyOptions struct {
ConnectTimeout, Timeout, TTFBTimeout time.Duration
Context []hcl.Body
BackendName string
Hostname, Origin, Path, SwaggerDef string
Hostname, Origin, Path, OpenAPIFile string
ValidateReq, ValidateRes bool
CORS *CORSOptions
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func (p *Proxy) preparetRequestValidatation(outreq *http.Request) (context.Conte
if err != nil {
return nil, nil, nil, err
}
router := openapi3filter.NewRouter().WithSwaggerFromFile(dir + "/" + p.options.SwaggerDef)
router := openapi3filter.NewRouter().WithSwaggerFromFile(dir + "/" + p.options.OpenAPIFile)
validationCtx := context.Background()
route, pathParams, _ := router.FindRoute(outreq.Method, outreq.URL)

Expand Down

0 comments on commit 11d4d8b

Please sign in to comment.