fix(api): omit disabled graphql playground spec metadata
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
a3a1c20e7a
commit
8dd15251ea
2 changed files with 10 additions and 3 deletions
10
openapi.go
10
openapi.go
|
|
@ -123,10 +123,14 @@ func (sb *SpecBuilder) Build(groups []RouteGroup) ([]byte, error) {
|
|||
}
|
||||
if graphqlPath := sb.effectiveGraphQLPath(); graphqlPath != "" {
|
||||
spec["x-graphql-path"] = normaliseOpenAPIPath(graphqlPath)
|
||||
spec["x-graphql-playground"] = sb.GraphQLPlayground
|
||||
if sb.GraphQLPlayground {
|
||||
spec["x-graphql-playground"] = true
|
||||
}
|
||||
}
|
||||
if playgroundPath := sb.effectiveGraphQLPlaygroundPath(); playgroundPath != "" {
|
||||
spec["x-graphql-playground-path"] = normaliseOpenAPIPath(playgroundPath)
|
||||
if sb.GraphQLPlayground {
|
||||
if playgroundPath := sb.effectiveGraphQLPlaygroundPath(); playgroundPath != "" {
|
||||
spec["x-graphql-playground-path"] = normaliseOpenAPIPath(playgroundPath)
|
||||
}
|
||||
}
|
||||
if wsPath := sb.effectiveWSPath(); wsPath != "" {
|
||||
spec["x-ws-path"] = normaliseOpenAPIPath(wsPath)
|
||||
|
|
|
|||
|
|
@ -562,6 +562,9 @@ func TestSpecBuilder_Good_GraphQLEndpoint(t *testing.T) {
|
|||
if !found {
|
||||
t.Fatal("expected graphql tag in spec")
|
||||
}
|
||||
if _, ok := spec["x-graphql-playground"]; ok {
|
||||
t.Fatal("expected x-graphql-playground to be omitted when playground is disabled")
|
||||
}
|
||||
|
||||
paths := spec["paths"].(map[string]any)
|
||||
pathItem, ok := paths["/graphql"].(map[string]any)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue