Skip to content

Commit c96e3e4

Browse files
feat: Add --include to curl examples in the OpenAPI (#919)
1 parent 3019e84 commit c96e3e4

17 files changed

+10462
-10462
lines changed

tools/cli/internal/openapi/filter/code_sample.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func getFileExtension(format string) string {
7777

7878
func (f *CodeSampleFilter) newDigestCurlCodeSamplesForOperation(pathName, opMethod, format string) codeSample {
7979
version := apiVersion(f.metadata.targetVersion)
80-
source := "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest \\\n " +
80+
source := "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest --include \\\n " +
8181
"--header \"Accept: application/vnd.atlas." + version + "+" + format + "\" \\\n "
8282

8383
switch opMethod {
@@ -107,7 +107,7 @@ func (f *CodeSampleFilter) newDigestCurlCodeSamplesForOperation(pathName, opMeth
107107

108108
func (f *CodeSampleFilter) newServiceAccountCurlCodeSamplesForOperation(pathName, opMethod, format string) codeSample {
109109
version := apiVersion(f.metadata.targetVersion)
110-
source := "curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
110+
source := "curl --include --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
111111
"--header \"Accept: application/vnd.atlas." + version + "+" + format + "\" \\\n "
112112

113113
switch opMethod {

tools/cli/internal/openapi/filter/code_sample_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ func TestCodeSampleFilter(t *testing.T) {
104104
{
105105
Lang: "cURL",
106106
Label: "curl (Service Accounts)",
107-
Source: "curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
107+
Source: "curl --include --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
108108
"--header \"Accept: application/vnd.atlas.2025-01-01+json\" \\\n " + "-X GET \"https://cloud.mongodb.com/test?pretty=true\"",
109109
},
110110
{
111111
Lang: "cURL",
112112
Label: "curl (Digest)",
113-
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest \\\n " +
113+
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest --include \\\n " +
114114
"--header \"Accept: application/vnd.atlas.2025-01-01+json\" \\\n " + "-X GET \"https://cloud.mongodb.com/test?pretty=true\"",
115115
},
116116
},
@@ -175,13 +175,13 @@ func TestCodeSampleFilter(t *testing.T) {
175175
{
176176
Lang: "cURL",
177177
Label: "curl (Service Accounts)",
178-
Source: "curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
178+
Source: "curl --include --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
179179
"--header \"Accept: application/vnd.atlas.preview+json\" \\\n " + "-X GET \"https://cloud.mongodb.com/test?pretty=true\"",
180180
},
181181
{
182182
Lang: "cURL",
183183
Label: "curl (Digest)",
184-
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest \\\n " +
184+
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest --include \\\n " +
185185
"--header \"Accept: application/vnd.atlas.preview+json\" \\\n " + "-X GET \"https://cloud.mongodb.com/test?pretty=true\"",
186186
},
187187
},
@@ -246,13 +246,13 @@ func TestCodeSampleFilter(t *testing.T) {
246246
{
247247
Lang: "cURL",
248248
Label: "curl (Service Accounts)",
249-
Source: "curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
249+
Source: "curl --include --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
250250
"--header \"Accept: application/vnd.atlas.2025-01-01.upcoming+json\" \\\n " + "-X GET \"https://cloud.mongodb.com/test?pretty=true\"",
251251
},
252252
{
253253
Lang: "cURL",
254254
Label: "curl (Digest)",
255-
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest \\\n " +
255+
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest --include \\\n " +
256256
"--header \"Accept: application/vnd.atlas.2025-01-01.upcoming+json\" \\\n " + "-X GET \"https://cloud.mongodb.com/test?pretty=true\"",
257257
},
258258
},
@@ -335,14 +335,14 @@ func TestCodeSampleFilter(t *testing.T) {
335335
{
336336
Lang: "cURL",
337337
Label: "curl (Service Accounts)",
338-
Source: "curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
338+
Source: "curl --include --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " +
339339
"--header \"Accept: application/vnd.atlas.2025-01-01+gzip\" \\\n " +
340340
"-X GET \"https://cloud.mongodb.com/test\" \\\n --output \"file_name.gz\"",
341341
},
342342
{
343343
Lang: "cURL",
344344
Label: "curl (Digest)",
345-
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest \\\n " +
345+
Source: "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest --include \\\n " +
346346
"--header \"Accept: application/vnd.atlas.2025-01-01+gzip\" \\\n " +
347347
"-X GET \"https://cloud.mongodb.com/test\" \\\n --output \"file_name.gz\"",
348348
},

0 commit comments

Comments
 (0)