Skip to content

Commit 5558223

Browse files
authored
Make params non-nullable even if all params are optional (#1022)
In 5.x, an optional query parameter's type could be referenced with an expression such as type myQueryType = operations['myOperation']['parameters']['query'] In 6.0, that only works if there is at least one mandatory query parameter in addition to the optional one. This makes query parameter types much more awkward to reference in application code if all the parameters are optional. Revert to the 5.x behavior: if there are any parameters, optional or not, the `parameters` object is always present. If there are any query parameters, the `query` object is always present, same with `path` and the other parameter types. Fixes #995
1 parent 5f2b8ee commit 5558223

7 files changed

+983
-989
lines changed

examples/github-api-next.ts

+558-558
Large diffs are not rendered by default.

examples/github-api.ts

+138-138
Large diffs are not rendered by default.

examples/octokit-ghes-3.6-diff-to-api.ts

+30-30
Original file line numberDiff line numberDiff line change
@@ -5928,9 +5928,9 @@ export interface operations {
59285928
};
59295929
"enterprise-admin/list-public-keys": {
59305930
/** List public keys */
5931-
parameters?: {
5931+
parameters: {
59325932
/** @description Only show public keys accessed after the given time. */
5933-
query?: {
5933+
query: {
59345934
sort?: "created" | "updated" | "accessed";
59355935
since?: string;
59365936
};
@@ -6074,8 +6074,8 @@ export interface operations {
60746074
};
60756075
"enterprise-admin/list-pre-receive-environments": {
60766076
/** List pre-receive environments */
6077-
parameters?: {
6078-
query?: {
6077+
parameters: {
6078+
query: {
60796079
sort?: "created" | "updated" | "name";
60806080
};
60816081
};
@@ -6236,9 +6236,9 @@ export interface operations {
62366236
};
62376237
"enterprise-admin/list-pre-receive-hooks": {
62386238
/** List pre-receive hooks */
6239-
parameters?: {
6239+
parameters: {
62406240
/** @description The property to sort the results by. */
6241-
query?: {
6241+
query: {
62426242
sort?: "created" | "updated" | "name";
62436243
};
62446244
};
@@ -6467,8 +6467,8 @@ export interface operations {
64676467
*
64686468
* The permissions the installation has are included under the `permissions` key.
64696469
*/
6470-
parameters?: {
6471-
query?: {
6470+
parameters: {
6471+
query: {
64726472
outdated?: string;
64736473
};
64746474
};
@@ -6545,9 +6545,9 @@ export interface operations {
65456545
*
65466546
* You can use this API to list the set of OAuth applications that have been granted access to your account. Unlike the [list your authorizations](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations#list-your-authorizations) API, this API does not manage individual tokens. This API will return one entry for each OAuth application that has been granted access to your account, regardless of the number of tokens an application has generated for your user. The list of OAuth applications returned matches what is shown on [the application authorizations settings screen within GitHub](https://github.com/settings/applications#authorized). The `scopes` returned are the union of scopes authorized for the application. For example, if an application has one token with `repo` scope and another token with `user` scope, the grant will return `["repo", "user"]`.
65476547
*/
6548-
parameters?: {
6548+
parameters: {
65496549
/** @description The client ID of your GitHub app. */
6550-
query?: {
6550+
query: {
65516551
client_id?: string;
65526552
};
65536553
};
@@ -6703,9 +6703,9 @@ export interface operations {
67036703
* @deprecated
67046704
* @description **Deprecation Notice:** GitHub Enterprise Server will discontinue the [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations), which is used by integrations to create personal access tokens and OAuth tokens, and you must now create these tokens using our [web application flow](https://docs.github.com/[email protected]/apps/building-oauth-apps/authorizing-oauth-apps/#web-application-flow). The [OAuth Authorizations API](https://docs.github.com/[email protected]/rest/reference/oauth-authorizations) will be removed on November, 13, 2020. For more information, including scheduled brownouts, see the [blog post](https://developer.github.com/changes/2020-02-14-deprecating-oauth-auth-endpoint/).
67056705
*/
6706-
parameters?: {
6706+
parameters: {
67076707
/** @description The client ID of your GitHub app. */
6708-
query?: {
6708+
query: {
67096709
client_id?: string;
67106710
};
67116711
};
@@ -7502,10 +7502,10 @@ export interface operations {
75027502
*
75037503
* You can manage team membership with your identity provider using Enterprise Managed Users for GitHub Enterprise Cloud. For more information, see "[GitHub's products](https://docs.github.com/[email protected]/github/getting-started-with-github/githubs-products)" in the GitHub Help documentation.
75047504
*/
7505-
parameters?: {
7505+
parameters: {
75067506
/** @description Page token */
75077507
/** @description Limits the list to groups containing the text in the group name */
7508-
query?: {
7508+
query: {
75097509
page?: number;
75107510
display_name?: string;
75117511
};
@@ -7564,9 +7564,9 @@ export interface operations {
75647564
* List pre-receive hooks for an organization
75657565
* @description List all pre-receive hooks that are enabled or testing for this organization as well as any disabled hooks that can be configured at the organization level. Globally disabled pre-receive hooks that do not allow downstream configuration are not listed.
75667566
*/
7567-
parameters?: {
7567+
parameters: {
75687568
/** @description The sort order for the response collection. */
7569-
query?: {
7569+
query: {
75707570
sort?: "created" | "updated" | "name";
75717571
};
75727572
};
@@ -8016,10 +8016,10 @@ export interface operations {
80168016
* **Deprecation notice**:
80178017
* The `tool_name` field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the `tool` field.
80188018
*/
8019-
parameters?: {
8019+
parameters: {
80208020
/** @description The Git reference for the analyses you want to list. The `ref` for a branch can be formatted either as `refs/heads/<branch name>` or simply `<branch name>`. To reference a pull request use `refs/pull/<number>/merge`. */
80218021
/** @description Filter analyses belonging to the same SARIF upload. */
8022-
query?: {
8022+
query: {
80238023
ref?: components["schemas"]["code-scanning-ref"];
80248024
sarif_id?: components["schemas"]["code-scanning-analysis-sarif-id"];
80258025
};
@@ -8048,10 +8048,10 @@ export interface operations {
80488048
* endpoint. GitHub Apps must have the `members` organization permission and `metadata` repository permission to use this
80498049
* endpoint.
80508050
*/
8051-
parameters?: {
8051+
parameters: {
80528052
/** @description Filter collaborators returned by their affiliation. `outside` means all outside collaborators of an organization-owned repository. `direct` means all collaborators with permissions to an organization-owned repository, regardless of organization membership status. `all` means all collaborators the authenticated user can see. */
80538053
/** @description Filter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned. */
8054-
query?: {
8054+
query: {
80558055
affiliation?: "outside" | "direct" | "all";
80568056
permission?: "pull" | "triage" | "push" | "maintain" | "admin";
80578057
};
@@ -8221,8 +8221,8 @@ export interface operations {
82218221
* List pre-receive hooks for a repository
82228222
* @description List all pre-receive hooks that are enabled or testing for this repository as well as any disabled hooks that are allowed to be enabled at the repository level. Pre-receive hooks that are disabled at a higher level and are not configurable will not be listed.
82238223
*/
8224-
parameters?: {
8225-
query?: {
8224+
parameters: {
8225+
query: {
82268226
sort?: "created" | "updated" | "name";
82278227
};
82288228
};
@@ -8552,9 +8552,9 @@ export interface operations {
85528552
* - For GitHub Enterprise Server, this endpoint will only list repositories available to all users on the enterprise.
85538553
* - Pagination is powered exclusively by the `since` parameter. Use the [Link header](https://docs.github.com/[email protected]/rest/overview/resources-in-the-rest-api#link-header) to get the URL for the next page of repositories.
85548554
*/
8555-
parameters?: {
8555+
parameters: {
85568556
/** @description Specifies the types of repositories to return. This endpoint will only list repositories available to all users on the enterprise. */
8557-
query?: {
8557+
query: {
85588558
visibility?: "all" | "public";
85598559
};
85608560
};
@@ -8578,10 +8578,10 @@ export interface operations {
85788578
* List provisioned SCIM groups for an enterprise
85798579
* @description **Note:** The SCIM API endpoints for enterprise accounts are currently in beta and are subject to change.
85808580
*/
8581-
parameters?: {
8581+
parameters: {
85828582
/** @description filter results */
85838583
/** @description attributes to exclude */
8584-
query?: {
8584+
query: {
85858585
filter?: string;
85868586
excludedAttributes?: string;
85878587
};
@@ -8630,9 +8630,9 @@ export interface operations {
86308630
* Get SCIM provisioning information for an enterprise group
86318631
* @description **Note:** The SCIM API endpoints for enterprise accounts are currently in beta and are subject to change.
86328632
*/
8633-
parameters?: {
8633+
parameters: {
86348634
/** @description Attributes to exclude. */
8635-
query?: {
8635+
query: {
86368636
excludedAttributes?: string;
86378637
};
86388638
};
@@ -8739,9 +8739,9 @@ export interface operations {
87398739
* - If the user signs in, their GitHub Enterprise Server account is linked to this entry.
87408740
* - If the user does not sign in (or does not create a new account when prompted), they are not added to the GitHub Enterprise Server enterprise, and the external identity `null` entry remains in place.
87418741
*/
8742-
parameters?: {
8742+
parameters: {
87438743
/** @description filter results */
8744-
query?: {
8744+
query: {
87458745
filter?: string;
87468746
};
87478747
};

0 commit comments

Comments
 (0)