diff --git a/src/__tests__/__snapshots__/gen-api-models.test.ts.snap b/src/__tests__/__snapshots__/gen-api-models.test.ts.snap
index 3fa0ca2f..d646184e 100644
--- a/src/__tests__/__snapshots__/gen-api-models.test.ts.snap
+++ b/src/__tests__/__snapshots__/gen-api-models.test.ts.snap
@@ -508,3 +508,19 @@ exports[`gen-api-models should support file uploads 1`] = `
// Decodes the success response with the type defined in the specs
export const testFileUploadDefaultDecoder = () => testFileUploadDecoder(t.undefined);"
`;
+
+exports[`gen-api-models should support generate requestbody 1`] = `
+"
+ /****************************************************************
+ * testRequestBody
+ */
+
+ // Request type definition
+ export type TestRequestBodyT = r.IPostApiRequestType<{readonly problem?: Problem}, \\"Content-Type\\", never, r.IResponseType<204, undefined>>;
+
+ // Decodes the success response with a custom success type
+ export function testRequestBodyDecoder(type: t.Type) { return r.ioResponseDecoder<204, (typeof type)[\\"_A\\"], (typeof type)[\\"_O\\"]>(204, type); }
+
+ // Decodes the success response with the type defined in the specs
+ export const testRequestBodyDefaultDecoder = () => testRequestBodyDecoder(t.undefined);"
+`;
diff --git a/src/__tests__/api.yaml b/src/__tests__/api.yaml
index fec97352..e114fa46 100644
--- a/src/__tests__/api.yaml
+++ b/src/__tests__/api.yaml
@@ -45,7 +45,42 @@ paths:
responses:
"200":
description: "File uploaded"
+ /test-serializers:
+ post:
+ operationId: "testSerializer"
+ parameters:
+ - name: "qo"
+ in: "query"
+ required: false
+ type: "string"
+ - $ref: "#/parameters/PaginationRequest"
+ responses:
+ "200":
+ description: "File uploaded"
+ schema:
+ $ref: "#/definitions/Message"
+ "403":
+ description: "Error string"
+ schema:
+ $ref: "#/definitions/Problem"
+ /test-requestbody:
+ post:
+ operationId: "testRequestBody"
+ parameters:
+ - in: body
+ name: body
+ schema:
+ "$ref": "#/definitions/Problem"
+ responses:
+ "204":
+ description: No content
definitions:
+ Problem:
+ properties:
+ title:
+ type: string
+ type:
+ type: string
AllOfTest:
allOf:
- type: object
diff --git a/src/__tests__/gen-api-models.test.ts b/src/__tests__/gen-api-models.test.ts
index 53ae8f29..5e337a1d 100644
--- a/src/__tests__/gen-api-models.test.ts
+++ b/src/__tests__/gen-api-models.test.ts
@@ -276,4 +276,25 @@ describe("gen-api-models", () => {
expect(code.e1).toMatchSnapshot();
});
+
+
+ it("should support generate requestbody", async () => {
+ const operation = spec.paths["/test-requestbody"].post;
+
+ const code = await renderOperation(
+ "post",
+ operation.operationId,
+ operation,
+ spec.parameters,
+ spec.securityDefinitions,
+ [],
+ {},
+ "undefined",
+ "undefined",
+ true
+ );
+
+ expect(code.e1).toMatchSnapshot();
+ });
+
});