Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/types/OpenAPI3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface OpenAPI3Parameter {

export interface OpenAPI3ResponseObject {
description?: string;
content: {
content?: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

[contentType: string]: { schema: OpenAPI3SchemaObject | OpenAPI3Reference };
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function comment(text: string): string {
}

/** shim for Object.fromEntries() for Node < 13 */
export function fromEntries(entries: [string, any][]): object {
export function fromEntries(entries: [string, any][]): Record<string, unknown> {
return entries.reduce((obj, [key, val]) => ({ ...obj, [key]: val }), {});
}

Expand Down
6 changes: 5 additions & 1 deletion src/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ export default function generateTypesV3(
([statusCode, response]) => {
if (response.description) output += comment(response.description);
if (!response.content || !Object.keys(response.content).length) {
output += `"${statusCode}": any;\n`;
const type =
statusCode === "204" || Math.floor(+statusCode / 100) === 3
? "never"
: "unknown";
output += `"${statusCode}": ${type};\n`;
return;
}
output += `"${statusCode}": {\n`;
Expand Down
54 changes: 27 additions & 27 deletions tests/bin/expected/petstore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ export interface paths {
/**
* Invalid ID supplied
*/
'400': any
'400': unknown
/**
* Pet not found
*/
'404': any
'404': unknown
/**
* Validation exception
*/
'405': any
'405': unknown
}
}
post: {
responses: {
/**
* Invalid input
*/
'405': any
'405': unknown
}
}
}
Expand Down Expand Up @@ -54,7 +54,7 @@ export interface paths {
/**
* Invalid status value
*/
'400': any
'400': unknown
}
}
}
Expand Down Expand Up @@ -82,7 +82,7 @@ export interface paths {
/**
* Invalid tag value
*/
'400': any
'400': unknown
}
}
}
Expand Down Expand Up @@ -110,11 +110,11 @@ export interface paths {
/**
* Invalid ID supplied
*/
'400': any
'400': unknown
/**
* Pet not found
*/
'404': any
'404': unknown
}
}
post: {
Expand All @@ -130,7 +130,7 @@ export interface paths {
/**
* Invalid input
*/
'405': any
'405': unknown
}
}
delete: {
Expand All @@ -149,11 +149,11 @@ export interface paths {
/**
* Invalid ID supplied
*/
'400': any
'400': unknown
/**
* Pet not found
*/
'404': any
'404': unknown
}
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ export interface paths {
/**
* Invalid Order
*/
'400': any
'400': unknown
}
}
}
Expand Down Expand Up @@ -233,11 +233,11 @@ export interface paths {
/**
* Invalid ID supplied
*/
'400': any
'400': unknown
/**
* Order not found
*/
'404': any
'404': unknown
}
}
/**
Expand All @@ -256,11 +256,11 @@ export interface paths {
/**
* Invalid ID supplied
*/
'400': any
'400': unknown
/**
* Order not found
*/
'404': any
'404': unknown
}
}
}
Expand All @@ -273,7 +273,7 @@ export interface paths {
/**
* successful operation
*/
default: any
default: unknown
}
}
}
Expand All @@ -283,7 +283,7 @@ export interface paths {
/**
* successful operation
*/
default: any
default: unknown
}
}
}
Expand All @@ -293,7 +293,7 @@ export interface paths {
/**
* successful operation
*/
default: any
default: unknown
}
}
}
Expand Down Expand Up @@ -322,7 +322,7 @@ export interface paths {
/**
* Invalid username/password supplied
*/
'400': any
'400': unknown
}
}
}
Expand All @@ -332,7 +332,7 @@ export interface paths {
/**
* successful operation
*/
default: any
default: unknown
}
}
}
Expand All @@ -357,11 +357,11 @@ export interface paths {
/**
* Invalid username supplied
*/
'400': any
'400': unknown
/**
* User not found
*/
'404': any
'404': unknown
}
}
/**
Expand All @@ -380,11 +380,11 @@ export interface paths {
/**
* Invalid user supplied
*/
'400': any
'400': unknown
/**
* User not found
*/
'404': any
'404': unknown
}
}
/**
Expand All @@ -403,11 +403,11 @@ export interface paths {
/**
* Invalid username supplied
*/
'400': any
'400': unknown
/**
* User not found
*/
'404': any
'404': unknown
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 I’m OK with this change. Really, any undeclared type should be “dangerous” and I do like that this will surface more errors than any

}
}
}
Expand Down
Loading