diff --git a/event-catalog/events/PersonSignedInContract/index.md b/event-catalog/events/PersonSignedInContract/index.md
new file mode 100644
index 0000000..60f48de
--- /dev/null
+++ b/event-catalog/events/PersonSignedInContract/index.md
@@ -0,0 +1,20 @@
+---
+name: PersonSignedInContract
+version: 1
+summary: |
+ A summary
+producers:
+ - Producer
+consumers:
+ - Consumer
+owners:
+ - Name
+---
+
+Some information
+
+### Details
+
+Some details...
+
+
\ No newline at end of file
diff --git a/event-catalog/events/PersonSignedInContract/schema.json b/event-catalog/events/PersonSignedInContract/schema.json
new file mode 100644
index 0000000..f231f09
--- /dev/null
+++ b/event-catalog/events/PersonSignedInContract/schema.json
@@ -0,0 +1,46 @@
+{
+ "$schema": "http://json-schema.org/draft-07/schema#",
+ "type": "object",
+ "properties": {
+ "detail-type": {
+ "type": "string",
+ "const": "PersonSignedInContract"
+ },
+ "detail": {
+ "type": "object",
+ "properties": {
+ "detail-version": {
+ "type": "number",
+ "const": 1
+ },
+ "data": {
+ "type": "object",
+ "properties": {
+ "userName": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "userName",
+ "password"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "required": [
+ "detail-version",
+ "data"
+ ],
+ "additionalProperties": false
+ }
+ },
+ "required": [
+ "detail",
+ "detail-type"
+ ],
+ "additionalProperties": false,
+ "definitions": {}
+}
\ No newline at end of file
diff --git a/example-architecture/events/contracts/personSignedInContractV1.ts b/example-architecture/events/contracts/personSignedInContractV1.ts
new file mode 100644
index 0000000..da46fd4
--- /dev/null
+++ b/example-architecture/events/contracts/personSignedInContractV1.ts
@@ -0,0 +1,12 @@
+import { Contract } from "../../types";
+
+export interface PersonSignedInContract extends Contract {
+ "detail-type": "PersonSignedInContract";
+ detail: {
+ "detail-version": 1;
+ data: {
+ userName: string;
+ password: string;
+ };
+ };
+}
diff --git a/src/__tests__/fixtures/contracts/testContract.ts b/src/__tests__/fixtures/contracts/testContract.ts
new file mode 100644
index 0000000..5850e91
--- /dev/null
+++ b/src/__tests__/fixtures/contracts/testContract.ts
@@ -0,0 +1,11 @@
+import { Contract } from "../types.js";
+export interface PersonRegisteredContract extends Contract {
+ "detail-type": "PersonRegisteredContract";
+ detail: {
+ "detail-version": 1;
+ data: {
+ firstName: string;
+ lastName: string;
+ };
+ };
+}
diff --git a/src/__tests__/fixtures/contracts/testContract2.ts b/src/__tests__/fixtures/contracts/testContract2.ts
new file mode 100644
index 0000000..f9e841d
--- /dev/null
+++ b/src/__tests__/fixtures/contracts/testContract2.ts
@@ -0,0 +1,10 @@
+import { Contract } from "../types.js";
+export interface PersonRegisteredContract extends Contract {
+ "detail-type": "PersonRegisteredContract";
+ detail: {
+ "detail-version": 2;
+ data: {
+ firstName: string;
+ };
+ };
+}
diff --git a/src/__tests__/fixtures/types.ts b/src/__tests__/fixtures/types.ts
new file mode 100644
index 0000000..19963d5
--- /dev/null
+++ b/src/__tests__/fixtures/types.ts
@@ -0,0 +1,9 @@
+export interface Contract {
+ readonly "detail-type": string;
+ readonly detail: Detail;
+}
+
+export interface Detail {
+ readonly "detail-version": number;
+ readonly data: Record;
+}
diff --git a/src/__tests__/generateDocs.integration.test.ts b/src/__tests__/generateDocs.integration.test.ts
new file mode 100644
index 0000000..ad10eca
--- /dev/null
+++ b/src/__tests__/generateDocs.integration.test.ts
@@ -0,0 +1,59 @@
+import { existsSync, readFileSync } from "fs";
+import { readdir } from "fs/promises";
+import path from "path";
+
+import { rimraf } from "rimraf";
+import { afterEach, describe, expect, it } from "vitest";
+
+import { generateDocumentation } from "../generateDocs.js";
+
+const testContractsPath = path.join(
+ process.cwd(),
+ "/src/__tests__/fixtures/contracts",
+);
+const testDocsPath = path.join(process.cwd(), "/src/__tests__/fixtures/docs");
+
+describe("Create documentation for contract types, standardised for use with event catalog", () => {
+ afterEach(async () => {
+ const files = await readdir(testDocsPath);
+ for (const file of files) {
+ await rimraf(path.join(testDocsPath, file));
+ }
+ });
+
+ it("Creates documentation without error when passed valid contract types", async () => {
+ await generateDocumentation(testContractsPath, testDocsPath);
+ const savedVersionedDocs = readFileSync(
+ path.join(
+ testDocsPath,
+ "/PersonRegisteredContract/versioned/1/schema.json",
+ ),
+ {
+ encoding: "utf8",
+ },
+ );
+ expect(savedVersionedDocs).toMatch(/("const": "PersonRegisteredContract")/);
+ expect(savedVersionedDocs).toMatch(/("const": 1)/);
+ expect(
+ existsSync(
+ path.join(
+ testDocsPath,
+ "/PersonRegisteredContract/versioned/1/index.md",
+ ),
+ ),
+ ).toStrictEqual(true);
+ const savedUnversionedDocs = readFileSync(
+ path.join(testDocsPath, "/PersonRegisteredContract/schema.json"),
+ {
+ encoding: "utf8",
+ },
+ );
+ expect(savedUnversionedDocs).toMatch(
+ /("const": "PersonRegisteredContract")/i,
+ );
+ expect(savedUnversionedDocs).toMatch(/("const": 2)/i);
+ expect(
+ existsSync(path.join(testDocsPath, "/PersonRegisteredContract/index.md")),
+ ).toStrictEqual(true);
+ });
+});
diff --git a/src/helpers/generateSchemaDetails.ts b/src/helpers/generateSchemaDetails.ts
index 9141897..d42c87f 100644
--- a/src/helpers/generateSchemaDetails.ts
+++ b/src/helpers/generateSchemaDetails.ts
@@ -1,4 +1,5 @@
import path from "path";
+
import { createGenerator } from "ts-json-schema-generator";
//TODO: We have to use relative paths here as apparently ts-node doesn't support esm :(