From 178e034561d44797fb2e017388eb02deba8a1bc1 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 25 Mar 2025 19:25:34 +0200 Subject: [PATCH] docs-util: sort examples to show JS SDK first (#11986) --- .../docs-generator/src/classes/kinds/oas.ts | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/www/utils/packages/docs-generator/src/classes/kinds/oas.ts b/www/utils/packages/docs-generator/src/classes/kinds/oas.ts index da910c8ae4..2ce5fd75ba 100644 --- a/www/utils/packages/docs-generator/src/classes/kinds/oas.ts +++ b/www/utils/packages/docs-generator/src/classes/kinds/oas.ts @@ -363,13 +363,6 @@ class OasKindGenerator extends FunctionKindGenerator { // retrieve code examples oas["x-codeSamples"] = [] - if (curlExample) { - oas["x-codeSamples"].push({ - ...OasExamplesGenerator.CURL_CODESAMPLE_DATA, - source: curlExample, - }) - } - if (jsSdkExample) { oas["x-codeSamples"].push({ ...OasExamplesGenerator.JSCLIENT_CODESAMPLE_DATA, @@ -377,6 +370,13 @@ class OasKindGenerator extends FunctionKindGenerator { }) } + if (curlExample) { + oas["x-codeSamples"].push({ + ...OasExamplesGenerator.CURL_CODESAMPLE_DATA, + source: curlExample, + }) + } + // add security details if applicable oas.security = this.getSecurity({ isAdminAuthenticated, @@ -729,6 +729,13 @@ class OasKindGenerator extends FunctionKindGenerator { ) } + // sort the code samples to show JS SDK first + oas["x-codeSamples"] = oas["x-codeSamples"]?.sort((a) => { + return a.label === OasExamplesGenerator.JSCLIENT_CODESAMPLE_DATA.label + ? -1 + : 1 + }) + // push new tags to the tags property if (tagName) { const areaTags = this.tags.get(splitOasPath[0] as OasArea)