-
Notifications
You must be signed in to change notification settings - Fork 15
fix: Fix foascli sunset list to print sunset endpoints with deterministic order
#804
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
Changes from 7 commits
d9220a9
c6386e1
2e0c99d
2718af1
653ea9d
55d7c7d
50098e5
9cd52d2
e3c42ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,11 @@ | |
| package sunset | ||
|
|
||
| import ( | ||
| "maps" | ||
| "regexp" | ||
| "slices" | ||
| "sort" | ||
|
|
||
| "github.com/getkin/kin-openapi/openapi3" | ||
| "github.com/tufin/oasdiff/load" | ||
| ) | ||
|
|
@@ -95,8 +100,21 @@ func successResponseExtensions(responsesMap map[string]*openapi3.ResponseRef) ma | |
| } | ||
|
|
||
| func contentExtensions(content openapi3.Content) map[string]any { | ||
| for _, v := range content { | ||
| return v.Extensions | ||
| } | ||
| return nil | ||
| keysContent := slices.Collect(maps.Keys(content)) | ||
| // Regex to find a date in YYYY-MM-DD format. | ||
| dateRegex := regexp.MustCompile(`\d{4}-\d{2}-\d{2}`) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. q: What about upcoming and preview?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Regarding
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will create a follow up ticket for |
||
| // we need the content of the API version with the older date. | ||
| sort.Slice(keysContent, func(i, j int) bool { | ||
| dateI := dateRegex.FindString(keysContent[i]) | ||
| dateJ := dateRegex.FindString(keysContent[j]) | ||
|
|
||
| // If both have dates, compare them as strings. | ||
| if dateI != "" && dateJ != "" { | ||
| return dateI < dateJ | ||
| } | ||
| // Strings with dates should come before those without. | ||
| return dateI != "" | ||
| }) | ||
|
|
||
| return content[keysContent[0]].Extensions | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.