Generated TypeScript definitions based on GitHub's OpenAPI spec
This repository continuously converts GitHub's OpenAPI specification into TypeScript definitions and publishes them to npm as @octokit/openapi-types
.
Generated TypeScript definitions based on GitHub's OpenAPI spec
License: MIT License
Generated TypeScript definitions based on GitHub's OpenAPI spec
This repository continuously converts GitHub's OpenAPI specification into TypeScript definitions and publishes them to npm as @octokit/openapi-types
.
The API docs say that when listing contributors, the fields for id
, login
, avatar_url
, etc are not optional (not null or undefined).
However, in this repo's packages/openapi-type/types.d.ts
, the contributor fields are all marked as optional:
...
/**
* Contributor
* @description Contributor
*/
contributor: {
login?: string;
id?: number;
node_id?: string;
/** Format: uri */
avatar_url?: string;
...
I first noticed this in my local copy of @octokit/openapi-types v18.0.0, but when writing this bug report, I looked at the contents of packages/openapi-type/types.d.ts
as of commit [d14957b](https://github.com/octokit/openapi-types.ts/commit/d14957b7ce2f4d59f7e39ef054a7bd133606efb6)
.
No response
Hello,
I'm not sure if it is the right repo to report it as it seems to be generated from somewhere elese, please point me in another repo if you want me to report it elsewhere !
All label's pull request fields are optional, even the id, it does not seem like they should:
labels: {
id?: number;
node_id?: string;
url?: string;
name?: string;
description?: string;
color?: string;
default?: boolean;
}[];
pull-request-simple
: https://github.com/octokit/openapi-types.ts/blob/main/generated/types.ts#L25713-L25721
pull-request
: https://github.com/octokit/openapi-types.ts/blob/main/generated/types.ts#L26560-L26568
Thanks
This issue contains a list of Renovate updates and their statuses.
These updates are awaiting their schedule. Click on a checkbox to ignore the schedule.
On npm the latest version is now 14
https://www.npmjs.com/package/@octokit/openapi-types
But there is no corresponding entry at the releases page
https://github.com/octokit/openapi-types.ts/releases
What were the changes in this version?
octokit.rest.repos.updateInformationAboutPagesSite
:
octokit.rest.repos.updateInformationAboutPagesSite({
owner: context.repo.owner,
repo: context.repo.repo,
source: { // error error error error error error error error error
branch: 'branch-foo',
path: '/',
},
})
Take a look at the type.d.ts
:
{
// ...
source?: Partial<'gh-pages' | 'master' | 'master /docs'> &
Partial<{
/** The repository branch used to publish your site's source files. */
branch: string
/** The repository directory that includes the source files for the Pages site. Allowed paths are `/` or `/docs`. */
path: '/' | '/docs'
}>
}
How can I use the source
type correctly?
components['schemas']['notifications']
Even though 13.13.0 was removed from npm, it is still in caches and gets picked up.
It is not always possible to reset caches stored in GitHub actions.
typo
No response
No response
No response
The payload for octokit.repos.createCommitStatus
for a status is different than the status response from octokit.repos.listCommitStatusesForRef
.
octokit.repos.createCommitStatus
is string
and octokit.repos.createCommitStatus
is 'pending' | 'success' | 'failure' | 'error'
. `
It appears that v3.2.1 broke some types in @octokit/rest
by upgrading the dependency openapi-typescript
to v3. Prior to that version, we called the library like so:
import {Octokit} from '@octokit/rest'
const octokit = new Octokit({auth: '...})
await octokit.repos.createOrUpdateFileContents({
owner: '...',
repo: '...',
path: '...,
content: '...',
message: '...,
})
After upgrading @octokit/rest
to v3.2.1, that causes the following error:
packages/provisioning-api/src/github.ts:28:50 - error TS2345: Argument of type '{ owner: string; repo: string; path: string; content: string; message: string; }' is not assignable to parameter of type 'RequestParameters & Pick<{ owner: string; repo: string; path: string; } & { data: { "application/json": { message: string; content: string; sha?: string | undefined; branch?: string | undefined; committer?: { ...; } | undefined; author?: { ...; } | undefined; }; }; }, "owner" | ... 2 more ... | "data">'.
Property 'data' is missing in type '{ owner: string; repo: string; path: string; content: string; message: string; }' but required in type 'Pick<{ owner: string; repo: string; path: string; } & { data: { "application/json": { message: string; content: string; sha?: string | undefined; branch?: string | undefined; committer?: { name: string; email: string; date?: string | undefined; } | undefined; author?: { ...; } | undefined; }; }; }, "owner" | ... 2 m...'.
28 await octokit.repos.createOrUpdateFileContents({
~
29 owner: '...',
~~~~~~~~~~~~~~~~~
...
33 message: `...`,
~~~~~~~~~~~~~~~~~~~
34 })
~~~
.yarn/cache/@octokit-types-npm-6.5.0-0c84f2cd1e-1bcac38bf1.zip/node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:10:5
10 data: {
~~~~
'data' is declared here.
packages/provisioning-api/src/github.ts:45:50 - error TS2345: Argument of type '{ owner: string; repo: string; path: string; content: string; message: string; sha: string; }' is not assignable to parameter of type 'RequestParameters & Pick<{ owner: string; repo: string; path: string; } & { data: { "application/json": { message: string; content: string; sha?: string | undefined; branch?: string | undefined; committer?: { ...; } | undefined; author?: { ...; } | undefined; }; }; }, "owner" | ... 2 more ... | "data">'.
Property 'data' is missing in type '{ owner: string; repo: string; path: string; content: string; message: string; sha: string; }' but required in type 'Pick<{ owner: string; repo: string; path: string; } & { data: { "application/json": { message: string; content: string; sha?: string | undefined; branch?: string | undefined; committer?: { name: string; email: string; date?: string | undefined; } | undefined; author?: { ...; } | undefined; }; }; }, "owner" | ... 2 m...'.
45 await octokit.repos.createOrUpdateFileContents({
~
46 owner: '...',
~~~~~~~~~~~~~~~~~
...
51 sha: '...',
~~~~~~~~~~~~~~~
52 })
~~~
.yarn/cache/@octokit-types-npm-6.5.0-0c84f2cd1e-1bcac38bf1.zip/node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:10:5
10 data: {
~~~~
'data' is declared here.
Found 2 errors.
It's asking for a data
provided with essentially the full request body duplicated. Here's what it wants for data
:
{
data: {
"application/json": {
message: string;
content: string;
sha?: string;
branch?: string;
committer?: {
name: string;
email: string;
date?: string;
};
author?: {
name: string;
email: string;
date?: string;
};
};
};
}
I have not determined exactly what the issue is, but something about the types that openapi-typescript
v3 is generating is not fully compatible with @octokit/rest
.
We can use https://github.com/semantic-release/git for that
main
branch failed. π¨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. Iβm sure you can fix this πͺ.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the main
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those donβt help, or if this issue is reporting something you think isnβt right, you can always ask the humans behind semantic-release.
package.json
file.A package.json file at the root of your project is required to release on npm.
Please follow the npm guideline to create a valid package.json
file.
Good luck with your project β¨
Your semantic-release bot π¦π
I've started getting a failing pipeline (something changed upstream it seems) on a project that uses @oktokit/rest
package. It started failing about 2 weeks ago.
The error references this package Error! This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (6:7) /home/circleci/project/node_modules/@octokit/openapi-types/generated/types.ts
I have tried downgrading the version of @oktokit/rest
but still seeing the issue, perhaps I can't find the right version at which the package was introduced and many dependencies are not pinned so it is tricky to find.
The package lockfile is not published with you releases so we end up getting whatever is the latest version within the range and I think this is the issue really, would someone be able to confirm?
snyk-api-import@ snyk-api-import
βββ¬ @octokit/[email protected] invalid
β βββ¬ @octokit/[email protected]
β β βββ¬ @octokit/[email protected]
β β β βββ @octokit/[email protected] deduped
β β βββ¬ @octokit/[email protected]
β β β βββ @octokit/[email protected] deduped
β β β βββ @octokit/[email protected] deduped
β β β βββ [email protected]
β β βββ¬ @octokit/[email protected]
β β β βββ¬ @octokit/[email protected]
β β β β βββ @octokit/[email protected] deduped
β β β β βββ [email protected] deduped
β β β β βββ [email protected]
β β β βββ¬ @octokit/[email protected]
β β β β βββ @octokit/[email protected] deduped
β β β β βββ [email protected] deduped
β β β β βββ [email protected] deduped
β β β βββ @octokit/[email protected] deduped
β β β βββ [email protected]
β β β βββ [email protected]
β β β βββ [email protected]
β β β βββ¬ [email protected]
β β β β βββ [email protected]
β β β βββ [email protected]
β β βββ¬ @octokit/[email protected]
β β β βββ @octokit/[email protected]
β β β βββ @types/[email protected] deduped
β β βββ [email protected]
β β βββ [email protected]
β βββ @octokit/[email protected] extraneous
β βββ @octokit/[email protected]
β βββ @octokit/[email protected] extraneous
βββ¬ @semantic-release/[email protected]
npx pkg . -t node12-linux-x64,node12-macos-x64,node12-win-x64
pkg
command succeeded, unfortunately I deleted it to make sure CI and local were in sync it so can't check the versions of the dependencies that last worked :(. Realised too late that I really needed that! And it was ignored in git π€¦ so no backups for me)Error! This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (6:7)
/home/circleci/project/node_modules/@octokit/openapi-types/generated/types.ts
at makeError (/home/circleci/project/node_modules/@semantic-release/exec/node_modules/execa/lib/error.js:59:11)
at handlePromise (/home/circleci/project/node_modules/@semantic-release/exec/node_modules/execa/index.js:114:26)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async module.exports (/home/circleci/project/node_modules/@semantic-release/exec/lib/exec.js:16:11)
at async prepare (/home/circleci/project/node_modules/@semantic-release/exec/index.js:54:5)
at async validator (/home/circleci/project/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
at async /home/circleci/project/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
at async Promise.all (index 0)
at async next (/home/circleci/project/node_modules/p-reduce/index.js:16:18) {
After updating Octokit from 2.0.14 to the latest version and running typecheck
, I started seeing this error appearing for this code:
const { data: { installations } } = await octokit.rest.apps.listInstallationsForAuthenticatedUser();
installations.map((installation) => installation.account!.login)
Property 'login' does not exist on type 'SerializeObject<UndefinedToOptional<{ name?: string | null | undefined; email?: string | null | undefined; login: string; id: number; node_id: string; avatar_url: string; gravatar_id: string | null; url: string; html_url: string; ... 11 more ...; starred_at?: string | undefined; }>> | SerializeObject<...>'.
Property 'login' does not exist on type 'SerializeObject<UndefinedToOptional<{ description?: string | null | undefined; html_url: string; website_url?: string | null | undefined; id: number; node_id: string; name: string; slug: string; created_at: string | null; updated_at: string | null; avatar_url: string; }>>'
Is there something missing on my side? Or is this a bug? I noticed that the error does not appear if I try to access any of the following properties:
- avatar_url
- html_url
- id
- name?
- node_id
But it does happen for any other property, like description?
. I can't seem to figure out if there's a pattern here. This worked fine in previous versions with openapi-types = 16.0.0
I apologize if this is not a bug. Thanks!
Octokit 3.1.0 with openapi-types
on 18.0.0
.
Previously, was using Octokit 2.0.14 with openapi-types
on 16.0.0
.
No response
Upgrading to the latest version of Octokit OpenAPI Types has removed a large number of fields from the account property of the InstallationFunctionOptions type. Previously this property contained the union of both simple-user and enterprise schemas, but the latest version seems to have changed this to only the intersection of the two types.
Latest version snippet from types.d.ts :
installation: {
/**
* @description The ID of the installation.
* @example 1
*/
id: number;
account:
| (
| components["schemas"]["simple-user"]
| components["schemas"]["enterprise"]
)
| null;
/**
* @description Describe whether all repositories have been selected or there's a selection involved
* @enum {string}
*/
repository_selection: "all" | "selected";
/**
* Format: uri
* @example https://api.github.com/installations/1/access_tokens
*/
access_tokens_url: string;
/**
* Format: uri
* @example https://api.github.com/installation/repositories
*/
repositories_url: string;
/**
* Format: uri
* @example https://github.com/organizations/github/settings/installations/1
*/
html_url: string;
/** @example 1 */
app_id: number;
/** @description The ID of the user or organization this token is being scoped to. */
target_id: number;
/** @example Organization */
target_type: string;
permissions: components["schemas"]["app-permissions"];
events: string[];
/** Format: date-time */
created_at: string;
/** Format: date-time */
updated_at: string;
/** @example config.yaml */
single_file_name: string | null;
/** @example true */
has_multiple_single_files?: boolean;
/**
* @example [
* "config.yml",
* ".github/issue_TEMPLATE.md"
* ]
*/
single_file_paths?: string[];
/** @example github-actions */
app_slug: string;
suspended_by: components["schemas"]["nullable-simple-user"];
/** Format: date-time */
suspended_at: string | null;
/** @example "[email protected]" */
contact_email?: string | null;
};
Previous version :
installation: {
/**
* @description The ID of the installation.
* @example 1
*/
id: number;
account:
| (Partial<components["schemas"]["simple-user"]> &
Partial<components["schemas"]["enterprise"]>)
| null;
/**
* @description Describe whether all repositories have been selected or there's a selection involved
* @enum {string}
*/
repository_selection: "all" | "selected";
/**
* Format: uri
* @example https://api.github.com/installations/1/access_tokens
*/
access_tokens_url: string;
/**
* Format: uri
* @example https://api.github.com/installation/repositories
*/
repositories_url: string;
/**
* Format: uri
* @example https://github.com/organizations/github/settings/installations/1
*/
html_url: string;
/** @example 1 */
app_id: number;
/** @description The ID of the user or organization this token is being scoped to. */
target_id: number;
/** @example Organization */
target_type: string;
permissions: components["schemas"]["app-permissions"];
events: string[];
/** Format: date-time */
created_at: string;
/** Format: date-time */
updated_at: string;
/** @example config.yaml */
single_file_name: string | null;
/** @example true */
has_multiple_single_files?: boolean;
/**
* @example [
* "config.yml",
* ".github/issue_TEMPLATE.md"
* ]
*/
single_file_paths?: string[];
/** @example github-actions */
app_slug: string;
suspended_by: components["schemas"]["nullable-simple-user"];
/** Format: date-time */
suspended_at: string | null;
/** @example "[email protected]" */
contact_email?: string | null;
};
[email protected]
[email protected]
Working OpenAPI-Types : @octokit/[email protected]
Broken OpenAPI-Types : @octokit/[email protected]
No response
Continue publishing @octokit/openapi-types
as is, but add @octokit/openapi-types-ghae
and @octokit/openapi-types-ghes-2.30
(etc)
github updated the openapi specification for GET /orgs/{org}/copilot/billing
github/rest-api-description#3428
I would like to use the correct type of te response.
Could you please update the package and release it?
No response
part of #109
An eslint error occurred after updating to the latest npm release. The change in openapi-types.ts at line 37676 may have introduced an ambiguity that eslint has trouble with. vscode appears to be confused as well. This was found in gitgitgadget dependabot pull request failing. This was referenced in a octokit/rest.js/ comment. The error is:
error Unsafe assignment of an "any" value @typescript-eslint/no-unsafe-assignment
The code compiles okay but gets errors in vscode and eslint. There may be some confusion between 200 and 202 status codes both being successful but this is just a guess.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Location: package.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: @pika/pack, Invalid configuration option: author, Invalid configuration option: keywords, Invalid configuration option: license, Invalid configuration option: main, Invalid configuration option: name, Invalid configuration option: octokit, Invalid configuration option: packageRules[0].@octokit/tsconfig, Invalid configuration option: packageRules[0].@pika/pack, Invalid configuration option: packageRules[0].@pika/plugin-build-node, Invalid configuration option: packageRules[0].@pika/plugin-build-web, Invalid configuration option: packageRules[0].@pika/plugin-ts-standard-pkg, Invalid configuration option: packageRules[0].openapi-typescript, Invalid configuration option: packageRules[0].pika-plugin-merge-properties, Invalid configuration option: packageRules[0].semantic-release-plugin-update-version-in-files, Invalid configuration option: packageRules[0].typescript, Invalid configuration option: publishConfig, Invalid configuration option: release, Invalid configuration option: renovate, Invalid configuration option: scripts, Invalid configuration option: types, Invalid configuration option: version
Corresponding to https://docs.github.com/en/[email protected]/rest/reference/checks the properties conclusion`` and
started_at` are optional values. The API does not allow 'null' value for both of them.
Steps to recreate:
conclusion
and started_at
.Expected result: Update request works
Actual result: The update request ends in a http error that say conclusion
and started_at
cannot be nil.
The generate-types script writes a README.md file that includes a link to the LICENSE file. The LICENSE file isn't written to the package folder though so it's not included in the distributed npm packages and the README references a non-existent file.
Can the license file also be written to each package folder so it gets included in distributed packages?
What happened?
Trying to use @octokit/app like this:
const emails = await octokit.request('GET /user/emails');
const isPrimary = emails.data[0].primary;
And according to the docs, this should return:
[
{
"email": "[email protected]",
"verified": true,
"primary": true,
"visibility": "public"
}
]
but TypeScript tells me:
Property 'primary' does not exist on type 'string | { email: string; primary: boolean; verified: boolean; visibility: string; }'.
Property 'primary' does not exist on type 'string'
It seems the type is set to either the email object OR just a string.
I tried to track down where the type i defined, and I think it's here: GitHub's REST API OpenAPI Description, but it looks correct... (line 39539 π )
What did you expect to happen?
I expect the type to match the API docs.
What the problem might be
Not sure where this string gets added unfortunately.
This is not very straight forward.
For one, octokit/openapi just naively transpiles all specs that exist in https://github.com/github/rest-api-description which currently go back to GHES 2.18, but the latest supported GHES version is 2.22. Knowing what the currently supported GHES versions is a recurring problem in @octokit, I had to hard-code it several times, e.g. in https://github.com/octokit/plugin-enterprise-server.js/blob/e8ec2270bd60930a39623195cececea5933070b9/scripts/update-endpoints/ghe-versions.js (which is already out of date, too.)
For now I'll hard code it here so I don't go down yet another rabbit hole, but it is something I have to properly solve now. I'll make a follow up note
The other problem is that each generated TypeScript file is ~1MB big. If we add all the relevant versions to the @octokit/openapi-types
package that means 4-5MB extra in download size each time someone installs any octokit package, despite the fact that only a small subset will actually use the types for the enterprise versions.
One approache would be to setup a monorepo like we do in https://github.com/octokit/webhooks. But for that we would also need to remove the current build step, and instead of the TypeScript source code we would generate and publish .d.ts
files.
I guess converting this repository from TypeScript + Build Step to .d.ts
will be useful anyway, so I might as well start out doing that. Removing the build still will make it much easier to turn this repository into a monorepo for multiple @octokit/openapi-types*
repositories
I have to give this some more thought, but here is my current plan
While building a private action, the commit was blocked by our secret blocker.
The secret blocker was triggered by the example RSA Private key in file types.d.ts
(line 9570
and 11702
).
/** @example "-----BEGIN RSA PRIVATE KEY-----\nMIIEogIB
@octokit/openapi-types
version 22.2.0
installed with
npm install @actions/core
npm install @actions/github
Using node v20.14.0
No response
There are questions that come up occasionally about "missing" types when the actual issue is that the consumer needs to use the corresponding platform package - i.e. GHAE, GHES, + all of the corresponding versions.
This behavior is opaque to new users because it requires understanding the various aspects of the GitHub platform and how that translates to the Octokit JS environment.
No response
No response
No response
For /scripts/
folder at least
The problem seems to be when the package.json
files are modified in the update script.
This line of the update-package
script should be running the linter, but it seems as though it isn't
Originally posted by @wolfy1339 in #207 (comment)
The checks/create
operation is missing a ton of properties in the requestBody
:
"checks/create": {
parameters: {
path: {
owner: components["parameters"]["owner"];
repo: components["parameters"]["repo"];
};
};
requestBody: {
content: {
"application/json": OneOf<
[
{
/** @enum {unknown} */
status: "completed";
[key: string]: unknown;
},
{
/** @enum {unknown} */
status?: "queued" | "in_progress";
[key: string]: unknown;
}
]
>;
};
};
responses: {
/** @description Response */
201: {
content: {
"application/json": components["schemas"]["check-run"];
};
};
};
};
Looking at the schema here, it looks like it has all the fields. For example, the schema defines name
and head_sha
as required properties, but they are missing from the type above.
@octokit/openapi-types v17.1.2
No response
Blocked by github/rest-api-description#486
/** Simple User */
"simple-user": {
name?: string | null;
email?: string | null;
login: string;
id: number;
node_id: string;
avatar_url: string;
gravatar_id: string | null;
url: string;
html_url: string;
followers_url: string;
following_url: string;
gists_url: string;
starred_url: string;
subscriptions_url: string;
organizations_url: string;
repos_url: string;
events_url: string;
received_events_url: string;
type: string;
site_admin: boolean;
starred_at?: string;
} | null;
I've no idea where the | null
comes from
The same is true for these components
simple-user
integration
team-simple
auto_merge
deployment_branch_policy
export type GitHubEvent = GetResponseDataTypeFromEndpointMethod<typeof octokit.activity.listPublicEventsForUser>[0];
const iterator = octokit.paginate.iterator(octokit.rest.activity.listPublicEventsForUser, {
username: user,
per_page: 100,
})
events = []
for await (const item of iterator) {
events = this.events.concat(item.data)
}
JsonContent of event object:
"payload": {
"push_id": 10843997312,
"size": 1,
"distinct_size": 1,
"ref": "refs/heads/master",
"head": "c73a84db441fdd656d90be5172e41b3eaa69a356",
"before": "cc3d1a380867a6b30a1520526c4be8f20fc52a69",
"commits": ...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.