Skip to content

Commit 54df332

Browse files
AllieJonssonAlfred Jonsson
and
Alfred Jonsson
authoredMar 18, 2024
fix(msw): mock blobs as blobs instead of strings (#1269)
Co-authored-by: Alfred Jonsson <alfred.jonsson@decerno.se>
1 parent bf161cb commit 54df332

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
 

‎packages/mock/src/faker/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export const DEFAULT_FORMAT_MOCK: Record<
55
string
66
> = {
77
bic: 'faker.finance.bic()',
8+
binary:
9+
"new Blob(faker.helpers.arrayElements(faker.word.words(10).split(' ')))",
810
city: 'faker.location.city()',
911
country: 'faker.location.country()',
1012
date: "faker.date.past().toISOString().split('T')[0]",

‎tests/configs/swr.config.ts

+14
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,18 @@ export default defineConfig({
131131
target: '../specifications/petstore.yaml',
132132
},
133133
},
134+
blobFile: {
135+
output: {
136+
target: '../generated/swr/blob-file/endpoints.ts',
137+
schemas: '../generated/swr/blob-file/model',
138+
client: 'swr',
139+
mock: true,
140+
},
141+
input: {
142+
target: '../specifications/blob-file.yaml',
143+
override: {
144+
transformer: '../transformers/add-version.js',
145+
},
146+
},
147+
},
134148
});

‎tests/specifications/blob-file.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
openapi: 3.1.0
2+
info:
3+
title: Blob File
4+
description: 'Blobs'
5+
version: 1.0.0
6+
tags:
7+
- name: blobs
8+
description: Blobs
9+
servers:
10+
- url: http://localhost
11+
paths:
12+
/binary-blob:
13+
get:
14+
tags:
15+
- blobs
16+
summary: Binary Blob response
17+
operationId: getBinaryBlob
18+
responses:
19+
200:
20+
description: Successful Operation
21+
content:
22+
application/json:
23+
schema:
24+
type: 'string'
25+
format: 'binary'

0 commit comments

Comments
 (0)
Please sign in to comment.