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 authored and Marcel Ludwig committed Dec 9, 2020
1 parent 062a9e4 commit a16854c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions config/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Backend struct {
RequestBodyLimit string `hcl:"request_body_limit,optional"`
TTFBTimeout string `hcl:"ttfb_timeout,optional"`
Timeout string `hcl:"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 @@ -86,8 +86,8 @@ func (b *Backend) Merge(other *Backend) (*Backend, []hcl.Body) {
result.Timeout = other.Timeout
}

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

if other.ValidateReq {
Expand Down
2 changes: 1 addition & 1 deletion handler/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (p *Proxy) prepareRequestValidation(outreq *http.Request) (context.Context,
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
4 changes: 2 additions & 2 deletions handler/proxy_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type ProxyOptions struct {
ConnectTimeout, Timeout, TTFBTimeout time.Duration
Context []hcl.Body
BackendName string
SwaggerDef string
OpenAPIFile string
ValidateReq, ValidateRes bool
CORS *CORSOptions
RequestBodyLimit int64
Expand Down Expand Up @@ -52,7 +52,7 @@ func NewProxyOptions(conf *config.Backend, corsOpts *CORSOptions, remainCtx []hc
RequestBodyLimit: bodyLimit,
TTFBTimeout: ttfbD,
Timeout: totalD,
SwaggerDef: conf.SwaggerDef,
OpenAPIFile: conf.OpenAPIFile,
ValidateReq: conf.ValidateReq,
ValidateRes: conf.ValidateRes,
}, nil
Expand Down

0 comments on commit a16854c

Please sign in to comment.