-
Notifications
You must be signed in to change notification settings - Fork 42
OpenAPI specification format #168
Conversation
openapi.json
Outdated
"type": "string", | ||
"enum": ["*"] | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the "oneOf" schema automatically from scraping the docs might be tricky, but if it’s useful we will find a way
The OpenAPI will force us to have unique routes per endpoint because of the way they are defined {
"paths": {
"/repos/:owner/:repo/issues": {
"get": {
...
}
}
}
} For that we would need to change
as the paths are technically the same. |
openapi/index.json
Outdated
"pull-request-summary": "", | ||
"issue": "id,number" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryangribble could you add an explanation on how you use that property for octokit.net?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the Issue.cs
response model, we use it to generate this property:
internal string DebuggerDisplay => string.Format(CultureInfo.InvariantCulture, "Issue Id: {Id}, Number: {Number}");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for each response object (schema) we need to know what are the "important" fields that should be shown when this object is being shown (eg in debugger window or mouse over)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was no suitable field on the actual properties
openAPI entry, so I went down the path of using OpenAPI extensions. They can only apply to certain places though, and under schemas
isnt one of those... so although its not ideal to have them at the top info
level, there wasn't a more suitable place really.
If the goal is to generate everything from "the source" then I think we will need to end up adding certain additional info into the openAPI description, because maintaining something like this on the octokit client side means a manual update whenever a new response schema is added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the "important" fields are the URL parameters in general? So e.g. for GET /repos/:owner/:repo/issues/:number
it would be ["owner", "repo", "number"]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a mismatch though, because these objects are declared in schemas area, so there is no url/parameters there (those are under operations/responses)
I think I'm missing something.
vs
These are not the same, right? But then... looking more closely, |
As far as I can tell, this would work well for generating the Ruby client. |
@kytrinyx for example, say I have a branch "feature", I can get it with
Response is an object {
"ref": "refs/heads/feature",
"node_id": "MDM6UmVmcmVmcy9oZWFkcy9mZWF0dXJlQQ==",
"url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature",
"object": {
"type": "commit",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
}
} Now, some time passes, the
Now returns an array [
{
"ref": "refs/heads/feature/hello",
"node_id": "MDM6UmVmcmVmcy9oZWFkcy9tYXN0ZXI=",
"url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature/hello",
"object": {
"type": "commit",
"sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
}
},
{
"ref": "refs/heads/feature/world",
"node_id": "MDM6UmVmcmVmcy9oZWFkcy9naC1wYWdlcw==",
"url": "https://api.github.com/repos/octocat/Hello-World/git/refs/heads/feature/world",
"object": {
"type": "commit",
"sha": "612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac",
"url": "https://api.github.com/repos/octocat/Hello-World/git/commits/612077ae6dffb4d2fbd8ce0cccaa58893b07b5ac"
}
}
] Both requests use the same route, but receive different type of responses depending on wether the URL part after The tricky part in Get all references is this
And in the 2nd example |
@gr2m Thank you, this is exactly what I was missing. This is a problem also because the same endpoint can return two types (array vs object). We definitely need to look at the API design for this. |
This comment has been minimized.
This comment has been minimized.
862beb8
to
58b60f4
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
* except for an odd failure on `GHE_VERSION=2.17 npm test`
BREAKING CHANGE: Definitions removed for GHE 2.14 due to deprecation
🎉 This PR is included in version 21.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
So awesome to see this ship! Thank you @gr2m 🚀 |
And @d11n! Derek from dojo4 (who took on maintainership of octokit.rb) greatly helped in the past weeks 👏 |
Preview 👀
Base of discussion. Starting out with specifications for issues (list, get, create, delete) to see if the format is usable across Octokit .js, .net and .rb
Continuously deployed to https://octokit-routes-openapi.now.sh/
Breaking changes
Keeping track of things that will change besides the format
repos/get-commit-ref-sha
will be removed, as it’s not a separate endpoint but only sets a custom media format header comparet torepos/get-commit
The plan
✅ OpenAPI specification
GET /repos/{owner}/{repo}/issues
GET /repos/:owner/:repo/issues/:number
POST /repos/:owner/:repo/issues
PATCH /repos/:owner/:repo/issues/:number
PUT /repos/:owner/:repo/issues/:number/lock
DELETE /repos/:owner/:repo/issues/:number/lock
✅ Generate OpenAPI specification
See #328
✅ Adapt
@octokit/rest
to use OpenAPI specificationProof of concept how Octokit libraries can be generated from the Open API spec.
plugins/rest-api-endpoints/routes.json
file with same format.allowNull
for parametersoutput.annotations[].message
which currently use"output.annotations[].message"
as key, instead ofoutput: { annotations: { items: { message } } } }
(simplified)mapTo
"content-type": "text/plain; charset=utf-8"
for markdown.renderRawvalidation
, e.g./projects/columns/:column_id/moves
and/projects/columns/cards/:card_id/moves
@octokit/rest
docs🏗 Merge
openapi
branch into masterfigure out how to bring back ignored operations due to route conflictsOpenAPI: figure out complicated routes #470Figure out special case:OpenAPI: figure out complicated routes #470POST :url
x-is-deprecated
flag, see feat: add deprecation flag #429🔜 Clean up implementation
It’s currently chaotic because the internal methods all scrape the data into the previous format, then at the end we transform the previous format to OpenAPI. We have to get rid of the previous format throughout the code base in order to make the code base maintainable and lower to barrier for outside contribution
replace overrides with the new OpenAPI operations format. There are only 4 overrides left, the others are just "ignore this section".OpenAPI: replace overrides with the new OpenAPI operations format #471🔮 Backlog
octokit/*
repositories to new OpenAPI specificationAfter merge
See also https://github.com/octokit/routes/milestone/1