From 84b25bc220d2f2421eabf945257d6a9146e89cd7 Mon Sep 17 00:00:00 2001 From: Artem Derevnjuk Date: Fri, 24 Feb 2023 14:25:06 +0400 Subject: [PATCH] fix(openapi-sampler): sampling the binary data (#199) closes #198 --- packages/oas/tests/fixtures/petstore.oas.result.json | 2 +- packages/openapi-sampler/src/samplers/StringSampler.ts | 2 +- packages/openapi-sampler/tests/string.spec.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/oas/tests/fixtures/petstore.oas.result.json b/packages/oas/tests/fixtures/petstore.oas.result.json index 41722116..1e766f74 100644 --- a/packages/oas/tests/fixtures/petstore.oas.result.json +++ b/packages/oas/tests/fixtures/petstore.oas.result.json @@ -198,7 +198,7 @@ "bodySize": 0, "postData": { "mimeType": "multipart/form-data; boundary=956888039105887155673143", - "text": "--956888039105887155673143\r\nContent-Disposition: form-data; name=\"additionalMetadata\"\r\n\r\nlorem\r\n--956888039105887155673143\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n\\x01\\x02\\x03\\x04\\x05\r\n--956888039105887155673143--" + "text": "--956888039105887155673143\r\nContent-Disposition: form-data; name=\"additionalMetadata\"\r\n\r\nlorem\r\n--956888039105887155673143\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n\u0001\u0002\u0003\u0004\u0005\r\n--956888039105887155673143--" } }, { diff --git a/packages/openapi-sampler/src/samplers/StringSampler.ts b/packages/openapi-sampler/src/samplers/StringSampler.ts index 8f1ab5da..8a80b33a 100644 --- a/packages/openapi-sampler/src/samplers/StringSampler.ts +++ b/packages/openapi-sampler/src/samplers/StringSampler.ts @@ -23,7 +23,7 @@ export class StringSampler implements Sampler { 'uri-reference': () => '../brokencrystals', 'uri-template': () => 'https://brokencrystals.com/api/file/{provider}', 'byte': () => 'ZHVtbXkgYmluYXJ5IHNhbXBsZQA=', - 'binary': () => '\\x01\\x02\\x03\\x04\\x05', + 'binary': () => '\x01\x02\x03\x04\x05', 'base64': () => 'ZHVtbXkgYmluYXJ5IHNhbXBsZQA=', 'uuid': () => 'fbdf5a53-161e-4460-98ad-0e39408d8689', 'json-pointer': () => '/json/pointer', diff --git a/packages/openapi-sampler/tests/string.spec.ts b/packages/openapi-sampler/tests/string.spec.ts index 9b5e7476..79101d11 100644 --- a/packages/openapi-sampler/tests/string.spec.ts +++ b/packages/openapi-sampler/tests/string.spec.ts @@ -45,7 +45,7 @@ describe('StringSampler', () => { type: 'string', format: 'binary' }, - expected: '\\x01\\x02\\x03\\x04\\x05' + expected: '\x01\x02\x03\x04\x05' }, { input: {