Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion templates/default/procedure-call.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ const describeReturnType = () => {

const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);

const getSuccessResponseTypes = () => {
const successResponses = responseBodyInfo.responses.filter(response => response.isSuccess);

return config.Ts.UnionType(successResponses.map((response) => response.type)) || "any";
}


%>
/**
<%~ routeDocs.description %>
Expand All @@ -91,7 +98,7 @@ const isValidIdentifier = (name) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);

*/
<% if (isValidIdentifier(route.routeName.usage)) { %><%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %><% } else { %>"<%~ route.routeName.usage %>"<%~ route.namespace ? ': ' : ' = ' %><% } %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> =>
<%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({
<%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ `${getSuccessResponseTypes()}` %>, <%~ errorType %>>({
path: `<%~ path %>`,
method: '<%~ _.upperCase(method) %>',
<%~ queryTmpl ? `query: ${queryTmpl},` : '' %>
Expand Down
50 changes: 30 additions & 20 deletions tests/__snapshots__/extended.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8124,7 +8124,7 @@ export class Api<
* @request GET:/v2
*/
getVersionDetailsv2: (params: RequestParams = {}) =>
this.request<GetVersionDetailsv2Data, any>({
this.request<GetVersionDetailsv2Data | void, any>({
path: \`/v2\`,
method: "GET",
format: "json",
Expand Down Expand Up @@ -8490,7 +8490,7 @@ export class Api<
* @request GET:/v2
*/
getVersionDetailsv2: (params: RequestParams = {}) =>
this.request<GetVersionDetailsv2Data, any>({
this.request<GetVersionDetailsv2Data | void, any>({
path: \`/v2\`,
method: "GET",
format: "json",
Expand Down Expand Up @@ -9600,7 +9600,7 @@ export class Api<
{ job, ...query }: SignRetrieveParams,
params: RequestParams = {},
) =>
this.request<SignRetrieveData, SignRetrieveError>({
this.request<SignRetrieveData | void, SignRetrieveError>({
path: \`/scope/\${job}\`,
method: "GET",
format: "json",
Expand All @@ -9618,7 +9618,7 @@ export class Api<
{ job, ...query }: SignRetrieveHeadParams,
params: RequestParams = {},
) =>
this.request<SignRetrieveHeadData, SignRetrieveHeadError>({
this.request<SignRetrieveHeadData | void, SignRetrieveHeadError>({
path: \`/scope/\${job}\`,
method: "HEAD",
...params,
Expand Down Expand Up @@ -11330,7 +11330,7 @@ export class Api<
parameters: TdeCertificate,
params: RequestParams = {},
) =>
this.request<ManagedInstanceTdeCertificatesCreateData, void>({
this.request<ManagedInstanceTdeCertificatesCreateData | void, void>({
path: \`/subscriptions/\${subscriptionId}/resourceGroups/\${resourceGroupName}/providers/Microsoft.Sql/managedInstances/\${managedInstanceName}/tdeCertificates\`,
method: "POST",
query: query,
Expand Down Expand Up @@ -51037,7 +51037,7 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
OauthAuthorizationsGetOrCreateAuthorizationForAppData,
OauthAuthorizationsGetOrCreateAuthorizationForAppData | Authorization,
BasicError | ValidationError
>({
path: \`/authorizations/clients/\${clientId}\`,
Expand Down Expand Up @@ -51067,7 +51067,8 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
OauthAuthorizationsGetOrCreateAuthorizationForAppAndFingerprintData,
| OauthAuthorizationsGetOrCreateAuthorizationForAppAndFingerprintData
| Authorization,
ValidationError
>({
path: \`/authorizations/clients/\${clientId}/\${fingerprint}\`,
Expand Down Expand Up @@ -52857,7 +52858,7 @@ export class Api<
data: ActivityMarkNotificationsAsReadPayload,
params: RequestParams = {},
) =>
this.request<ActivityMarkNotificationsAsReadData, BasicError>({
this.request<ActivityMarkNotificationsAsReadData | void, BasicError>({
path: \`/notifications\`,
method: "PUT",
body: data,
Expand Down Expand Up @@ -53024,7 +53025,7 @@ export class Api<
data: ActionsCreateOrUpdateOrgSecretPayload,
params: RequestParams = {},
) =>
this.request<ActionsCreateOrUpdateOrgSecretData, any>({
this.request<ActionsCreateOrUpdateOrgSecretData | void, any>({
path: \`/orgs/\${org}/actions/secrets/\${secretName}\`,
method: "PUT",
body: data,
Expand Down Expand Up @@ -54145,7 +54146,7 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
OrgsConvertMemberToOutsideCollaboratorData,
OrgsConvertMemberToOutsideCollaboratorData | void,
OrgsConvertMemberToOutsideCollaboratorError
>({
path: \`/orgs/\${org}/outside_collaborators/\${username}\`,
Expand Down Expand Up @@ -55127,7 +55128,7 @@ export class Api<
}: TeamsCheckPermissionsForRepoInOrgParams,
params: RequestParams = {},
) =>
this.request<TeamsCheckPermissionsForRepoInOrgData, void>({
this.request<TeamsCheckPermissionsForRepoInOrgData | void, void>({
path: \`/orgs/\${org}/teams/\${teamSlug}/repos/\${owner}/\${repo}\`,
method: "GET",
format: "json",
Expand Down Expand Up @@ -56228,7 +56229,7 @@ export class Api<
data: ActionsCreateOrUpdateRepoSecretPayload,
params: RequestParams = {},
) =>
this.request<ActionsCreateOrUpdateRepoSecretData, any>({
this.request<ActionsCreateOrUpdateRepoSecretData | void, any>({
path: \`/repos/\${owner}/\${repo}/actions/secrets/\${secretName}\`,
method: "PUT",
body: data,
Expand Down Expand Up @@ -59430,7 +59431,7 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
ReactionsCreateForCommitCommentData,
ReactionsCreateForCommitCommentData | Reaction,
| {
documentation_url: string;
message: string;
Expand Down Expand Up @@ -59493,7 +59494,7 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
ReactionsCreateForIssueCommentData,
ReactionsCreateForIssueCommentData | Reaction,
| {
documentation_url: string;
message: string;
Expand Down Expand Up @@ -59527,7 +59528,7 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
ReactionsCreateForPullRequestReviewCommentData,
ReactionsCreateForPullRequestReviewCommentData | Reaction,
| {
documentation_url: string;
message: string;
Expand Down Expand Up @@ -59786,7 +59787,10 @@ export class Api<
data: ReposAddCollaboratorPayload,
params: RequestParams = {},
) =>
this.request<ReposAddCollaboratorData, BasicError | ValidationError>({
this.request<
ReposAddCollaboratorData | void,
BasicError | ValidationError
>({
path: \`/repos/\${owner}/\${repo}/collaborators/\${username}\`,
method: "PUT",
body: data,
Expand Down Expand Up @@ -60022,7 +60026,13 @@ export class Api<
data: ReposCreateDeploymentPayload,
params: RequestParams = {},
) =>
this.request<ReposCreateDeploymentData, ReposCreateDeploymentError>({
this.request<
| ReposCreateDeploymentData
| {
message?: string;
},
ReposCreateDeploymentError
>({
path: \`/repos/\${owner}/\${repo}/deployments\`,
method: "POST",
body: data,
Expand Down Expand Up @@ -60115,7 +60125,7 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
ReposCreateOrUpdateFileContentsData,
ReposCreateOrUpdateFileContentsData | FileCommit,
BasicError | ValidationError
>({
path: \`/repos/\${owner}/\${repo}/contents/\${path}\`,
Expand Down Expand Up @@ -61644,7 +61654,7 @@ export class Api<
{ owner, repo, ...query }: ReposListContributorsParams,
params: RequestParams = {},
) =>
this.request<ReposListContributorsData, BasicError>({
this.request<ReposListContributorsData | void, BasicError>({
path: \`/repos/\${owner}/\${repo}/contributors\`,
method: "GET",
query: query,
Expand Down Expand Up @@ -63579,7 +63589,7 @@ export class Api<
}: TeamsCheckPermissionsForRepoLegacyParams,
params: RequestParams = {},
) =>
this.request<TeamsCheckPermissionsForRepoLegacyData, void>({
this.request<TeamsCheckPermissionsForRepoLegacyData | void, void>({
path: \`/teams/\${teamId}/repos/\${owner}/\${repo}\`,
method: "GET",
format: "json",
Expand Down
17 changes: 10 additions & 7 deletions tests/__snapshots__/simple.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6199,7 +6199,7 @@ export class Api<
field?: string;
/** base64safe encoded public signing key */
sub?: string;
},
} | void,
Error
>({
path: \`/scope/\${job}\`,
Expand Down Expand Up @@ -20357,7 +20357,7 @@ export class Api<
this.request<
{
message?: string;
},
} | void,
BasicError
>({
path: \`/notifications\`,
Expand Down Expand Up @@ -24051,7 +24051,7 @@ export class Api<
repo: string,
params: RequestParams = {},
) =>
this.request<TeamRepository, void>({
this.request<TeamRepository | void, void>({
path: \`/orgs/\${org}/teams/\${teamSlug}/repos/\${owner}/\${repo}\`,
method: "GET",
format: "json",
Expand Down Expand Up @@ -27670,7 +27670,7 @@ export class Api<
},
params: RequestParams = {},
) =>
this.request<RepositoryInvitation, BasicError | ValidationError>({
this.request<RepositoryInvitation | void, BasicError | ValidationError>({
path: \`/repos/\${owner}/\${repo}/collaborators/\${username}\`,
method: "PUT",
body: data,
Expand Down Expand Up @@ -28505,7 +28505,7 @@ export class Api<
},
params: RequestParams = {},
) =>
this.request<Contributor[], BasicError>({
this.request<Contributor[] | void, BasicError>({
path: \`/repos/\${owner}/\${repo}/contributors\`,
method: "GET",
query: query,
Expand Down Expand Up @@ -28621,7 +28621,10 @@ export class Api<
params: RequestParams = {},
) =>
this.request<
Deployment,
| Deployment
| {
message?: string;
},
| {
/** @example ""https://docs.github.com/rest/reference/repos#create-a-deployment"" */
documentation_url?: string;
Expand Down Expand Up @@ -35792,7 +35795,7 @@ export class Api<
repo: string,
params: RequestParams = {},
) =>
this.request<TeamRepository, void>({
this.request<TeamRepository | void, void>({
path: \`/teams/\${teamId}/repos/\${owner}/\${repo}\`,
method: "GET",
format: "json",
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/axios/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4741,7 +4741,7 @@ export class Api<
body: MergesBody,
params: RequestParams = {},
) =>
this.request<MergesSuccessful, void | MergesConflict>({
this.request<MergesSuccessful | void, void | MergesConflict>({
path: \`/repos/\${owner}/\${repo}/merges\`,
method: "POST",
body: body,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4745,7 +4745,7 @@ export class Api<SecurityDataType extends unknown> {
body: MergesBody,
params: RequestParams = {},
) =>
this.http.request<MergesSuccessful, void | MergesConflict>({
this.http.request<MergesSuccessful | void, void | MergesConflict>({
path: \`/repos/\${owner}/\${repo}/merges\`,
method: "POST",
body: body,
Expand Down
Loading