Skip to content

Fix spacing for cURL code samples #26706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

WhiteFruit
Copy link

@WhiteFruit WhiteFruit commented Jul 14, 2023

Why:

The cURL code samples in the API docs are missing a space before the escape character on the authorization header line. This can cause confusion if you copy/paste the code snippet and get an unexpected error.

Closes issue #26708.

What's being changed (if available, include any code snippets, screenshots, or gifs):

The authorization header line in the cURL code samples will now have a space before the backslash escape character at the end of the line:
-H "Authorization: Bearer <YOUR-TOKEN>"\ --> -H "Authorization: Bearer <YOUR-TOKEN>" \

This allows users to copy/paste the command without errors.

Screenshots

Before:

Screenshot 2023-07-14 at 10 30 13 AM

After:

Screenshot 2023-07-14 at 10 30 52 AM

Alternate Solution

Alternatively, you could split the args on line 91, and let ${args.join(' \\\n ')} on line 96 join them with the proper spacing, escape characters, and newlines. I've created a branch with those changes if that is the preferred direction.

  if (operation.subcategory === 'management-console' || operation.subcategory === 'manage-ghes') {
    authHeader = '-u "api_key:your-password"'
    apiVersionHeader = ''
  } else {
    authHeader = '-H "Authorization: Bearer <YOUR-TOKEN>"'

    apiVersionHeader =
      allVersions[currentVersion].apiVersions.length > 0 &&
      allVersions[currentVersion].latestApiVersion
        ? `-H "X-GitHub-Api-Version: ${allVersions[currentVersion].latestApiVersion}"`
        : ''
  }

  const args = [
    operation.verb !== 'get' && `-X ${operation.verb.toUpperCase()}`,
    `-H "Accept: ${defaultAcceptHeader}"`,
    authHeader,
    apiVersionHeader,
    contentTypeHeader,
    `${operation.serverUrl}${requestPath}`,
    requestBodyParams,
  ].filter(Boolean)
  return `curl -L \\\n  ${args.join(' \\\n  ')}`
}

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline.

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

@welcome
Copy link

welcome bot commented Jul 14, 2023

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions
Copy link
Contributor

👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions. The complete list of files we can't accept are:
.devcontainer/**
.github/actions-scripts/**
.github/workflows/**
.github/CODEOWNERS
assets/fonts/**
data/graphql/**
Dockerfile*
src/**
lib/redirects/**
package*.json
scripts/**
content/actions/deployment/security-hardening-your-deployments/**

You'll need to revert all of the files you changed in that list using GitHub Desktop or git checkout origin/main <file name>. Once you get those files reverted, we can continue with the review process. :octocat:

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jul 14, 2023
@github-actions
Copy link
Contributor

👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions. The complete list of files we can't accept are:
.devcontainer/**
.github/actions-scripts/**
.github/workflows/**
.github/CODEOWNERS
assets/fonts/**
data/graphql/**
Dockerfile*
src/**
lib/redirects/**
package*.json
scripts/**
content/actions/deployment/security-hardening-your-deployments/**

You'll need to revert all of the files you changed in that list using GitHub Desktop or git checkout origin/main <file name>. Once you get those files reverted, we can continue with the review process. :octocat:

@cmwilson21
Copy link
Contributor

cmwilson21 commented Jul 17, 2023

@WhiteFruit Thanks for opening a PR! Unfortunately, we can't accept changes to these files in this repo. I'm going to go ahead and close this PR 💛

See the comment here for more info.

@cmwilson21 cmwilson21 closed this Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Do not begin working on this issue until triaged by the team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants