github / rest-api-description

An OpenAPI description for GitHub's REST API
MIT License
1.4k stars 229 forks source link

Correct Code Example in "Add team access restrictions" #1980

Open je-hal opened 1 year ago

je-hal commented 1 year ago

Code of Conduct

What article on docs.github.com is affected?

Add team access restrictions

What part(s) of the article would you like to see updated?

The code sample is not working.

Currently it suggests to add a JSON object '{"teams":["justice-league"]}' in the body of the HTTP Request:

curl \
  -X PUT \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>"\
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
  -d '{"teams":["justice-league"]}'

However, it is described in the parameter description that an array is expected. That's why you end up with the following error message if you follow the code sample:

{ "message": "Invalid request.\n\nFor 'links/9/schema', {\"teams\"=>[\"justice-league\"]} is not an array.", "documentation_url": "https://docs.github.com/rest/branches/branch-protection#add-team-access-restrictions" }

The correct code sample would be:

curl \
  -X PUT \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>"\
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/restrictions/teams \
  -d '["justice-league"]'

Additional information

No response

welcome[bot] commented 1 year ago

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

cmwilson21 commented 1 year ago

@je-hal Thanks so much for opening an issue! I'll triage this for the team to take a look :eyes:

docubot commented 1 year ago

Thank you for opening this issue! Changes to the REST API schema can be requested in github/rest-api-description. I will transfer your issue over to that open source repo.

je-hal commented 1 year ago

Any updates here? 👋 I'd already be happy if someone could confirm that there is something wrong with the example.