Skip to content

Commit 65489ee

Browse files
committed
Failing test added
paths include 'summary' and 'description'
1 parent b2eb99e commit 65489ee

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed

tests/v3/index.test.ts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,4 +988,154 @@ describe("OpenAPI3 features", () => {
988988
`)
989989
);
990990
});
991+
992+
it("paths include 'summary' and 'description'", () => {
993+
const schema: OpenAPI3 = {
994+
openapi: "3.0.1",
995+
paths: {
996+
"/": {
997+
summary: "Root",
998+
description: "Lorem ipsum sic dolor amet",
999+
get: {
1000+
responses: {
1001+
"200": {
1002+
content: {
1003+
"application/json": {
1004+
schema: {
1005+
type: "object",
1006+
properties: {
1007+
title: { type: "string" },
1008+
body: { type: "string" },
1009+
},
1010+
required: ["title", "body"],
1011+
},
1012+
},
1013+
},
1014+
},
1015+
},
1016+
},
1017+
},
1018+
"/search": {
1019+
post: {
1020+
parameters: [
1021+
{
1022+
name: "q",
1023+
in: "query",
1024+
required: true,
1025+
schema: { type: "string" },
1026+
},
1027+
{
1028+
name: "p",
1029+
in: "query",
1030+
schema: { type: "integer" },
1031+
},
1032+
],
1033+
responses: {
1034+
"200": {
1035+
content: {
1036+
"application/json": {
1037+
schema: {
1038+
type: "object",
1039+
properties: {
1040+
results: {
1041+
type: "array",
1042+
items: { $ref: "#/components/schemas/SearchResult" },
1043+
},
1044+
total: { type: "integer" },
1045+
},
1046+
required: ["total"],
1047+
},
1048+
},
1049+
},
1050+
},
1051+
"404": {
1052+
content: {
1053+
"application/json": {
1054+
schema: { $ref: "#/components/schemas/ErrorResponse" },
1055+
},
1056+
},
1057+
},
1058+
},
1059+
},
1060+
},
1061+
},
1062+
components: {
1063+
schemas: {
1064+
ErrorResponse: {
1065+
type: "object",
1066+
properties: {
1067+
error: { type: "string" },
1068+
message: { type: "string" },
1069+
},
1070+
required: ["error", "message"],
1071+
},
1072+
SearchResponse: {
1073+
type: "object",
1074+
properties: {
1075+
title: { type: "string" },
1076+
date: { type: "string" },
1077+
},
1078+
required: ["title", "date"],
1079+
},
1080+
},
1081+
responses: {
1082+
NotFound: {
1083+
content: {
1084+
"application/json": {
1085+
schema: { $ref: "#/components/schemas/ErrorResponse" },
1086+
},
1087+
},
1088+
},
1089+
},
1090+
},
1091+
};
1092+
1093+
expect(swaggerToTS(schema)).toBe(
1094+
format(`
1095+
export interface paths {
1096+
'/': {
1097+
get: {
1098+
responses: {
1099+
'200': {
1100+
'application/json': { title: string; body: string }
1101+
}
1102+
}
1103+
}
1104+
};
1105+
'/search': {
1106+
post: {
1107+
parameters: {
1108+
query: {
1109+
q: string;
1110+
p?: number;
1111+
}
1112+
};
1113+
responses: {
1114+
'200': {
1115+
'application/json': {
1116+
results?: components['schemas']['SearchResult'][];
1117+
total: number;
1118+
}
1119+
}
1120+
'404': {
1121+
'application/json': components['schemas']['ErrorResponse']
1122+
}
1123+
}
1124+
}
1125+
}
1126+
}
1127+
1128+
export interface operations {}
1129+
1130+
export interface components {
1131+
schemas: {
1132+
ErrorResponse: { error: string; message: string };
1133+
SearchResponse: { title: string; date: string }
1134+
}
1135+
responses: {
1136+
NotFound: { [key: string]: any }
1137+
}
1138+
}`)
1139+
);
1140+
});
9911141
});

0 commit comments

Comments
 (0)