Skip to content
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

"Add labels to an issue" code block is badly formatted and missing documentation #451

Open
Marcono1234 opened this issue Sep 19, 2021 · 1 comment
Labels
Status: Needs info Full requirements are not yet known, so implementation should not be started Type: Documentation Improvements or additions to documentation Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects

Comments

@Marcono1234
Copy link

What happened?

The code block of addLabels.md is badly formatted (indentation is wrong), and the page is missing documentation.

Though the GitHub docs page is also rather confusing:

  • You can pass an empty array to remove all labels.

    Is that actually correct or was it copied from "Set labels for an issue" by accident? It would be rather surprising if an 'add' operation is able to delete something.

  • but GitHub recommends passing an object with the labels key

    Not quite sure what "object" means here, the previous sentence said the type is array; same applies to the "Set labels for an issue" endpoint.

  • The examples for this endpoint as well as "Set labels for an issue" seem to be copied from "list labels"; they don't actually specify labels to add / set

@Marcono1234 Marcono1234 added the Type: Bug Something isn't working as documented label Sep 19, 2021
@ghost ghost added this to Bugs in JS Sep 19, 2021
@gr2m
Copy link
Contributor

gr2m commented Sep 22, 2021

The code block of addLabels.md is badly formatted (indentation is wrong),

we should run the code through prettier, as we do here

writeFileSync(
ROUTES_PATH,
prettier.format(
`import { EndpointsDefaultsAndDecorations } from "../types";
const Endpoints: EndpointsDefaultsAndDecorations = ${JSON.stringify(
sortKeys(newRoutes, { deep: true })
)}
export default Endpoints`,
{ parser: "typescript" }
)
);

A pull request would be much appreciated

Though the GitHub docs page is also rather confusing

Both the GitHub docs and the code in this repository are generated from GitHub's OpenAPI spec at https://github.com/github/rest-api-description/. That's where the parameter description would need to be fixed.

You can pass an empty array to remove all labels.
Is that actually correct or was it copied from "Set labels for an issue" by accident? It would be rather surprising if an 'add' operation is able to delete something.

I'm with you, it sounds incorrect to me. Can you verify?

Not quite sure what "object" means here, the previous sentence said the type is array; same applies to the "Set labels for an issue" endpoint.

Originally, the POST /repos/{owner}/{repo}/issues/{issue_number}/labels and several others would accept the HTTP request body to be an array, as in ["label1", "label2"]. We changed all these endpoints to also accept { "labels": ["labels1: "labels2"]}, to make the endpoint easier to consume with SDKs such as Octokit.js.

You can basically ignore the whole note.

The examples for this endpoint as well as "Set labels for an issue" seem to be copied from "list labels"; they don't actually specify labels to add / set

My guess here is that the OpenAPI spec defines an anyOf here to account for the different types of request body be accepted. That's why the examples are very useful, because technically the labels parameter is not required.

I'd file an issue for that on github.com/github/docs, if none exists yet. You can mention me there. I'd argue we should no longer document sending labels as array in the request body at all, and remove it entirely from the public OpenAPI spec.

@gr2m gr2m added Type: Documentation Improvements or additions to documentation Type: Support Any questions, information, or general needs around the SDK or GitHub APIs and removed Type: Bug Something isn't working as documented labels Sep 22, 2021
@ghost ghost moved this from Bugs to Support in JS Sep 22, 2021
@gr2m gr2m added the Status: Needs info Full requirements are not yet known, so implementation should not be started label Sep 22, 2021
@ghost ghost moved this from Support to Awaiting response in JS Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs info Full requirements are not yet known, so implementation should not be started Type: Documentation Improvements or additions to documentation Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
No open projects
JS
  
Awaiting response
Development

No branches or pull requests

2 participants