Fix Management Console API code samples (#30455)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) => ({
|
||||
|
||||
Reference in New Issue
Block a user