Skip to content
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

CLOUDP-303346: Add support for parameter aliases in OpenAPI spec #3698

Merged
merged 7 commits into from
Mar 4, 2025

Conversation

jeroenvervaeke
Copy link
Collaborator

@jeroenvervaeke jeroenvervaeke commented Mar 3, 2025

Proposed changes

  • Add support for parameter aliases in OpenAPI spec.
  • Added overlay to add projectId alias to all groupId parameters.
  • Flyby, improved extractExtensionsFromOperation to return operationExtensions instead of a tuple.

Jira ticket: CLOUDP-303346

@jeroenvervaeke jeroenvervaeke requested a review from a team as a code owner March 3, 2025 16:46
@jeroenvervaeke jeroenvervaeke marked this pull request as draft March 3, 2025 16:49
@mongodb mongodb deleted a comment from github-actions bot Mar 3, 2025
@jeroenvervaeke jeroenvervaeke marked this pull request as ready for review March 3, 2025 17:39
@@ -338,6 +344,10 @@ components:
description: Flag that indicates whether the response body should be in the <a href="https://en.wikipedia.org/wiki/Prettyprint" target="_blank" rel="noopener noreferrer">prettyprint</a> format.
in: query
name: pretty
x-xgen-atlascli:
flag-short: p
Copy link
Collaborator

Choose a reason for hiding this comment

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

p is usually a short for password, and we use it in a couple of places to avoid confusion I advise against it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a fixture in a unit test, I don't think the actual values are relevant here.

@@ -338,6 +344,10 @@ components:
description: Flag that indicates whether the response body should be in the <a href="https://en.wikipedia.org/wiki/Prettyprint" target="_blank" rel="noopener noreferrer">prettyprint</a> format.
in: query
name: pretty
Copy link
Collaborator

Choose a reason for hiding this comment

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

does pretty have any meaning for the CLI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is a fixture in a unit test, I don't think the actual values are relevant here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

as in isn't the CLI always pretty?

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh interesting seems like no after trying thi s

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But to reply to your question, it does not have a meaning to the CLI; it's just a regular parameter passed to the backend, and the CLI doesn't handle it any differently.

short: "",
}

getExtensionValues := func(extensionsMap map[string]any) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

any particular reason for an anonymous function? doesn't seem to be used as a callback or similar pattern of passing as an arg

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because of the captured ext variable and trying to avoid filling the namespace with all similarly named functions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that's probably a tell we may need better code organization, in lining the function because trying to name it causes confusing with other functions sound like a good time to think if this package needs some cleaning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've reorganized the code to get rid of the anonymous function

@@ -43,6 +43,7 @@ var Commands = GroupedAndSortedCommands{
IsArray: {{ .Type.IsArray }},
Type: `{{ .Type.Type }}`,
},
Aliases: []string{ {{ range $i, $alias := .Aliases }}{{if $i}},{{end}}`{{ $alias }}`{{end}} },
Copy link
Collaborator

Choose a reason for hiding this comment

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

can this be

Suggested change
Aliases: []string{ {{ range $i, $alias := .Aliases }}{{if $i}},{{end}}`{{ $alias }}`{{end}} },
{{if .Aliases }} Aliases: []string{ {{ range $i, $alias := .Aliases }}{{if $i}},{{end}}`{{ $alias }}`{{end}} }, {{end}}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was hesitating between what I have and what you suggested.
I've updated the code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I still se a couple of empty slices initialization which I was trying to avoid

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's fixed now. I blindly accepted the suggestion, but I forgot that there's a second piece of code that does the same thing.

update:
x-xgen-atlascli:
aliases:
- projectId
Copy link
Collaborator

@fmenezes fmenezes Mar 4, 2025

Choose a reason for hiding this comment

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

nit: it works the way it is, but currently, we have a small gap we can't provide the short version of the alias (we only provide --projectId but we don't have a way to provide a hypothetical -P)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion, I'll make the changes!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

fmenezes
fmenezes previously approved these changes Mar 4, 2025
Copy link
Collaborator

@fmenezes fmenezes left a comment

Choose a reason for hiding this comment

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

LGTM

gssbzn
gssbzn previously approved these changes Mar 4, 2025
Copy link
Collaborator

@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.

Thanks for the changes

@jeroenvervaeke jeroenvervaeke dismissed stale reviews from gssbzn and fmenezes via 199d837 March 4, 2025 12:04
Copy link
Collaborator

@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.

-P is a shorhand for profile

Copy link
Contributor

github-actions bot commented Mar 4, 2025

Coverage Report 📈

Branch Commit Coverage
master d5053c4 37.8%
CLOUDP-303346 c90c502 37.9%
Difference .1%

Copy link
Collaborator

@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

@jeroenvervaeke jeroenvervaeke merged commit 1267c75 into master Mar 4, 2025
22 checks passed
@jeroenvervaeke jeroenvervaeke deleted the CLOUDP-303346 branch March 4, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants