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
5 changes: 5 additions & 0 deletions .changeset/stale-masks-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"swagger-typescript-api": patch
---

fix: incorrect format detection when using ref/responses
4 changes: 2 additions & 2 deletions src/schema-routes/schema-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,11 @@ export class SchemaRoutes {
parsedSchemas,
operationId,
defaultType,
contentTypes,
}) =>
lodash.reduce(
requestInfos,
(acc, requestInfo, status) => {
const contentTypes = this.getContentTypes([requestInfo], operationId);

return [
...acc,
{
Expand Down Expand Up @@ -460,6 +459,7 @@ export class SchemaRoutes {
parsedSchemas,
operationId,
defaultType: this.config.defaultResponseType,
contentTypes,
});

const successResponse = responseInfos.find(
Expand Down
23 changes: 23 additions & 0 deletions tests/__snapshots__/extended.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9363,6 +9363,7 @@ export class Api<
this.request<WrongPathParams1Data, any>({
path: \`/wrong-path-params1/\${pathParam1}/\${pathParam2}/\${pathParam3}/\${pathParam4}\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand All @@ -9381,6 +9382,7 @@ export class Api<
this.request<WrongPathParams2Data, any>({
path: \`/wrong-path-params2\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand Down Expand Up @@ -9621,6 +9623,7 @@ export class Api<
this.request<SignRetrieveHeadData, SignRetrieveHeadError>({
path: \`/scope/\${job}\`,
method: "HEAD",
format: "json",
...params,
}),

Expand Down Expand Up @@ -52055,6 +52058,7 @@ export class Api<
this.request<GistsCheckIsStarredData, GistsCheckIsStarredError>({
path: \`/gists/\${gistId}/star\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -54093,6 +54097,7 @@ export class Api<
this.request<OrgsCheckBlockedUserData, OrgsCheckBlockedUserError>({
path: \`/orgs/\${org}/blocks/\${username}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -54150,6 +54155,7 @@ export class Api<
>({
path: \`/orgs/\${org}/outside_collaborators/\${username}\`,
method: "PUT",
format: "json",
...params,
}),

Expand Down Expand Up @@ -54584,6 +54590,7 @@ export class Api<
>({
path: \`/orgs/\${org}/outside_collaborators/\${username}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -55055,6 +55062,7 @@ export class Api<
method: "PUT",
body: data,
type: ContentType.Json,
format: "json",
...params,
}),

Expand Down Expand Up @@ -55820,6 +55828,7 @@ export class Api<
this.request<ProjectsDeleteData, ProjectsDeleteError>({
path: \`/projects/\${projectId}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand All @@ -55838,6 +55847,7 @@ export class Api<
this.request<ProjectsDeleteCardData, ProjectsDeleteCardError>({
path: \`/projects/columns/cards/\${cardId}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -57888,6 +57898,7 @@ export class Api<
>({
path: \`/repos/\${owner}/\${repo}/assignees/\${assignee}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -60237,6 +60248,7 @@ export class Api<
this.request<ReposDeleteData, ReposDeleteError>({
path: \`/repos/\${owner}/\${repo}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -63439,6 +63451,7 @@ export class Api<
this.request<TeamsAddMemberLegacyData, TeamsAddMemberLegacyError>({
path: \`/teams/\${teamId}/members/\${username}\`,
method: "PUT",
format: "json",
...params,
}),

Expand Down Expand Up @@ -63498,6 +63511,7 @@ export class Api<
method: "PUT",
body: data,
type: ContentType.Json,
format: "json",
...params,
}),

Expand Down Expand Up @@ -64187,6 +64201,7 @@ export class Api<
>({
path: \`/user/starred/\${owner}/\${repo}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -64935,6 +64950,7 @@ export class Api<
this.request<UsersCheckBlockedData, UsersCheckBlockedError>({
path: \`/user/blocks/\${username}\`,
method: "GET",
format: "json",
...params,
}),

Expand All @@ -64956,6 +64972,7 @@ export class Api<
>({
path: \`/user/following/\${username}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -70618,6 +70635,7 @@ export class Api<
this.request<CreatePetsData, CreatePetsError>({
path: \`/pets\`,
method: "POST",
format: "json",
...params,
}),

Expand Down Expand Up @@ -71047,6 +71065,7 @@ export class Api<
this.request<CreatePetsData, CreatePetsError>({
path: \`/pets\`,
method: "POST",
format: "json",
...params,
}),

Expand Down Expand Up @@ -71533,6 +71552,7 @@ export class Api<
this.request<DeletePetData, DeletePetError>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -72079,6 +72099,7 @@ export class Api<
this.request<DeletePetData, DeletePetError>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -72894,6 +72915,7 @@ export class Api<
this.request<DeletePetData, DeletePetError>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -74641,6 +74663,7 @@ export class Api<
this.request<DeletePetData, DeletePetError>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down
23 changes: 23 additions & 0 deletions tests/__snapshots__/simple.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5914,6 +5914,7 @@ export class Api<
this.request<void, any>({
path: \`/wrong-path-params1/\${pathParam1}/\${pathParam2}/\${pathParam3}/\${pathParam4}\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand All @@ -5929,6 +5930,7 @@ export class Api<
this.request<void, any>({
path: \`/wrong-path-params2\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand Down Expand Up @@ -6219,6 +6221,7 @@ export class Api<
this.request<void, Error>({
path: \`/scope/\${job}\`,
method: "HEAD",
format: "json",
...params,
}),

Expand Down Expand Up @@ -19759,6 +19762,7 @@ export class Api<
this.request<void, BasicError | object>({
path: \`/gists/\${gistId}/star\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -21609,6 +21613,7 @@ export class Api<
this.request<void, BasicError>({
path: \`/orgs/\${org}/blocks/\${username}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -22675,6 +22680,7 @@ export class Api<
>({
path: \`/orgs/\${org}/outside_collaborators/\${username}\`,
method: "PUT",
format: "json",
...params,
}),

Expand All @@ -22700,6 +22706,7 @@ export class Api<
>({
path: \`/orgs/\${org}/outside_collaborators/\${username}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -23980,6 +23987,7 @@ export class Api<
method: "PUT",
body: data,
type: ContentType.Json,
format: "json",
...params,
}),

Expand Down Expand Up @@ -24271,6 +24279,7 @@ export class Api<
>({
path: \`/projects/columns/cards/\${cardId}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -24598,6 +24607,7 @@ export class Api<
>({
path: \`/projects/\${projectId}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -24963,6 +24973,7 @@ export class Api<
>({
path: \`/repos/\${owner}/\${repo}\`,
method: "DELETE",
format: "json",
...params,
}),

Expand Down Expand Up @@ -25988,6 +25999,7 @@ export class Api<
this.request<void, BasicError>({
path: \`/repos/\${owner}/\${repo}/assignees/\${assignee}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -35495,6 +35507,7 @@ export class Api<
>({
path: \`/teams/\${teamId}/members/\${username}\`,
method: "PUT",
format: "json",
...params,
}),

Expand Down Expand Up @@ -35713,6 +35726,7 @@ export class Api<
method: "PUT",
body: data,
type: ContentType.Json,
format: "json",
...params,
}),

Expand Down Expand Up @@ -36053,6 +36067,7 @@ export class Api<
this.request<void, BasicError>({
path: \`/user/blocks/\${username}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -36279,6 +36294,7 @@ export class Api<
this.request<void, BasicError>({
path: \`/user/following/\${username}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -37448,6 +37464,7 @@ export class Api<
this.request<void, BasicError>({
path: \`/user/starred/\${owner}/\${repo}\`,
method: "GET",
format: "json",
...params,
}),

Expand Down Expand Up @@ -42161,6 +42178,7 @@ export class Api<
this.request<void, Error>({
path: \`/pets\`,
method: "POST",
format: "json",
...params,
}),

Expand Down Expand Up @@ -42515,6 +42533,7 @@ export class Api<
this.request<void, Error>({
path: \`/pets\`,
method: "POST",
format: "json",
...params,
}),

Expand Down Expand Up @@ -42902,6 +42921,7 @@ export class Api<
this.request<void, Error>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand Down Expand Up @@ -43311,6 +43331,7 @@ export class Api<
this.request<void, Error>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand Down Expand Up @@ -43998,6 +44019,7 @@ export class Api<
this.request<void, ErrorModel>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand Down Expand Up @@ -45107,6 +45129,7 @@ export class Api<
this.request<void, ErrorModel>({
path: \`/pets/\${id}\`,
method: "DELETE",
format: "json",
...params,
}),
};
Expand Down
Loading