octokit / routes

machine-readable, always up-to-date GitHub REST API route specifications
MIT License
84 stars 42 forks source link

Incorrect files property in POST /gists #718

Closed WillAbides closed 4 years ago

WillAbides commented 4 years ago

Current specification

https://github.com/octokit/routes/blob/d32911fbef9b29a2ae85c3383698176948cba252/openapi/api.github.com/operations/gists/create.json#L373-L382

I expected

The "files" parameter is defined as a map like

{
  "files": {
    "content": "this is my content"
  }
}

What the endpoint actually accepts is like so:

{
  "files": {
    "file1.txt": {
      "content": "file one"
    },
    "file2.txt": {
      "content": "file two"
    }
  }
}

The corrected schema would be:

{
  "files": {
    "type": "object",
    "description": "The filenames and content of each file in the gist. The keys in the `files` object represent the filename and have the type `string`.",
    "additionalProperties": {
      "type": "object",
      "properties": {
        "content": {
          "type": "string",
          "description": "The content of the file."
        }
      }
    }
  }
}
gr2m commented 4 years ago

This is a tricky one. We cannot derive the type automatically by parsing the documentation, we will have to implement a manual override for this endpoint.

If you are interested to send a pull request, you can put the workaround here: /lib/endpoint/overrides/workarounds.js

We documented the process of contributing at https://github.com/octokit/routes/blob/master/CONTRIBUTING.md

WillAbides commented 4 years ago

I started hacking something together on workarounds.js when I submitted the issue, and my lack of js knowledge quickly got in the way. I think I'm better leaving it for somebody who knows what they're doing.

octokitbot commented 4 years ago

:tada: This issue has been resolved in version 28.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: