Skip to content

Commit 39696b1

Browse files
committed
feat(cli): shallow merge OAS paths
1 parent f68b696 commit 39696b1

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

packages/cli/src/document-transformer.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@ import {
99
import { DocumentTransformer } from "./document-transformer.js";
1010
import { OASDocument, RPCDocument } from "./types";
1111

12+
const healthCheck = {
13+
"/health": {
14+
get: {
15+
operationId: "health",
16+
description: "Health check",
17+
responses: {
18+
200: {
19+
description: "OK",
20+
},
21+
},
22+
},
23+
},
24+
};
25+
1226
const rpcDocument: RPCDocument = {
1327
yarpc: "1.0.0",
1428
info: {
1529
title: "Widgets API",
1630
version: "1.0.0",
1731
},
32+
paths: {
33+
...healthCheck,
34+
},
1835
operations: {
1936
queries,
2037
mutations,
@@ -25,7 +42,10 @@ const rpcDocument: RPCDocument = {
2542
const oasDocument: OASDocument = {
2643
openapi: "3.1.0",
2744
info: rpcDocument.info,
28-
paths,
45+
paths: {
46+
...healthCheck,
47+
...paths,
48+
},
2949
components: rpcDocument.components,
3050
};
3151

packages/cli/src/document-transformer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class DocumentTransformer {
1717
}
1818

1919
async transform(): Promise<OASDocument> {
20-
const { info, operations, yarpc, ...rest } = this.doc;
20+
const { info, paths: oasPaths, operations, yarpc, ...rest } = this.doc;
2121

2222
if (typeof yarpc !== "string") {
2323
throw new Error("Missing required yarpc version");
@@ -32,7 +32,10 @@ export class DocumentTransformer {
3232
return {
3333
openapi: "3.1.0",
3434
info,
35-
paths,
35+
paths: {
36+
...oasPaths,
37+
...paths,
38+
},
3639
...rest,
3740
};
3841
}

0 commit comments

Comments
 (0)