Skip to content

feat: autogenerate go SDK example in the codeSample #772

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

andreaangiolillo
Copy link
Collaborator

@andreaangiolillo andreaangiolillo commented Jun 13, 2025

Proposed changes

This PR adds autogenerated example of the GO SDK in the openapi specification.

You can preview how the documentation will look using this bump.sh link

Redocly:

Screenshot 2025-06-13 at 14 42 26

@andreaangiolillo andreaangiolillo marked this pull request as ready for review June 13, 2025 12:37
@andreaangiolillo andreaangiolillo requested a review from a team as a code owner June 13, 2025 12:37
@@ -15,10 +15,14 @@
package filter

import (
"fmt"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main changes were in this file. The files under tests were autogenerated.

@@ -121,6 +125,41 @@ func newAtlasCliCodeSamplesForOperation(op *openapi3.Operation) codeSample {
}
}

func (f *CodeSampleFilter) newGoSdkCodeSamplesForOperation(op *openapi3.Operation, opMethod string) codeSample {
version := strings.ReplaceAll(apiVersion(f.metadata.targetVersion), "-", "") + "001"
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 field represents the SDK version. The value is formatted as YYYY-MM-DD-001, where 001 indicates the first SDK release for that API version. The last three digits are incremented for subsequent releases, but 001 will always be available as the initial version for each API version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit curious on how this version stays in sync with the latest SDK version:

  1. Is this reference to the SDK version always being published before SDK?
  2. Or there is a mechanism for reading the latest SDK version?

Copy link
Collaborator Author

@andreaangiolillo andreaangiolillo Jun 13, 2025

Choose a reason for hiding this comment

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

No, neither of those options apply. I generate the SDK version by combining the API version in the format YYYY-DD.MM with 001 as the suffix, which represents the first release for any new API version and is always present. Subsequent releases for the same API version will follow the format YYYY-DD.MM-002, YYYY-DD.MM-003, and so on, but the example will always use the initial 001 release.
If I merge this, I will then create a ticket to improve this to check for the release in the sdk repo but I don't think is critical for the initial example since the 001 is always present.

@andreaangiolillo andreaangiolillo requested review from a team, wtrocki and EspenAlbert June 13, 2025 12:41
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.

3 participants