Skip to content

[Bug] Exclude webhooks when filter is provided #734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/_OpenAPIGeneratorCore/Hooks/FilteredDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ struct FilteredDocumentBuilder {
}
}
filteredDocument.components = components
// Always remove webhooks, as they may contain references to schemas that were not included.
// Webhooks are not supported for filtering, so whenever a filter is used, all webhooks are excluded.
filteredDocument.webhooks = [:]
return filteredDocument
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ final class Test_FilteredDocument: XCTestCase {
$ref: '#/components/schemas/B'
Empty:
description: success
webhooks:
my-webhook:
post:
description: Webhook
responses:
'200':
description: OK
"""
let document = try YAMLDecoder().decode(OpenAPI.Document.self, from: documentYAML)
assert(filtering: document, filter: DocumentFilter(), hasPaths: [], hasOperations: [], hasSchemas: [])
Expand Down Expand Up @@ -192,5 +199,6 @@ final class Test_FilteredDocument: XCTestCase {
file: file,
line: line
)
XCTAssertUnsortedEqual(filteredDocument.webhooks.keys, [], "Webhooks don't match", file: file, line: line)
}
}