1
0
mirror of synced 2025-12-23 11:54:18 -05:00

Fix Management Console API code samples (#30455)

This commit is contained in:
Manuel Bergler
2022-09-06 17:58:04 +02:00
committed by GitHub
parent cefc49b915
commit 219638d7d4
2 changed files with 17 additions and 9 deletions

View File

@@ -43,9 +43,14 @@ export function getShellExample(operation: Operation, codeSample: CodeSample) {
}
}
let authHeader = '-H "Authorization: Bearer <YOUR-TOKEN>"'
if (operation.subcategory === 'management-console') {
authHeader = '-u "api_key:your-password"'
}
const args = [
operation.verb !== 'get' && `-X ${operation.verb.toUpperCase()}`,
`-H "Accept: ${defaultAcceptHeader}" \\ \n -H "Authorization: Bearer <YOUR-TOKEN>"`,
`-H "Accept: ${defaultAcceptHeader}" \\ \n ${authHeader}`,
`${operation.serverUrl}${requestPath}`,
requestBodyParams,
].filter(Boolean)

View File

@@ -60,15 +60,18 @@ export function RestCodeSamples({ operation, slug }: Props) {
}))
// Menu options for the language selector
const languageSelectOptions: LanguageOptionT[] = [
{ key: CURLKEY, text: 'cURL' },
{ key: JSKEY, text: 'JavaScript' },
]
const languageSelectOptions: LanguageOptionT[] = [{ key: CURLKEY, text: 'cURL' }]
// Management Console operations are not supported by Octokit
if (operation.subcategory !== 'management-console') {
languageSelectOptions.push({ key: JSKEY, text: 'JavaScript' })
// Not all examples support the GH CLI language option. If any of
// the examples don't support it, we don't show GH CLI as an option.
if (!languageExamples.some((example) => example.ghcli === undefined)) {
languageSelectOptions.push({ key: GHCLIKEY, text: 'GitHub CLI' })
}
}
// Menu options for the example selector
const exampleSelectOptions = languageExamples.map((example, index) => ({