-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1305 from hey-api/fix/experimental-parser-content…
…-file-no-schema fix: handle file-like content media type without explicit schema
- Loading branch information
Showing
17 changed files
with
291 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hey-api/openapi-ts': patch | ||
--- | ||
|
||
fix: handle file-like content media type without explicit schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { isMediaTypeFileLike } from '../mediaType'; | ||
|
||
describe('isMediaTypeFileLike', () => { | ||
const scenarios: Array<{ | ||
fileLike: ReturnType<typeof isMediaTypeFileLike>; | ||
mediaType: Parameters<typeof isMediaTypeFileLike>[0]['mediaType']; | ||
}> = [ | ||
{ | ||
fileLike: false, | ||
mediaType: 'application/json', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'application/json+download', | ||
}, | ||
{ | ||
fileLike: false, | ||
mediaType: 'application/json; charset=ascii', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'application/octet-stream', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'application/pdf', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'application/xml; charset=utf-8', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'application/zip', | ||
}, | ||
{ | ||
fileLike: false, | ||
mediaType: 'image/jpeg', | ||
}, | ||
{ | ||
fileLike: false, | ||
mediaType: 'image/jpeg; charset=utf-8', | ||
}, | ||
{ | ||
fileLike: false, | ||
mediaType: 'text/html; charset=utf-8', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'text/javascript; charset=ISO-8859-1', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'text/plain; charset=utf-8', | ||
}, | ||
{ | ||
fileLike: true, | ||
mediaType: 'video/mp4', | ||
}, | ||
]; | ||
|
||
it.each(scenarios)( | ||
'detects $mediaType as file-like? $fileLike', | ||
async ({ mediaType, fileLike }) => { | ||
expect(isMediaTypeFileLike({ mediaType })).toEqual(fileLike); | ||
}, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/openapi-ts/test/__snapshots__/3.0.x/content-binary/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './types.gen'; |
13 changes: 13 additions & 0 deletions
13
packages/openapi-ts/test/__snapshots__/3.0.x/content-binary/types.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
export type GetFooResponses = { | ||
200: string; | ||
}; | ||
|
||
export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; | ||
|
||
export type GetBarResponses = { | ||
200: Blob | File; | ||
}; | ||
|
||
export type GetBarResponse = GetBarResponses[keyof GetBarResponses]; |
2 changes: 2 additions & 0 deletions
2
packages/openapi-ts/test/__snapshots__/3.1.x/content-binary/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
export * from './types.gen'; |
13 changes: 13 additions & 0 deletions
13
packages/openapi-ts/test/__snapshots__/3.1.x/content-binary/types.gen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// This file is auto-generated by @hey-api/openapi-ts | ||
|
||
export type GetFooResponses = { | ||
200: string; | ||
}; | ||
|
||
export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; | ||
|
||
export type GetBarResponses = { | ||
200: Blob | File; | ||
}; | ||
|
||
export type GetBarResponse = GetBarResponses[keyof GetBarResponses]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "OpenAPI 3.0.0 content binary example", | ||
"version": "1" | ||
}, | ||
"paths": { | ||
"/foo": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"content": { | ||
"image/png": { | ||
"schema": { | ||
"type": "string", | ||
"contentMediaType": "image/png", | ||
"contentEncoding": "base64" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/bar": { | ||
"get": { | ||
"responses": { | ||
"200": { | ||
"content": { | ||
"application/zip": {} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.