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

[Feature Reqest] Add body params for API calls #29

Open
IAmHughes opened this issue Jun 7, 2019 · 5 comments
Open

[Feature Reqest] Add body params for API calls #29

IAmHughes opened this issue Jun 7, 2019 · 5 comments

Comments

@IAmHughes
Copy link

IAmHughes commented Jun 7, 2019

I'd love to find a way to populate the body of requests too for each endpoint in the routes directory. The way this would look would be by modifying the empty "body": {} to something like this:

"body": {
        "mimeType": "application/json",
        "text": "{\n\t\"ignored\": false\n}"
    },

Here would be an example of the full object for one of the calls.

{
      "parentId": "__FLD_2__",
      "_id": "__REQ_17__",
      "_type": "request",
      "name": "Set a thread subscription",
      "description": "This lets you subscribe or unsubscribe from a conversation.\n\nhttps://developer.github.com/v3/activity/notifications/#set-a-thread-subscription",
      "headers": [],
      "authentication": {
        "token": "{{ github_token  }}",
        "type": "bearer"
      },
      "method": "PUT",
      "url": "{{ github_api_root  }}/notifications/threads/{{ thread_id }}/subscription",
      "body": {
        "mimeType": "application/json",
        "text": "{\n\t\"ignored\": false\n}"
    },
      "parameters": []
    },

I spent about 30 minutes doing this by hand and it was not a fun process. We may want to consider programmatically getting this information in there somehow (I'm sure some fancy sed/awk can help).

Then I realized you used the Octokit Routes so I think we would need to update something in Index.js to pull the body tag out instead of just populating it with an empty body as we do here

@swinton
Copy link
Owner

swinton commented Jun 7, 2019

This would be a great addition.

The change to include a body would go here, approximately:

However, I don't think @octokit/routes includes the request bodies, so this would be quite difficult to implement.

@swinton
Copy link
Owner

swinton commented Jun 7, 2019

#7 should be easier @IAmHughes, since params are defined in @octokit/routes.

@IAmHughes
Copy link
Author

I was just going to say that may be the better route, closing in favor of #7 so we can leverage the params:

@swinton
Copy link
Owner

swinton commented Dec 15, 2019

This might be worth revisiting now that @octokit/routes supports the OpenAPI spec, which specifies a requestBody object.

@swinton swinton reopened this Dec 15, 2019
@swinton
Copy link
Owner

swinton commented Dec 17, 2019

Here's an example requestBody, for the POST /app/installations/:installation_id/access_tokens route, note there is an example property that we could use:

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "repository_ids": {
            "type": "array",
            "description": "The `id`s of the repositories that the installation token can access. Providing repository `id`s restricts the access of an installation token to specific repositories. You can use the \"[List repositories](https://developer.github.com/v3/apps/installations/#list-repositories)\" endpoint to get the `id` of all repositories that an installation can access. For example, you can select specific repositories when creating an installation token to restrict the number of repositories that can be cloned using the token.",
            "items": {
              "type": "integer"
            }
          },
          "permissions": {
            "type": "object",
            "description": "The permissions granted to the access token. The permissions object includes the permission names and their access type. For a complete list of permissions and allowable values, see \"[GitHub App permissions](https://developer.github.com/apps/building-github-apps/creating-github-apps-using-url-parameters/#github-app-permissions).\"",
            "properties": {}
          }
        }
      },
      "example": {
        "repository_ids": [
          1296269
        ],
        "permissions": {
          "issues": "write",
          "contents": "read"
        }
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants