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

Use CommitAuthor for Commit.author #353

Merged
merged 1 commit into from
Apr 29, 2023

Conversation

gavrielrh
Copy link
Contributor

Problem:

The GitHub response from creating a file/commit is failing due to a serialization error with the Commit struct, despite the request being successful.
The error is saying that the path of commit.author.login is missing.

Context

In the GitHub documentation, they include the response schema for the "Create or update file contents" endpoint Repositories/Contents/Create or update file contents , where, author is a git user with a name: string, an email: string, and a date:string. This is the same for the committer field in the response schema.

Full response schema:

{
  "title": "File Commit",
  "description": "File Commit",
  "type": "object",
  "required": [
    "content",
    "commit"
  ],
  "properties": {
    "content": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "sha": {
          "type": "string"
        },
        "size": {
          "type": "integer"
        },
        "url": {
          "type": "string"
        },
        "html_url": {
          "type": "string"
        },
        "git_url": {
          "type": "string"
        },
        "download_url": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "_links": {
          "type": "object",
          "properties": {
            "self": {
              "type": "string"
            },
            "git": {
              "type": "string"
            },
            "html": {
              "type": "string"
            }
          }
        }
      }
    },
    "commit": {
      "type": "object",
      "properties": {
        "sha": {
          "type": "string"
        },
        "node_id": {
          "type": "string"
        },
        "url": {
          "type": "string"
        },
        "html_url": {
          "type": "string"
        },
        "author": {
          "type": "object",
          "properties": {
            "date": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "email": {
              "type": "string"
            }
          }
        },
        "committer": {
          "type": "object",
          "properties": {
            "date": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "email": {
              "type": "string"
            }
          }
        },
        "message": {
          "type": "string"
        },
        "tree": {
          "type": "object",
          "properties": {
            "url": {
              "type": "string"
            },
            "sha": {
              "type": "string"
            }
          }
        },
        "parents": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "url": {
                "type": "string"
              },
              "html_url": {
                "type": "string"
              },
              "sha": {
                "type": "string"
              }
            }
          }
        },
        "verification": {
          "type": "object",
          "properties": {
            "verified": {
              "type": "boolean"
            },
            "reason": {
              "type": "string"
            },
            "signature": {
              "type": [
                "string",
                "null"
              ]
            },
            "payload": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    }
  }
}

Fix

Use the CommitAuthor Author rather than the Author Author, for the Commit struct.

@XAMPPRocky
Copy link
Owner

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

@XAMPPRocky XAMPPRocky merged commit 153f9f8 into XAMPPRocky:main Apr 29, 2023
@github-actions github-actions bot mentioned this pull request Apr 29, 2023
@gavrielrh gavrielrh deleted the fix-file-create branch May 6, 2023 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants