Skip to content

Commit 71a6e52

Browse files
committed
add requestBody test
1 parent 5d57f3a commit 71a6e52

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

packages/openapi-typescript/test/transform/request-body-object.test.ts

+39-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,45 @@ describe("transformRequestBodyObject", () => {
4848
"*/*"?: never;
4949
};
5050
}`,
51-
// options: DEFAULT_OPTIONS,
51+
},
52+
],
53+
[
54+
"POST data with default values",
55+
{
56+
given: {
57+
content: {
58+
"application/x-www-form-urlencoded": {
59+
schema: {
60+
type: "object",
61+
properties: {
62+
required: { type: "string" },
63+
optional: { type: "string" },
64+
flag_optional: { type: "boolean", default: false },
65+
flag_required: { type: "boolean", default: false },
66+
},
67+
required: ["required", "flag_required"],
68+
},
69+
},
70+
},
71+
required: true,
72+
description: "description",
73+
},
74+
want: `{
75+
content: {
76+
"application/x-www-form-urlencoded": {
77+
required: string;
78+
optional?: string;
79+
/** @default false */
80+
flag_optional?: boolean;
81+
/** @default false */
82+
flag_required: boolean;
83+
};
84+
};
85+
}`,
86+
options: {
87+
path: "#/paths/~post-item/post/requestBody/application~1x-www-form-urlencoded",
88+
ctx: { ...DEFAULT_CTX },
89+
},
5290
},
5391
],
5492
];

0 commit comments

Comments
 (0)