@@ -23,6 +23,7 @@ import (
2323 "github.com/stretchr/testify/require"
2424)
2525
26+ //nolint:funlen // Test cases require long function for comprehensive coverage
2627func TestCodeSampleFilter (t * testing.T ) {
2728 testCases := []struct {
2829 name string
@@ -352,6 +353,97 @@ func TestCodeSampleFilter(t *testing.T) {
352353 })),
353354 },
354355 },
356+ {
357+ name : "stable api with x-xgen-operation-id-override" ,
358+ version : "2025-01-01" ,
359+ oas : & openapi3.T {
360+ Paths : openapi3 .NewPaths (openapi3 .WithPath ("/test" , & openapi3.PathItem {
361+ Get : & openapi3.Operation {
362+ OperationID : "testOperationID" ,
363+ Summary : "testSummary" ,
364+ Responses : openapi3 .NewResponses (openapi3 .WithName ("200" , & openapi3.Response {
365+ Content : openapi3.Content {
366+ "application/vnd.atlas.2025-01-01+json" : {
367+ Schema : & openapi3.SchemaRef {
368+ Ref : "#/components/schemas/PaginatedAppUserView" ,
369+ },
370+ Extensions : map [string ]any {
371+ "x-gen-version" : "2025-01-01" ,
372+ },
373+ },
374+ },
375+ })),
376+ Tags : []string {"TestTag" },
377+ Extensions : map [string ]any {
378+ "x-sunset" : "9999-12-31" ,
379+ "x-xgen-operation-id-override" : "customOperationName" ,
380+ },
381+ },
382+ })),
383+ },
384+ expectedOas : & openapi3.T {
385+ Paths : openapi3 .NewPaths (openapi3 .WithPath ("/test" , & openapi3.PathItem {
386+ Get : & openapi3.Operation {
387+ OperationID : "testOperationID" ,
388+ Summary : "testSummary" ,
389+ Responses : openapi3 .NewResponses (openapi3 .WithName ("200" , & openapi3.Response {
390+ Content : openapi3.Content {
391+ "application/vnd.atlas.2025-01-01+json" : {
392+ Schema : & openapi3.SchemaRef {
393+ Ref : "#/components/schemas/PaginatedAppUserView" ,
394+ },
395+ Extensions : map [string ]any {
396+ "x-gen-version" : "2025-01-01" ,
397+ },
398+ },
399+ },
400+ })),
401+ Tags : []string {"TestTag" },
402+ Extensions : map [string ]any {
403+ "x-sunset" : "9999-12-31" ,
404+ "x-xgen-operation-id-override" : "customOperationName" ,
405+ "x-codeSamples" : []codeSample {
406+ {
407+ Lang : "cURL" ,
408+ Label : "Atlas CLI" ,
409+ Source : "atlas api testTag customOperationName --help" ,
410+ },
411+ {
412+ Lang : "go" ,
413+ Label : "Go" ,
414+ Source : "import (\n " +
415+ "\t \" os\" \n \" context\" \n " + "\t \" log\" \n " +
416+ "\t sdk \" go.mongodb.org/atlas-sdk/v20250101001/admin\" \n )\n \n " +
417+ "func main() {\n " +
418+ "\t ctx := context.Background()\n " +
419+ "\t clientID := os.Getenv(\" MONGODB_ATLAS_CLIENT_ID\" )\n " +
420+ "\t clientSecret := os.Getenv(\" MONGODB_ATLAS_CLIENT_SECRET\" )\n \n " +
421+ "\t // See https://dochub.mongodb.org/core/atlas-go-sdk-oauth\n " +
422+ "\t client, err := sdk.NewClient(sdk.UseOAuthAuth(clientID, clientSecret))\n \n " +
423+ "\t if err != nil {\n " + "\t \t log.Fatalf(\" Error: %v\" , err)\n \t }\n \n " +
424+ "\t params = &sdk.TestOperationIDApiParams{}\n " +
425+ "\t sdkResp, httpResp, err := client.TestTagApi.\n " +
426+ "\t \t TestOperationIDWithParams(ctx, params).\n " +
427+ "\t \t Execute()" + "\n }\n " ,
428+ },
429+ {
430+ Lang : "cURL" ,
431+ Label : "curl (Service Accounts)" ,
432+ Source : "curl --include --header \" Authorization: Bearer ${ACCESS_TOKEN}\" \\ \n " +
433+ "--header \" Accept: application/vnd.atlas.2025-01-01+json\" \\ \n " + "-X GET \" https://cloud.mongodb.com/test?pretty=true\" " ,
434+ },
435+ {
436+ Lang : "cURL" ,
437+ Label : "curl (Digest)" ,
438+ Source : "curl --user \" ${PUBLIC_KEY}:${PRIVATE_KEY}\" \\ \n --digest --include \\ \n " +
439+ "--header \" Accept: application/vnd.atlas.2025-01-01+json\" \\ \n " + "-X GET \" https://cloud.mongodb.com/test?pretty=true\" " ,
440+ },
441+ },
442+ },
443+ },
444+ })),
445+ },
446+ },
355447 }
356448
357449 for _ , tt := range testCases {
0 commit comments