From 953f1b15208b6885fdad9d2b1dda9aa3867ae2e2 Mon Sep 17 00:00:00 2001 From: DmitryAnansky Date: Wed, 17 Dec 2025 15:56:37 +0200 Subject: [PATCH 1/3] fix: handling of runtime expressions with hyphenated keys in json pointers --- .changeset/silly-dingos-lie.md | 5 +++++ .../replace-json-pointers.test.ts | 15 +++++++++++++++ .../runtime-expressions/replace-json-pointers.ts | 10 +++++----- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 .changeset/silly-dingos-lie.md diff --git a/.changeset/silly-dingos-lie.md b/.changeset/silly-dingos-lie.md new file mode 100644 index 0000000000..37f8ce3e7f --- /dev/null +++ b/.changeset/silly-dingos-lie.md @@ -0,0 +1,5 @@ +--- +"@redocly/respect-core": patch +--- + +Fix Respect handling of runtime expressions with hyphenated keys in JSON pointers. diff --git a/packages/respect-core/src/modules/__tests__/runtime-expressions/replace-json-pointers.test.ts b/packages/respect-core/src/modules/__tests__/runtime-expressions/replace-json-pointers.test.ts index d22c2d9c48..437c87c426 100644 --- a/packages/respect-core/src/modules/__tests__/runtime-expressions/replace-json-pointers.test.ts +++ b/packages/respect-core/src/modules/__tests__/runtime-expressions/replace-json-pointers.test.ts @@ -169,4 +169,19 @@ describe('replaceJSONPointers', () => { expect(result).toBe('[] == []'); }); + + it('should correctly replace hyphenated keys', () => { + const context = { + $response: { + body: { + 'test-hyphenated-key-with-value': 'some-value-to-test', + }, + }, + }; + + const expression = '$response.body#/test-hyphenated-key-with-value'; + const result = replaceJSONPointers(expression, context); + + expect(result).toBe('"some-value-to-test"'); + }); }); diff --git a/packages/respect-core/src/modules/runtime-expressions/replace-json-pointers.ts b/packages/respect-core/src/modules/runtime-expressions/replace-json-pointers.ts index 51bc10f2b6..427e0b0030 100644 --- a/packages/respect-core/src/modules/runtime-expressions/replace-json-pointers.ts +++ b/packages/respect-core/src/modules/runtime-expressions/replace-json-pointers.ts @@ -3,25 +3,25 @@ import JsonPointerLib from 'json-pointer'; export function replaceJSONPointers(expression: string, context: any): string { const jsonPointerReplacementRules = [ { - pattern: /\$response\.body#\/([\w/]+)/g, + pattern: /\$response\.body#\/([\w/-]+)/g, ctxFunction: (match: string, pointer: string) => { return resolvePointer(context.$response?.body, pointer, match); }, }, { - pattern: /\$request\.body#\/([\w/]+)/g, + pattern: /\$request\.body#\/([\w/-]+)/g, ctxFunction: (match: string, pointer: string) => { return resolvePointer(context.$request?.body, pointer, match); }, }, { - pattern: /\$outputs\.([\w-]+)#\/([\w/]+)/g, + pattern: /\$outputs\.([\w-]+)#\/([\w/-]+)/g, ctxFunction: (match: string, property: string, pointer: string) => { return resolvePointer(context.$outputs?.[property], pointer, match); }, }, { - pattern: /\$workflows\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/]+)/g, + pattern: /\$workflows\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/-]+)/g, ctxFunction: (match: string, workflowId: string, property: string, pointer: string) => { return resolvePointer( context.$workflows?.[workflowId]?.outputs?.[property], @@ -31,7 +31,7 @@ export function replaceJSONPointers(expression: string, context: any): string { }, }, { - pattern: /\$steps\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/]+)/g, + pattern: /\$steps\.([\w-]+)\.outputs\.([\w-]+)#\/([\w/-]+)/g, ctxFunction: (match: string, stepId: string, property: string, pointer: string) => { return resolvePointer(context.$steps?.[stepId]?.outputs?.[property], pointer, match); }, From a390f73b9342c7cb21ce825dd44ef8a116ad068d Mon Sep 17 00:00:00 2001 From: DmitryAnansky Date: Wed, 17 Dec 2025 15:58:28 +0200 Subject: [PATCH 2/3] chore: update changelog --- .changeset/silly-dingos-lie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/silly-dingos-lie.md b/.changeset/silly-dingos-lie.md index 37f8ce3e7f..c2ab2fac56 100644 --- a/.changeset/silly-dingos-lie.md +++ b/.changeset/silly-dingos-lie.md @@ -2,4 +2,4 @@ "@redocly/respect-core": patch --- -Fix Respect handling of runtime expressions with hyphenated keys in JSON pointers. +Fixed Respect handling of runtime expressions with hyphenated keys in JSON pointers. From 0d294d7921db40415f05bc11cca9e16a7ab5f63e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81=C4=99kawa?= <164185257+JLekawa@users.noreply.github.com> Date: Wed, 17 Dec 2025 15:48:41 +0100 Subject: [PATCH 3/3] Update .changeset/silly-dingos-lie.md --- .changeset/silly-dingos-lie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/silly-dingos-lie.md b/.changeset/silly-dingos-lie.md index c2ab2fac56..e0e1e3743c 100644 --- a/.changeset/silly-dingos-lie.md +++ b/.changeset/silly-dingos-lie.md @@ -2,4 +2,4 @@ "@redocly/respect-core": patch --- -Fixed Respect handling of runtime expressions with hyphenated keys in JSON pointers. +Fixed Respect's handling of runtime expressions with hyphenated keys in JSON pointers.