Skip to content

Commit

Permalink
Hook not needed
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Broadhurst <peter.broadhurst@kaleido.io>
  • Loading branch information
peterbroadhurst committed Sep 13, 2023
1 parent 2b02803 commit 151b544
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
7 changes: 1 addition & 6 deletions pkg/ffapi/openapi3.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ type SwaggerGenOptions struct {
APIDefaultFilterLimit string
APIMaxFilterLimit uint
SupportFieldRedaction bool
PostGenerateHook func(doc *openapi3.T)

RouteCustomizations func(ctx context.Context, sg *SwaggerGen, route *Route, op *openapi3.Operation)
RouteCustomizations func(ctx context.Context, sg *SwaggerGen, route *Route, op *openapi3.Operation)
}

type BaseURLVariable struct {
Expand Down Expand Up @@ -107,9 +105,6 @@ func (sg *SwaggerGen) Generate(ctx context.Context, routes []*Route) *openapi3.T
sg.addRoute(ctx, doc, route)
opIds[route.Name] = true
}
if sg.options.PostGenerateHook != nil {
sg.options.PostGenerateHook(doc)
}
return doc
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/ffapi/openapi3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ func TestPreTranslatedRouteDescription(t *testing.T) {
assert.Equal(t, "this is a description", description)
}

func TestBaseURLVariablesAndHook(t *testing.T) {
func TestBaseURLVariables(t *testing.T) {
doc := NewSwaggerGen(&SwaggerGenOptions{
Title: "UnitTest",
Version: "1.0",
Expand All @@ -379,9 +379,6 @@ func TestBaseURLVariablesAndHook(t *testing.T) {
Default: "default-value",
},
},
PostGenerateHook: func(doc *openapi3.T) {
doc.Info.Title = "modified-by-hook"
},
}).Generate(context.Background(), testRoutes)
err := doc.Validate(context.Background())
assert.NoError(t, err)
Expand All @@ -394,5 +391,4 @@ func TestBaseURLVariablesAndHook(t *testing.T) {
b, err := yaml.Marshal(doc)
assert.NoError(t, err)
fmt.Print(string(b))
assert.Contains(t, string(b), "modified-by-hook")
}

0 comments on commit 151b544

Please sign in to comment.