Skip to content

Commit ab2a348

Browse files
committed
feat(generator): support all request body content types and binary format
- Add CONTENT_TYPE_PRIORITY constant with json, urlencoded, multipart - Add getRequestBodyContent() helper to find schema across content types - Update extractRequestBody() to use helper in both and inline branches - Add format: binary → File | Blob type mapping in getTypeFromSchema() - Add 12 new test cases covering form, multipart, and binary content - All 108 tests pass with 7 new snapshots
1 parent cabf093 commit ab2a348

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

packages/generator/src/__tests__/__snapshots__/generate-schema.test.ts.snap

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,74 @@ exports[`extractRequestBody handles requestBody $ref 1`] = `
10521052
},
10531053
}
10541054
`;
1055+
1056+
exports[`extractRequestBody handles requestBody with application/x-www-form-urlencoded 1`] = `
1057+
{
1058+
"email?": {
1059+
"default": undefined,
1060+
"type": "string",
1061+
},
1062+
"name?": {
1063+
"default": undefined,
1064+
"type": "string",
1065+
},
1066+
}
1067+
`;
1068+
1069+
exports[`extractRequestBody handles requestBody $ref with application/x-www-form-urlencoded 1`] = `
1070+
{
1071+
"email?": {
1072+
"default": undefined,
1073+
"type": "string",
1074+
},
1075+
"name?": {
1076+
"default": undefined,
1077+
"type": "string",
1078+
},
1079+
}
1080+
`;
1081+
1082+
exports[`extractRequestBody handles requestBody with multipart/form-data 1`] = `
1083+
{
1084+
"document?": {
1085+
"default": undefined,
1086+
"type": "File | Blob",
1087+
},
1088+
"name?": {
1089+
"default": undefined,
1090+
"type": "string",
1091+
},
1092+
}
1093+
`;
1094+
1095+
exports[`extractRequestBody handles requestBody $ref with multipart/form-data 1`] = `
1096+
{
1097+
"file?": {
1098+
"default": undefined,
1099+
"type": "File | Blob",
1100+
},
1101+
}
1102+
`;
1103+
1104+
exports[`extractRequestBody prefers application/json over other content types 1`] = `
1105+
{
1106+
"name?": {
1107+
"default": undefined,
1108+
"type": "string",
1109+
},
1110+
}
1111+
`;
1112+
1113+
exports[`getTypeFromSchema handles string with format binary 1`] = `
1114+
{
1115+
"default": undefined,
1116+
"type": "File | Blob",
1117+
}
1118+
`;
1119+
1120+
exports[`getTypeFromSchema handles nullable string with format binary 1`] = `
1121+
{
1122+
"default": undefined,
1123+
"type": "File | Blob | null",
1124+
}
1125+
`;

0 commit comments

Comments
 (0)