From 4adf0ed6f8ed4931c720dd92aa9413167765a4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ro=C5=BCek?= Date: Tue, 30 Apr 2024 17:27:50 +0200 Subject: [PATCH] fix(oas): extensions on tags is incorrectly spread --- .../__snapshots__/service.test.ts.snap | 22 ++++++++++++++----- src/oas/tags.ts | 2 +- src/oas2/__tests__/__fixtures__/id/bundled.ts | 1 + src/oas2/__tests__/bundle.test.ts | 6 +++-- src/oas3/__tests__/__fixtures__/id/bundled.ts | 1 + src/oas3/__tests__/__fixtures__/id/legacy.ts | 1 + src/oas3/__tests__/bundle.test.ts | 6 +++-- 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/oas/__tests__/__snapshots__/service.test.ts.snap b/src/oas/__tests__/__snapshots__/service.test.ts.snap index 076b248d..8b19f339 100644 --- a/src/oas/__tests__/__snapshots__/service.test.ts.snap +++ b/src/oas/__tests__/__snapshots__/service.test.ts.snap @@ -71,6 +71,7 @@ Object { "tags": Array [ Object { "description": "Everything about your Pets", + "extensions": Object {}, "externalDocs": Object { "description": "Find out more", "url": "http://swagger.io", @@ -80,11 +81,13 @@ Object { }, Object { "description": "Access to Petstore orders", + "extensions": Object {}, "id": "tag-store", "name": "store", }, Object { "description": "Operations about user", + "extensions": Object {}, "externalDocs": Object { "description": "Find out more about our store", "url": "http://swagger.io", @@ -93,11 +96,13 @@ Object { "name": "user", }, Object { + "extensions": Object { + "x-service-tag-extension": Object { + "hello": "world", + }, + }, "id": "tag-x-extension-in-tag", "name": "x-extension-in-tag", - "x-service-tag-extension": Object { - "hello": "world", - }, }, ], "termsOfService": "http://swagger.io/terms/", @@ -176,6 +181,7 @@ Object { "tags": Array [ Object { "description": "Everything about your Pets", + "extensions": Object {}, "externalDocs": Object { "description": "Find out more", "url": "http://swagger.io", @@ -185,11 +191,13 @@ Object { }, Object { "description": "Access to Petstore orders", + "extensions": Object {}, "id": "tag-store", "name": "store", }, Object { "description": "Operations about user", + "extensions": Object {}, "externalDocs": Object { "description": "Find out more about our store", "url": "http://swagger.io", @@ -198,11 +206,13 @@ Object { "name": "user", }, Object { + "extensions": Object { + "x-service-tag-extension": Object { + "hello": "world", + }, + }, "id": "tag-x-extension-in-tag", "name": "x-extension-in-tag", - "x-service-tag-extension": Object { - "hello": "world", - }, }, ], "termsOfService": "http://swagger.io/terms/", diff --git a/src/oas/tags.ts b/src/oas/tags.ts index 16326189..14675634 100644 --- a/src/oas/tags.ts +++ b/src/oas/tags.ts @@ -49,7 +49,7 @@ export const translateTagDefinition: TranslateFunction< ), ...toExternalDocs(tag.externalDocs), - ...extensions, + extensions, }; }; diff --git a/src/oas2/__tests__/__fixtures__/id/bundled.ts b/src/oas2/__tests__/__fixtures__/id/bundled.ts index 64da28ed..e977d2a5 100644 --- a/src/oas2/__tests__/__fixtures__/id/bundled.ts +++ b/src/oas2/__tests__/__fixtures__/id/bundled.ts @@ -14,6 +14,7 @@ export default { // hash('tag-mutates') id: 'tag-mutates', name: 'mutates', + extensions: {}, }, ], extensions: { diff --git a/src/oas2/__tests__/bundle.test.ts b/src/oas2/__tests__/bundle.test.ts index f3af30af..ea34d5ff 100644 --- a/src/oas2/__tests__/bundle.test.ts +++ b/src/oas2/__tests__/bundle.test.ts @@ -313,8 +313,10 @@ describe('bundleOas2Service', () => { { id: 'tag-service-tag-extension', name: 'service-tag-extension', - 'x-service-tag-extension': { - hello: 'world', + extensions: { + 'x-service-tag-extension': { + hello: 'world', + }, }, }, ], diff --git a/src/oas3/__tests__/__fixtures__/id/bundled.ts b/src/oas3/__tests__/__fixtures__/id/bundled.ts index fdf2c685..6a70c487 100644 --- a/src/oas3/__tests__/__fixtures__/id/bundled.ts +++ b/src/oas3/__tests__/__fixtures__/id/bundled.ts @@ -14,6 +14,7 @@ export default { // hash('tag-mutates') id: 'tag-mutates', name: 'mutates', + extensions: {}, }, ], components: { diff --git a/src/oas3/__tests__/__fixtures__/id/legacy.ts b/src/oas3/__tests__/__fixtures__/id/legacy.ts index 6901b97e..7f6fbca1 100644 --- a/src/oas3/__tests__/__fixtures__/id/legacy.ts +++ b/src/oas3/__tests__/__fixtures__/id/legacy.ts @@ -41,6 +41,7 @@ export default [ // hash(`tag-${tag.name}`) id: 'tag-mutates', name: 'mutates', + extensions: {}, }, ], extensions: { diff --git a/src/oas3/__tests__/bundle.test.ts b/src/oas3/__tests__/bundle.test.ts index 2919321d..112e5fdc 100644 --- a/src/oas3/__tests__/bundle.test.ts +++ b/src/oas3/__tests__/bundle.test.ts @@ -930,8 +930,10 @@ describe('bundleOas3Service', () => { { id: 'tag-service-tag-extension', name: 'service-tag-extension', - 'x-service-tag-extension': { - hello: 'world', + extensions: { + 'x-service-tag-extension': { + hello: 'world', + }, }, }, ],