diff --git a/src/__tests__/__snapshots__/gen-api-models.test.ts.snap b/src/__tests__/__snapshots__/gen-api-models.test.ts.snap
index 3fa0ca2f..042512e8 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 serializers 1`] = `
+"
+ /****************************************************************
+ * testSerializer
+ */
+
+ // Request type definition
+ export type TestSerializerT = r.IPostApiRequestType<{readonly qo?: string}, \\"Content-Type\\", never, r.IResponseType<200, Message>|r.IResponseType<403, Problem>>;
+
+ // Decodes the success response with a custom success type
+ export function testSerializerDecoder(type: t.Type) { return r.composeResponseDecoders(r.ioResponseDecoder<200, (typeof type)[\\"_A\\"], (typeof type)[\\"_O\\"]>(200, type), r.ioResponseDecoder<403, (typeof Problem)[\\"_A\\"], (typeof Problem)[\\"_O\\"]>(403, Problem)); }
+
+ // Decodes the success response with the type defined in the specs
+ export const testSerializerDefaultDecoder = () => testSerializerDecoder(Message);"
+`;
diff --git a/src/__tests__/api.yaml b/src/__tests__/api.yaml
index fec97352..ab24ce99 100644
--- a/src/__tests__/api.yaml
+++ b/src/__tests__/api.yaml
@@ -45,7 +45,30 @@ paths:
responses:
"200":
description: "File uploaded"
+ /test-serializers:
+ post:
+ operationId: "testSerializer"
+ parameters:
+ - name: "qo"
+ in: "query"
+ required: false
+ type: "string"
+ responses:
+ "200":
+ description: "File uploaded"
+ schema:
+ $ref: "#/definitions/Message"
+ "403":
+ description: "Error string"
+ schema:
+ $ref: "#/definitions/Problem"
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..7175799b 100644
--- a/src/__tests__/gen-api-models.test.ts
+++ b/src/__tests__/gen-api-models.test.ts
@@ -276,4 +276,24 @@ describe("gen-api-models", () => {
expect(code.e1).toMatchSnapshot();
});
+
+ it("should support generate serializers", async () => {
+ const operation = spec.paths["/test-serializers"].post;
+
+ const code = await renderOperation(
+ "post",
+ operation.operationId,
+ operation,
+ spec.parameters,
+ spec.securityDefinitions,
+ [],
+ {},
+ "undefined",
+ "undefined",
+ true
+ );
+
+ expect(code.e1).toMatchSnapshot();
+ });
+
});