Skip to content

Conversation

lovisaberggren
Copy link
Collaborator

@lovisaberggren lovisaberggren commented Jan 13, 2025

Proposed changes

Updates the FOAS CLI to remove the x-xgen-ipa-exception extensions from the version split oases.

Jira ticket: CLOUDP-292068

Checklist

  • I have signed the MongoDB CLA
  • I have added tests that prove my fix is effective or that my feature works

@lovisaberggren lovisaberggren marked this pull request as ready for review January 13, 2025 17:52
@lovisaberggren lovisaberggren requested a review from a team as a code owner January 13, 2025 17:52

// Filter: ExtensionFilter is a filter that updates the x-sunset and x-xgen-version extensions to a date string
// and deletes the x-sunset extension if the latest matched version is deprecated by hidden versions
// Filter: ExtensionFilter is a filter that deleted the x-xgen-ipa-exception extensions, updates the x-sunset and x-xgen-version
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Filter: ExtensionFilter is a filter that deleted the x-xgen-ipa-exception extensions, updates the x-sunset and x-xgen-version
// ExtensionFilter is a filter that deleted the x-xgen-ipa-exception extensions, updates the x-sunset and x-xgen-version

Copy link
Collaborator Author

@lovisaberggren lovisaberggren Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like if removing the Filter: in the comments, they're removed form the generated README.md, the script assumes the line starts with Filter:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @blva godocs should start with the method name any reason we don't follow that rule here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just followed a format I found in oasdiff to update the docs: https://github.com/mongodb/openapi/blob/main/tools/cli/scripts/doc_filters.sh

This can be fixed in a separate JIRA / PR if we want to udpate it everywhere, I think it's easy to update but I don't have the bandwidth right now

updateExtensionToDateString(operation.Extensions)
deleteIpaExceptionExtension(operation.Extensions)

for _, parameter := range operation.Parameters {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐻 with me this is a bit messy but need to look at the code in an editor to help you a bit

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup it's a bit messy, happy to get feedback on this one 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to break the code into separate functions, with each function handling a specific component type? It might make the code easier to follow and maintain

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yelizhenden-mdb 💯 yes that was one approach but I think filtering in general needs some love
I haven't really have the time to go deeper here since I found other stuff in the repo that needed fixing like some improved linting but you can split this in functions and leverage the fact that go encourage argument modification, is quite common in go to name an argument out to flag it will be modified by the function

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split some parts to more functions, let me know if it's a bit better.

is quite common in go to name an argument out to flag it will be modified by the function

Not sure what you mean here, unless you mean naming the parameter to out

}
}

func TestExtensionFilter_removeIpaException(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these seem like test cases see for how we do test cases in go

testCases := []struct {
name string
contentType string
expectedMatch string
wantErr bool
}{

Copy link
Contributor

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lovisaberggren lovisaberggren merged commit 5c4fae9 into main Jan 15, 2025
11 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-292068 branch January 15, 2025 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants