octocrab icon indicating copy to clipboard operation
octocrab copied to clipboard

Support pulls/{number}/commits

Open SamWilsn opened this issue 1 year ago • 12 comments

SamWilsn avatar Jun 12 '24 18:06 SamWilsn

Thank you for your PR! Can you rebase it on top on main?

XAMPPRocky avatar Jun 14 '24 07:06 XAMPPRocky

Done!

SamWilsn avatar Jun 14 '24 12:06 SamWilsn

@XAMPPRocky So it seems like GitHub's schema isn't entirely correct for the Author type, or maybe I'm doing something wrong. For at least one pull request, I'm getting back JSON that's deserializing to Author that doesn't have login or id. Have you encountered this before?

SamWilsn avatar Jun 19 '24 16:06 SamWilsn

@SamWilsn Yes, GitHub's schema is descriptive at best. It doesn't match the reality of the API and what the API will actually return.

XAMPPRocky avatar Jun 19 '24 16:06 XAMPPRocky

Should I change the Author type to have optional fields, or make a new type specific to this endpoint?

SamWilsn avatar Jun 19 '24 16:06 SamWilsn

Make it have optional fields, there might other endpoints where this also happens.

XAMPPRocky avatar Jun 19 '24 21:06 XAMPPRocky

It's, uh... mostly Option now :sweat_smile:

SamWilsn avatar Jun 20 '24 13:06 SamWilsn

Seems like GitHub hasn't gotten around to fixing either the documentation or the API endpoint. How would you like to proceed?

SamWilsn avatar Jul 18 '24 05:07 SamWilsn

I think they did fix the docs. For me it now says:

        {
          "title": "Empty Object",
          "description": "An object without any properties.",
          "type": "object",
          "properties": {},
          "additionalProperties": false
        }

Would it be possible to write code to conditionally deserialize into either Author (with fields), or into an empty dictionary (without any fields)?

maflcko avatar Jul 18 '24 06:07 maflcko

I think they did fix the docs.

I don't know how I missed that! I'm sorry.

Would it be possible to write code to conditionally deserialize into either Author (with fields), or into an empty dictionary (without any fields)?

I could do something like:

#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
struct Empty {
}

#[derive(Deserialize)]
#[serde(untagged)]
enum MaybeAuthor {
    Empty(Empty),
    Author(Author),
}

I think I'd prefer mapping {} to None though, unless there's a good reason not to?

SamWilsn avatar Jul 18 '24 14:07 SamWilsn

I think I'd prefer mapping {} to None though, unless there's a good reason not to?

Sure, I'd be ok with that as well.

maflcko avatar Jul 18 '24 14:07 maflcko

I think it would be better to have it be an option, if it's empty it should be considered equivalent to null.

XAMPPRocky avatar Jul 18 '24 14:07 XAMPPRocky

@XAMPPRocky @maflcko Sorry for the super long delay on this one. Noticed you've added support for pr commits! I've co-opted this pull request into adding support for deserializing {}.

Hopefully I've followed the specific pr style well enough!

SamWilsn avatar Aug 26 '24 21:08 SamWilsn

Needs rebase

maflcko avatar Aug 30 '24 09:08 maflcko

Done

SamWilsn avatar Aug 30 '24 15:08 SamWilsn

Thank you for your PR, and congrats on your first contribution! 🎉

XAMPPRocky avatar Sep 01 '24 08:09 XAMPPRocky