Skip to content

Commit 49b6cf1

Browse files
committed
test(orval): cover ~0 escape in external $ref token decoding (#3380)
1 parent 6751077 commit 49b6cf1

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

packages/orval/src/import-specs.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,10 @@ describe('dereferenceExternalRefs', () => {
771771
'/pets/{petId}': {
772772
$ref: '#/x-ext/abc1234/paths/~1pets~1%7BpetId%7D',
773773
},
774+
// `~0` is the JSON Pointer escape for a literal `~` (RFC 6901).
775+
'/pets~dogs': {
776+
$ref: '#/x-ext/abc1234/paths/~1pets~0dogs',
777+
},
774778
},
775779
'x-ext': {
776780
abc1234: {
@@ -795,6 +799,12 @@ describe('dereferenceExternalRefs', () => {
795799
responses: { '200': { description: 'ok' } },
796800
},
797801
},
802+
'/pets~dogs': {
803+
get: {
804+
operationId: 'listPetsDogs',
805+
responses: { '200': { description: 'ok' } },
806+
},
807+
},
798808
},
799809
},
800810
},
@@ -822,6 +832,12 @@ describe('dereferenceExternalRefs', () => {
822832
responses: { '200': { description: 'ok' } },
823833
},
824834
});
835+
expect(result.paths?.['/pets~dogs']).toEqual({
836+
get: {
837+
operationId: 'listPetsDogs',
838+
responses: { '200': { description: 'ok' } },
839+
},
840+
});
825841
expect(result).not.toHaveProperty('x-ext');
826842
});
827843

0 commit comments

Comments
 (0)