Skip to content

Commit 28c4c0e

Browse files
fix: update the sunset filter to remove the 9999-12-01 also from the operation extension. (#620)
1 parent c596360 commit 28c4c0e

File tree

2 files changed

+392
-291
lines changed

2 files changed

+392
-291
lines changed

tools/cli/internal/openapi/filter/sunset.go

+10
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ func (f *SunsetFilter) Apply() error {
4949
return nil
5050
}
5151

52+
// applyOnOperation removes the "sunset" extension if its value is set to "sunsetToBeDecided".
53+
// The "sunset" extension can be located in two places.
54+
// 1) Within the 20X response.
55+
// 2) As part of the operation itself.
5256
func applyOnOperation(op *openapi3.Operation) {
57+
// 1) Check the "sunset" extension in the response
5358
for key, response := range op.Responses.Map() {
5459
if !strings.HasPrefix(key, "20") {
5560
continue
@@ -61,4 +66,9 @@ func applyOnOperation(op *openapi3.Operation) {
6166
})
6267
}
6368
}
69+
70+
// 2) Check the "sunset" extension as part of the operation
71+
maps.DeleteFunc(op.Extensions, func(_ string, v any) bool {
72+
return v == sunsetToBeDecided
73+
})
6474
}

0 commit comments

Comments
 (0)