From 8b76f5d88b347febacfc9c8d2470e88c4e4ae9b5 Mon Sep 17 00:00:00 2001 From: James Berry Date: Tue, 19 Jul 2022 09:19:34 +0100 Subject: [PATCH] feat/operation-id --- src/generator/paths.ts | 2 ++ test/generator.test.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/src/generator/paths.ts b/src/generator/paths.ts index 5055395a..c1c7bd38 100644 --- a/src/generator/paths.ts +++ b/src/generator/paths.ts @@ -37,6 +37,7 @@ export const getOpenApiPathsObject = ( pathsObject[path] = { ...pathsObject[path], [httpMethod]: { + operationId: queryPath, summary, description, tags: tag ? [tag] : undefined, @@ -77,6 +78,7 @@ export const getOpenApiPathsObject = ( pathsObject[path] = { ...pathsObject[path], [httpMethod]: { + operationId: mutationPath, summary, description, tags: tag ? [tag] : undefined, diff --git a/test/generator.test.ts b/test/generator.test.ts index 45d71fab..82d7e382 100644 --- a/test/generator.test.ts +++ b/test/generator.test.ts @@ -547,6 +547,7 @@ describe('generator', () => { "/users": Object { "get": Object { "description": undefined, + "operationId": "readUsers", "parameters": undefined, "responses": Object { "200": Object { @@ -601,6 +602,7 @@ describe('generator', () => { }, "post": Object { "description": undefined, + "operationId": "createUser", "parameters": Array [], "requestBody": Object { "content": Object { @@ -673,6 +675,7 @@ describe('generator', () => { "/users/{id}": Object { "delete": Object { "description": undefined, + "operationId": "deleteUser", "parameters": Array [ Object { "description": undefined, @@ -717,6 +720,7 @@ describe('generator', () => { }, "get": Object { "description": undefined, + "operationId": "readUser", "parameters": Array [ Object { "description": undefined, @@ -778,6 +782,7 @@ describe('generator', () => { }, "patch": Object { "description": undefined, + "operationId": "updateUser", "parameters": Array [ Object { "description": undefined, @@ -982,6 +987,7 @@ describe('generator', () => { expect(openApiDocument.paths['/user']!.post!).toMatchInlineSnapshot(` Object { "description": undefined, + "operationId": "createUser", "parameters": Array [], "requestBody": Object { "content": Object { @@ -1066,6 +1072,7 @@ describe('generator', () => { expect(openApiDocument.paths['/user']!.get!).toMatchInlineSnapshot(` Object { "description": undefined, + "operationId": "getUser", "parameters": Array [ Object { "description": "User ID",