octokit / dotnet-sdk

MIT License
58 stars 8 forks source link

The SDK return a List of String when it should return a List of Label [BUG]: #107

Closed Hossain2024 closed 3 months ago

Hossain2024 commented 3 months ago

What happened?

I am encountering an issue while trying to get Label objects for an Issue in GitHub.

https://github.dev/octokit/dotnet-sdk/blob/main/src/GitHub/Repos/Item/Item/Issues/IssuesRequestBuilder.cs

The GitHub.Models.Issue class defines the label property as a List<string>. Based on the API response it should be a ``List

   public long? Id { get; set; }
        /// <summary>Labels to associate with this issue; pass one or more label names to replace the set of labels on this issue; send an empty array to clear all labels from the issue; note that the labels are silently dropped for users without push access to the repository</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
        public List<string>? Labels { get; set; }
#nullable restore
#else
        public List<string> Labels { get; set; }
#endif

The API URL:

https://api.github.com/repos/microsoft/kiota/issues/5037

"labels": [
        {
            "id": 2603543073,
            "node_id": "MDU6TGFiZWwyNjAzNTQzMDcz",
            "url": "https://api.github.com/repos/microsoft/kiota/labels/type:bug",
            "name": "type:bug",
            "color": "d73a4a",
            "default": false,
            "description": "A broken experience"
        },
        {
            "id": 3016728568,
            "node_id": "MDU6TGFiZWwzMDE2NzI4NTY4",
            "url": "https://api.github.com/repos/microsoft/kiota/labels/Python",
            "name": "Python",
            "color": "0BBE2D",
            "default": false,
            "description": ""
        }
   ]

In this API response the issues list is a List<Label>

Versions

0.0.23

Code of Conduct

github-actions[bot] commented 3 months ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

kfcampbell commented 3 months ago

@Hossain2024 you're mixing up a request and a response there. In your first code snippet, you've quoted a comment that includes "pass one or more label names to replace the set of labels", implying a POST or a PUT request, and linked IssuesRequestBuilder.cs, which is what is sent to the API.

In the second, you've shown a list of issues from the response, what is returned from the API.

A list of strings is sent in the request to associate an issue with a given label (for which the string is the label name). A list of objects representing a label is returned in the response, for which not only the string label name is returned, but also the color, the description, the default, and various other fields.