oxidecomputer / oxidecomputer/third-party-api-clients

Repos::get_collaborator_permission_level() return model is not correct

Open
#89 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
150
Forks
62
PR merge metrics
No merged PRs in 30d

Description

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)?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Repos::get_collaborator_permission_level() entry point and compare its RepositoryCollaboratorPermission and user models with the linked GitHub API response schema. Verify the top-level and nested fields and types against that schema; done means the generated return model represents the documented response, including role_name and the collaborator permissions fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.