Skip to content

Repos::get_collaborator_permission_level() return model is not correct #89

Description

@samkearney

The model returned from Repos::get_collaborator_permission_level() looks like (some attributes omitted):

pub struct RepositoryCollaboratorPermission {
    pub permission: String,
    pub user: Option<SimpleUser>,
}

pub struct SimpleUser {
    pub avatar_url: String,
    pub email: String,
    pub events_url: String,
    pub followers_url: String,
    pub following_url: String,
    pub gists_url: String,
    pub gravatar_id: String,
    pub html_url: String,
    pub id: i64,
    pub login: String,
    pub name: String,
    pub node_id: String,
    pub organizations_url: String,
    pub received_events_url: String,
    pub repos_url: String,
    pub site_admin: bool,
    pub starred_at: String,
    pub starred_url: String,
    pub subscriptions_url: String,
    pub type_: String,
    pub url: String,
}

Where the response schema from the API documentation for the endpoint looks like:

Expand Me

{
  "title": "Repository Collaborator Permission",
  "description": "Repository Collaborator Permission",
  "type": "object",
  "properties": {
    "permission": {
      "type": "string"
    },
    "role_name": {
      "type": "string",
      "examples": [
        "admin"
      ]
    },
    "user": {
      "anyOf": [
        {
          "type": "null"
        },
        {
          "title": "Collaborator",
          "description": "Collaborator",
          "type": "object",
          "properties": {
            "login": {
              "type": "string",
              "examples": [
                "octocat"
              ]
            },
            "id": {
              "type": "integer",
              "examples": [
                1
              ]
            },
            "email": {
              "type": [
                "string",
                "null"
              ]
            },
            "name": {
              "type": [
                "string",
                "null"
              ]
            },
            "node_id": {
              "type": "string",
              "examples": [
                "MDQ6VXNlcjE="
              ]
            },
            "avatar_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://github.com/images/error/octocat_happy.gif"
              ]
            },
            "gravatar_id": {
              "type": [
                "string",
                "null"
              ],
              "examples": [
                "41d064eb2195891e12d0413f63227ea7"
              ]
            },
            "url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://api.github.com/users/octocat"
              ]
            },
            "html_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://github.com/octocat"
              ]
            },
            "followers_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://api.github.com/users/octocat/followers"
              ]
            },
            "following_url": {
              "type": "string",
              "examples": [
                "https://api.github.com/users/octocat/following{/other_user}"
              ]
            },
            "gists_url": {
              "type": "string",
              "examples": [
                "https://api.github.com/users/octocat/gists{/gist_id}"
              ]
            },
            "starred_url": {
              "type": "string",
              "examples": [
                "https://api.github.com/users/octocat/starred{/owner}{/repo}"
              ]
            },
            "subscriptions_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://api.github.com/users/octocat/subscriptions"
              ]
            },
            "organizations_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://api.github.com/users/octocat/orgs"
              ]
            },
            "repos_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://api.github.com/users/octocat/repos"
              ]
            },
            "events_url": {
              "type": "string",
              "examples": [
                "https://api.github.com/users/octocat/events{/privacy}"
              ]
            },
            "received_events_url": {
              "type": "string",
              "format": "uri",
              "examples": [
                "https://api.github.com/users/octocat/received_events"
              ]
            },
            "type": {
              "type": "string",
              "examples": [
                "User"
              ]
            },
            "site_admin": {
              "type": "boolean"
            },
            "permissions": {
              "type": "object",
              "properties": {
                "pull": {
                  "type": "boolean"
                },
                "triage": {
                  "type": "boolean"
                },
                "push": {
                  "type": "boolean"
                },
                "maintain": {
                  "type": "boolean"
                },
                "admin": {
                  "type": "boolean"
                }
              },
              "required": [
                "pull",
                "push",
                "admin"
              ]
            },
            "role_name": {
              "type": "string",
              "examples": [
                "admin"
              ]
            }
          },
          "required": [
            "avatar_url",
            "events_url",
            "followers_url",
            "following_url",
            "gists_url",
            "gravatar_id",
            "html_url",
            "id",
            "node_id",
            "login",
            "organizations_url",
            "received_events_url",
            "repos_url",
            "site_admin",
            "starred_url",
            "subscriptions_url",
            "type",
            "url",
            "role_name"
          ]
        }
      ]
    }
  },
  "required": [
    "permission",
    "role_name",
    "user"
  ]
}

The top-level field role_name is missing, and the user field looks more like the struct Collaborator than SimpleUser (although even Collaborator is not quite right, because FullRepositoryPermissions is missing the fields triage and maintain).

This may be because the code is generated from GitHub's API spec 1.1.4 (Dec 2021) instead of the latest version 2.1.0 (Oct 2022)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions