Skip to content

Commit

Permalink
fix(msw): mock blobs as blobs instead of strings (#1269)
Browse files Browse the repository at this point in the history
Co-authored-by: Alfred Jonsson <alfred.jonsson@decerno.se>
  • Loading branch information
AffeJonsson and Alfred Jonsson committed Mar 18, 2024
1 parent bf161cb commit 54df332
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/mock/src/faker/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export const DEFAULT_FORMAT_MOCK: Record<
string
> = {
bic: 'faker.finance.bic()',
binary:
"new Blob(faker.helpers.arrayElements(faker.word.words(10).split(' ')))",
city: 'faker.location.city()',
country: 'faker.location.country()',
date: "faker.date.past().toISOString().split('T')[0]",
Expand Down
14 changes: 14 additions & 0 deletions tests/configs/swr.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,18 @@ export default defineConfig({
target: '../specifications/petstore.yaml',
},
},
blobFile: {
output: {
target: '../generated/swr/blob-file/endpoints.ts',
schemas: '../generated/swr/blob-file/model',
client: 'swr',
mock: true,
},
input: {
target: '../specifications/blob-file.yaml',
override: {
transformer: '../transformers/add-version.js',
},
},
},
});
25 changes: 25 additions & 0 deletions tests/specifications/blob-file.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
openapi: 3.1.0
info:
title: Blob File
description: 'Blobs'
version: 1.0.0
tags:
- name: blobs
description: Blobs
servers:
- url: http://localhost
paths:
/binary-blob:
get:
tags:
- blobs
summary: Binary Blob response
operationId: getBinaryBlob
responses:
200:
description: Successful Operation
content:
application/json:
schema:
type: 'string'
format: 'binary'

0 comments on commit 54df332

Please sign in to comment.