diff --git a/samples/freee.json b/samples/freee.json index ccd6e98..6c511a6 100644 --- a/samples/freee.json +++ b/samples/freee.json @@ -18666,15 +18666,8 @@ "type": "string" }, "receipt": { - "description": "証憑ファイル", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "証憑ファイル" } }, "required": [ @@ -26226,226 +26219,6 @@ "type", "webkitRelativePath" ] - }, - "ReadStream": { - "description": "Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.", - "type": "object", - "properties": { - "bytesRead": { - "description": "The number of bytes that have been read so far.", - "type": "number" - }, - "path": { - "description": "The path to the file the stream is reading from as specified in the first\nargument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a\n`Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.", - "anyOf": [ - { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^[0-9]+$": { - "type": "number" - } - }, - "properties": { - "BYTES_PER_ELEMENT": { - "type": "number" - }, - "buffer": { - "$ref": "#/components/schemas/ArrayBufferLike" - }, - "byteLength": { - "type": "number" - }, - "byteOffset": { - "type": "number" - }, - "length": { - "type": "number" - }, - "__@toStringTag@138753": { - "type": "string", - "const": "Uint8Array" - } - }, - "required": [ - "BYTES_PER_ELEMENT", - "__@toStringTag@138753", - "buffer", - "byteLength", - "byteOffset", - "length" - ] - }, - { - "type": "string" - } - ] - }, - "pending": { - "description": "This property is `true` if the underlying file has not been opened yet,\ni.e. before the `'ready'` event is emitted.", - "type": "boolean" - }, - "readableAborted": { - "description": "Returns whether the stream was destroyed or errored before emitting `'end'`.", - "type": "boolean" - }, - "readable": { - "description": "Is `true` if it is safe to call {@link read}, which means\nthe stream has not been destroyed or emitted `'error'` or `'end'`.", - "type": "boolean" - }, - "readableDidRead": { - "description": "Returns whether `'data'` has been emitted.", - "type": "boolean" - }, - "readableEncoding": { - "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding` property can be set using the {@link setEncoding} method.", - "anyOf": [ - { - "enum": [ - "ascii", - "base64", - "base64url", - "binary", - "hex", - "latin1", - "ucs-2", - "ucs2", - "utf-16le", - "utf-8", - "utf16le", - "utf8" - ], - "type": "string" - }, - { - "type": "null" - } - ] - }, - "readableEnded": { - "description": "Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v22.x/api/stream.html#event-end) event is emitted.", - "type": "boolean" - }, - "readableFlowing": { - "description": "This property reflects the current state of a `Readable` stream as described\nin the [Three states](https://nodejs.org/docs/latest-v22.x/api/stream.html#three-states) section.", - "type": [ - "null", - "boolean" - ] - }, - "readableHighWaterMark": { - "description": "Returns the value of `highWaterMark` passed when creating this `Readable`.", - "type": "number" - }, - "readableLength": { - "description": "This property contains the number of bytes (or objects) in the queue\nready to be read. The value provides introspection data regarding\nthe status of the `highWaterMark`.", - "type": "number" - }, - "readableObjectMode": { - "description": "Getter for the property `objectMode` of a given `Readable` stream.", - "type": "boolean" - }, - "destroyed": { - "description": "Is `true` after `readable.destroy()` has been called.", - "type": "boolean" - }, - "closed": { - "description": "Is `true` after `'close'` has been emitted.", - "type": "boolean" - }, - "errored": { - "description": "Returns error if the stream has been destroyed with an error.", - "anyOf": [ - { - "$ref": "#/components/schemas/Error" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "bytesRead", - "closed", - "destroyed", - "errored", - "path", - "pending", - "readable", - "readableAborted", - "readableDidRead", - "readableEncoding", - "readableEnded", - "readableFlowing", - "readableHighWaterMark", - "readableLength", - "readableObjectMode" - ] - }, - "ArrayBufferLike": { - "anyOf": [ - { - "$ref": "#/components/schemas/ArrayBuffer" - }, - { - "$ref": "#/components/schemas/SharedArrayBuffer" - } - ] - }, - "ArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@toStringTag@138753": { - "type": "string" - } - }, - "required": [ - "__@toStringTag@138753", - "byteLength" - ] - }, - "SharedArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@species@139211": { - "$ref": "#/components/schemas/SharedArrayBuffer" - }, - "__@toStringTag@138753": { - "type": "string", - "const": "SharedArrayBuffer" - } - }, - "required": [ - "__@species@139211", - "__@toStringTag@138753", - "byteLength" - ] - }, - "Error": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "message": { - "type": "string" - }, - "stack": { - "type": "string" - }, - "cause": {} - }, - "required": [ - "message", - "name" - ] } } } diff --git a/samples/freee/@types/index.ts b/samples/freee/@types/index.ts index 2d7d5d7..d506d10 100644 --- a/samples/freee/@types/index.ts +++ b/samples/freee/@types/index.ts @@ -1,6 +1,4 @@ /* eslint-disable */ -import type { ReadStream } from 'fs' - export type PaymentParams = { /** 事業所ID */ company_id: number; @@ -578,7 +576,7 @@ export type ReceiptCreateParams = { /** 取引日 (yyyy-mm-dd) */ issue_date?: string | undefined; /** 証憑ファイル */ - receipt: (File | ReadStream); + receipt: File; } export type ReceiptUpdateParams = { diff --git a/samples/openapi.json b/samples/openapi.json index 5a314a6..c2dd942 100644 --- a/samples/openapi.json +++ b/samples/openapi.json @@ -639,15 +639,8 @@ "type": "object", "properties": { "file": { - "description": "Image to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Image to upload." }, "rightholder": { "type": "string" @@ -1548,15 +1541,8 @@ "type": "object", "properties": { "file": { - "description": "Audio to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Audio to upload." }, "caption": { "type": "string" @@ -1636,15 +1622,8 @@ "type": "object", "properties": { "file": { - "description": "Image to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Image to upload." }, "caption": { "type": "string" @@ -1898,15 +1877,8 @@ "type": "object", "properties": { "file": { - "description": "Video to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Video to upload." }, "caption": { "type": "string" @@ -3397,15 +3369,8 @@ "type": "object", "properties": { "file": { - "description": "Audio to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Audio to upload." }, "caption": { "type": "string" @@ -3477,15 +3442,8 @@ "type": "object", "properties": { "file": { - "description": "Image to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Image to upload." }, "caption": { "type": "string" @@ -3724,15 +3682,8 @@ "type": "object", "properties": { "file": { - "description": "Video to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Video to upload." }, "caption": { "type": "string" @@ -3849,15 +3800,8 @@ "type": "object", "properties": { "file": { - "description": "audio to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "audio to upload." } }, "required": [ @@ -3905,15 +3849,8 @@ "type": "object", "properties": { "file": { - "description": "Image to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Image to upload." } }, "required": [ @@ -4049,15 +3986,8 @@ "type": "object", "properties": { "file": { - "description": "Audio to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Audio to upload." }, "caption": { "type": "string" @@ -4129,15 +4059,8 @@ "type": "object", "properties": { "file": { - "description": "Image to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Image to upload." }, "caption": { "type": "string" @@ -4251,27 +4174,13 @@ "type": "number" }, "video": { - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File" }, "audioId": { "type": "number" }, "audio": { - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File" }, "text": { "type": "string" @@ -4340,15 +4249,8 @@ "type": "object", "properties": { "file": { - "description": "Video to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "Video to upload." }, "caption": { "type": "string" @@ -4408,15 +4310,8 @@ "type": "object", "properties": { "file": { - "description": "video to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File", + "description": "video to upload." } }, "required": [ @@ -5661,14 +5556,7 @@ }, "image": { "description": "Profile picture to upload.", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File" }, "imageId": { "type": "string" @@ -6032,226 +5920,6 @@ "type", "webkitRelativePath" ] - }, - "ReadStream": { - "description": "Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.", - "type": "object", - "properties": { - "bytesRead": { - "description": "The number of bytes that have been read so far.", - "type": "number" - }, - "path": { - "description": "The path to the file the stream is reading from as specified in the first\nargument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a\n`Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.", - "anyOf": [ - { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^[0-9]+$": { - "type": "number" - } - }, - "properties": { - "BYTES_PER_ELEMENT": { - "type": "number" - }, - "buffer": { - "$ref": "#/components/schemas/ArrayBufferLike" - }, - "byteLength": { - "type": "number" - }, - "byteOffset": { - "type": "number" - }, - "length": { - "type": "number" - }, - "__@toStringTag@188024": { - "type": "string", - "const": "Uint8Array" - } - }, - "required": [ - "BYTES_PER_ELEMENT", - "__@toStringTag@188024", - "buffer", - "byteLength", - "byteOffset", - "length" - ] - }, - { - "type": "string" - } - ] - }, - "pending": { - "description": "This property is `true` if the underlying file has not been opened yet,\ni.e. before the `'ready'` event is emitted.", - "type": "boolean" - }, - "readableAborted": { - "description": "Returns whether the stream was destroyed or errored before emitting `'end'`.", - "type": "boolean" - }, - "readable": { - "description": "Is `true` if it is safe to call {@link read}, which means\nthe stream has not been destroyed or emitted `'error'` or `'end'`.", - "type": "boolean" - }, - "readableDidRead": { - "description": "Returns whether `'data'` has been emitted.", - "type": "boolean" - }, - "readableEncoding": { - "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding` property can be set using the {@link setEncoding} method.", - "anyOf": [ - { - "enum": [ - "ascii", - "base64", - "base64url", - "binary", - "hex", - "latin1", - "ucs-2", - "ucs2", - "utf-16le", - "utf-8", - "utf16le", - "utf8" - ], - "type": "string" - }, - { - "type": "null" - } - ] - }, - "readableEnded": { - "description": "Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v22.x/api/stream.html#event-end) event is emitted.", - "type": "boolean" - }, - "readableFlowing": { - "description": "This property reflects the current state of a `Readable` stream as described\nin the [Three states](https://nodejs.org/docs/latest-v22.x/api/stream.html#three-states) section.", - "type": [ - "null", - "boolean" - ] - }, - "readableHighWaterMark": { - "description": "Returns the value of `highWaterMark` passed when creating this `Readable`.", - "type": "number" - }, - "readableLength": { - "description": "This property contains the number of bytes (or objects) in the queue\nready to be read. The value provides introspection data regarding\nthe status of the `highWaterMark`.", - "type": "number" - }, - "readableObjectMode": { - "description": "Getter for the property `objectMode` of a given `Readable` stream.", - "type": "boolean" - }, - "destroyed": { - "description": "Is `true` after `readable.destroy()` has been called.", - "type": "boolean" - }, - "closed": { - "description": "Is `true` after `'close'` has been emitted.", - "type": "boolean" - }, - "errored": { - "description": "Returns error if the stream has been destroyed with an error.", - "anyOf": [ - { - "$ref": "#/components/schemas/Error" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "bytesRead", - "closed", - "destroyed", - "errored", - "path", - "pending", - "readable", - "readableAborted", - "readableDidRead", - "readableEncoding", - "readableEnded", - "readableFlowing", - "readableHighWaterMark", - "readableLength", - "readableObjectMode" - ] - }, - "ArrayBufferLike": { - "anyOf": [ - { - "$ref": "#/components/schemas/ArrayBuffer" - }, - { - "$ref": "#/components/schemas/SharedArrayBuffer" - } - ] - }, - "ArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@toStringTag@188024": { - "type": "string" - } - }, - "required": [ - "__@toStringTag@188024", - "byteLength" - ] - }, - "SharedArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@species@188482": { - "$ref": "#/components/schemas/SharedArrayBuffer" - }, - "__@toStringTag@188024": { - "type": "string", - "const": "SharedArrayBuffer" - } - }, - "required": [ - "__@species@188482", - "__@toStringTag@188024", - "byteLength" - ] - }, - "Error": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "message": { - "type": "string" - }, - "stack": { - "type": "string" - }, - "cause": {} - }, - "required": [ - "message", - "name" - ] } } } diff --git a/samples/openapi/api/v1/parse/image/index.ts b/samples/openapi/api/v1/parse/image/index.ts index 55b4d35..992b770 100644 --- a/samples/openapi/api/v1/parse/image/index.ts +++ b/samples/openapi/api/v1/parse/image/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; export type Methods = DefineMethods<{ post: { @@ -15,7 +14,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Image to upload. */ - file: (File | ReadStream); + file: File; rightholder?: string | undefined; statusCopyright?: 'unknown' | 'cc' | 'licensed' | 'sublicensed' | undefined; }; diff --git a/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/audio/index.ts b/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/audio/index.ts index 84f20d8..8529782 100644 --- a/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/audio/index.ts +++ b/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/audio/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../../../@types'; export type Methods = DefineMethods<{ @@ -18,7 +17,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Audio to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; imageId?: string | undefined; diff --git a/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/image/index.ts b/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/image/index.ts index 6a8009a..2a4a476 100644 --- a/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/image/index.ts +++ b/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/image/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../../../@types'; export type Methods = DefineMethods<{ @@ -18,7 +17,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Image to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; published?: boolean | undefined; diff --git a/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/video/index.ts b/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/video/index.ts index bdf7e4a..7bd7e84 100644 --- a/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/video/index.ts +++ b/samples/openapi/api/v3/channels/_channelId@string/chats/_chatId@string/items/video/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../../../@types'; export type Methods = DefineMethods<{ @@ -18,7 +17,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Video to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; published?: boolean | undefined; diff --git a/samples/openapi/api/v3/chats/_chatId@string/items/audio/index.ts b/samples/openapi/api/v3/chats/_chatId@string/items/audio/index.ts index ecad3ee..1d24975 100644 --- a/samples/openapi/api/v3/chats/_chatId@string/items/audio/index.ts +++ b/samples/openapi/api/v3/chats/_chatId@string/items/audio/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../@types'; export type Methods = DefineMethods<{ @@ -18,7 +17,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Audio to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; imageId?: string | undefined; diff --git a/samples/openapi/api/v3/chats/_chatId@string/items/image/index.ts b/samples/openapi/api/v3/chats/_chatId@string/items/image/index.ts index e0d17ef..2c0efb3 100644 --- a/samples/openapi/api/v3/chats/_chatId@string/items/image/index.ts +++ b/samples/openapi/api/v3/chats/_chatId@string/items/image/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../@types'; export type Methods = DefineMethods<{ @@ -18,7 +17,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Image to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; published?: boolean | undefined; diff --git a/samples/openapi/api/v3/chats/_chatId@string/items/video/index.ts b/samples/openapi/api/v3/chats/_chatId@string/items/video/index.ts index eab0faa..773063a 100644 --- a/samples/openapi/api/v3/chats/_chatId@string/items/video/index.ts +++ b/samples/openapi/api/v3/chats/_chatId@string/items/video/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../@types'; export type Methods = DefineMethods<{ @@ -18,7 +17,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Video to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; published?: boolean | undefined; diff --git a/samples/openapi/api/v3/extension/audio/index.ts b/samples/openapi/api/v3/extension/audio/index.ts index fd68a80..1a96965 100644 --- a/samples/openapi/api/v3/extension/audio/index.ts +++ b/samples/openapi/api/v3/extension/audio/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../@types'; export type Methods = DefineMethods<{ @@ -17,7 +16,7 @@ export type Methods = DefineMethods<{ reqBody: { /** audio to upload. */ - file: (File | ReadStream); + file: File; }; }; }>; diff --git a/samples/openapi/api/v3/extension/image/index.ts b/samples/openapi/api/v3/extension/image/index.ts index b690fc3..33ae2f7 100644 --- a/samples/openapi/api/v3/extension/image/index.ts +++ b/samples/openapi/api/v3/extension/image/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../@types'; export type Methods = DefineMethods<{ @@ -19,7 +18,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Image to upload. */ - file: (File | ReadStream); + file: File; }; }; }>; diff --git a/samples/openapi/api/v3/extension/story/_storyId@string/audio/index.ts b/samples/openapi/api/v3/extension/story/_storyId@string/audio/index.ts index 2d4d058..da24919 100644 --- a/samples/openapi/api/v3/extension/story/_storyId@string/audio/index.ts +++ b/samples/openapi/api/v3/extension/story/_storyId@string/audio/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../@types'; export type Methods = DefineMethods<{ @@ -17,7 +16,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Audio to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; text?: string | undefined; diff --git a/samples/openapi/api/v3/extension/story/_storyId@string/image/index.ts b/samples/openapi/api/v3/extension/story/_storyId@string/image/index.ts index 78bd33d..770d098 100644 --- a/samples/openapi/api/v3/extension/story/_storyId@string/image/index.ts +++ b/samples/openapi/api/v3/extension/story/_storyId@string/image/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../@types'; export type Methods = DefineMethods<{ @@ -17,7 +16,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Image to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; text?: string | undefined; diff --git a/samples/openapi/api/v3/extension/story/_storyId@string/index.ts b/samples/openapi/api/v3/extension/story/_storyId@string/index.ts index 0df0484..9845cce 100644 --- a/samples/openapi/api/v3/extension/story/_storyId@string/index.ts +++ b/samples/openapi/api/v3/extension/story/_storyId@string/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../@types'; export type Methods = DefineMethods<{ @@ -31,9 +30,9 @@ export type Methods = DefineMethods<{ quoteSource?: string | undefined; quotePersonHandle?: string | undefined; videoId?: number | undefined; - video?: (File | ReadStream) | undefined; + video?: File | undefined; audioId?: number | undefined; - audio?: (File | ReadStream) | undefined; + audio?: File | undefined; text?: string | undefined; headline?: string | undefined; quoteCreated?: string | undefined; diff --git a/samples/openapi/api/v3/extension/story/_storyId@string/video/index.ts b/samples/openapi/api/v3/extension/story/_storyId@string/video/index.ts index 7ff99c2..3ee7a05 100644 --- a/samples/openapi/api/v3/extension/story/_storyId@string/video/index.ts +++ b/samples/openapi/api/v3/extension/story/_storyId@string/video/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../../../@types'; export type Methods = DefineMethods<{ @@ -17,7 +16,7 @@ export type Methods = DefineMethods<{ reqBody: { /** Video to upload. */ - file: (File | ReadStream); + file: File; caption?: string | undefined; headline?: string | undefined; text?: string | undefined; diff --git a/samples/openapi/api/v3/extension/video/index.ts b/samples/openapi/api/v3/extension/video/index.ts index 3131d2b..642a9fd 100644 --- a/samples/openapi/api/v3/extension/video/index.ts +++ b/samples/openapi/api/v3/extension/video/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../@types'; export type Methods = DefineMethods<{ @@ -19,7 +18,7 @@ export type Methods = DefineMethods<{ reqBody: { /** video to upload. */ - file: (File | ReadStream); + file: File; }; }; }>; diff --git a/samples/openapi/api/v3/user/profile/index.ts b/samples/openapi/api/v3/user/profile/index.ts index 97ff3f8..5572fb4 100644 --- a/samples/openapi/api/v3/user/profile/index.ts +++ b/samples/openapi/api/v3/user/profile/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../../@types'; export type Methods = DefineMethods<{ @@ -13,7 +12,7 @@ export type Methods = DefineMethods<{ screenName?: string | undefined; url?: string | undefined; /** Profile picture to upload. */ - image?: (File | ReadStream) | undefined; + image?: File | undefined; imageId?: string | undefined; }; }; diff --git a/samples/simple-openapi.json b/samples/simple-openapi.json index 0f8381d..181fb5e 100644 --- a/samples/simple-openapi.json +++ b/samples/simple-openapi.json @@ -135,14 +135,7 @@ "content": { "application/json": { "schema": { - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File" } } } @@ -397,226 +390,6 @@ "type", "webkitRelativePath" ] - }, - "ReadStream": { - "description": "Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.", - "type": "object", - "properties": { - "bytesRead": { - "description": "The number of bytes that have been read so far.", - "type": "number" - }, - "path": { - "description": "The path to the file the stream is reading from as specified in the first\nargument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a\n`Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.", - "anyOf": [ - { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^[0-9]+$": { - "type": "number" - } - }, - "properties": { - "BYTES_PER_ELEMENT": { - "type": "number" - }, - "buffer": { - "$ref": "#/components/schemas/ArrayBufferLike" - }, - "byteLength": { - "type": "number" - }, - "byteOffset": { - "type": "number" - }, - "length": { - "type": "number" - }, - "__@toStringTag@46242": { - "type": "string", - "const": "Uint8Array" - } - }, - "required": [ - "BYTES_PER_ELEMENT", - "__@toStringTag@46242", - "buffer", - "byteLength", - "byteOffset", - "length" - ] - }, - { - "type": "string" - } - ] - }, - "pending": { - "description": "This property is `true` if the underlying file has not been opened yet,\ni.e. before the `'ready'` event is emitted.", - "type": "boolean" - }, - "readableAborted": { - "description": "Returns whether the stream was destroyed or errored before emitting `'end'`.", - "type": "boolean" - }, - "readable": { - "description": "Is `true` if it is safe to call {@link read}, which means\nthe stream has not been destroyed or emitted `'error'` or `'end'`.", - "type": "boolean" - }, - "readableDidRead": { - "description": "Returns whether `'data'` has been emitted.", - "type": "boolean" - }, - "readableEncoding": { - "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding` property can be set using the {@link setEncoding} method.", - "anyOf": [ - { - "enum": [ - "ascii", - "base64", - "base64url", - "binary", - "hex", - "latin1", - "ucs-2", - "ucs2", - "utf-16le", - "utf-8", - "utf16le", - "utf8" - ], - "type": "string" - }, - { - "type": "null" - } - ] - }, - "readableEnded": { - "description": "Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v22.x/api/stream.html#event-end) event is emitted.", - "type": "boolean" - }, - "readableFlowing": { - "description": "This property reflects the current state of a `Readable` stream as described\nin the [Three states](https://nodejs.org/docs/latest-v22.x/api/stream.html#three-states) section.", - "type": [ - "null", - "boolean" - ] - }, - "readableHighWaterMark": { - "description": "Returns the value of `highWaterMark` passed when creating this `Readable`.", - "type": "number" - }, - "readableLength": { - "description": "This property contains the number of bytes (or objects) in the queue\nready to be read. The value provides introspection data regarding\nthe status of the `highWaterMark`.", - "type": "number" - }, - "readableObjectMode": { - "description": "Getter for the property `objectMode` of a given `Readable` stream.", - "type": "boolean" - }, - "destroyed": { - "description": "Is `true` after `readable.destroy()` has been called.", - "type": "boolean" - }, - "closed": { - "description": "Is `true` after `'close'` has been emitted.", - "type": "boolean" - }, - "errored": { - "description": "Returns error if the stream has been destroyed with an error.", - "anyOf": [ - { - "$ref": "#/components/schemas/Error" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "bytesRead", - "closed", - "destroyed", - "errored", - "path", - "pending", - "readable", - "readableAborted", - "readableDidRead", - "readableEncoding", - "readableEnded", - "readableFlowing", - "readableHighWaterMark", - "readableLength", - "readableObjectMode" - ] - }, - "ArrayBufferLike": { - "anyOf": [ - { - "$ref": "#/components/schemas/ArrayBuffer" - }, - { - "$ref": "#/components/schemas/SharedArrayBuffer" - } - ] - }, - "ArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@toStringTag@46242": { - "type": "string" - } - }, - "required": [ - "__@toStringTag@46242", - "byteLength" - ] - }, - "SharedArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@species@46700": { - "$ref": "#/components/schemas/SharedArrayBuffer" - }, - "__@toStringTag@46242": { - "type": "string", - "const": "SharedArrayBuffer" - } - }, - "required": [ - "__@species@46700", - "__@toStringTag@46242", - "byteLength" - ] - }, - "Error": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "message": { - "type": "string" - }, - "stack": { - "type": "string" - }, - "cause": {} - }, - "required": [ - "message", - "name" - ] } } } diff --git a/samples/simple/file/_id@number/upload/index.ts b/samples/simple/file/_id@number/upload/index.ts index a1c3d24..f0007a2 100644 --- a/samples/simple/file/_id@number/upload/index.ts +++ b/samples/simple/file/_id@number/upload/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; export type Methods = DefineMethods<{ post: { @@ -9,6 +8,6 @@ export type Methods = DefineMethods<{ } | undefined; status: 204; - reqBody: (File | ReadStream); + reqBody: File; }; }>; diff --git a/samples/swagger.json b/samples/swagger.json index 4552f45..e8588c0 100644 --- a/samples/swagger.json +++ b/samples/swagger.json @@ -197,14 +197,7 @@ }, "file": { "description": "file to upload", - "anyOf": [ - { - "$ref": "#/components/schemas/File" - }, - { - "$ref": "#/components/schemas/ReadStream" - } - ] + "$ref": "#/components/schemas/File" } } } @@ -997,226 +990,6 @@ "type", "webkitRelativePath" ] - }, - "ReadStream": { - "description": "Instances of `fs.ReadStream` are created and returned using the {@link createReadStream} function.", - "type": "object", - "properties": { - "bytesRead": { - "description": "The number of bytes that have been read so far.", - "type": "number" - }, - "path": { - "description": "The path to the file the stream is reading from as specified in the first\nargument to `fs.createReadStream()`. If `path` is passed as a string, then`readStream.path` will be a string. If `path` is passed as a `Buffer`, then`readStream.path` will be a\n`Buffer`. If `fd` is specified, then`readStream.path` will be `undefined`.", - "anyOf": [ - { - "type": "object", - "additionalProperties": false, - "patternProperties": { - "^[0-9]+$": { - "type": "number" - } - }, - "properties": { - "BYTES_PER_ELEMENT": { - "type": "number" - }, - "buffer": { - "$ref": "#/components/schemas/ArrayBufferLike" - }, - "byteLength": { - "type": "number" - }, - "byteOffset": { - "type": "number" - }, - "length": { - "type": "number" - }, - "__@toStringTag@23": { - "type": "string", - "const": "Uint8Array" - } - }, - "required": [ - "BYTES_PER_ELEMENT", - "__@toStringTag@23", - "buffer", - "byteLength", - "byteOffset", - "length" - ] - }, - { - "type": "string" - } - ] - }, - "pending": { - "description": "This property is `true` if the underlying file has not been opened yet,\ni.e. before the `'ready'` event is emitted.", - "type": "boolean" - }, - "readableAborted": { - "description": "Returns whether the stream was destroyed or errored before emitting `'end'`.", - "type": "boolean" - }, - "readable": { - "description": "Is `true` if it is safe to call {@link read}, which means\nthe stream has not been destroyed or emitted `'error'` or `'end'`.", - "type": "boolean" - }, - "readableDidRead": { - "description": "Returns whether `'data'` has been emitted.", - "type": "boolean" - }, - "readableEncoding": { - "description": "Getter for the property `encoding` of a given `Readable` stream. The `encoding` property can be set using the {@link setEncoding} method.", - "anyOf": [ - { - "enum": [ - "ascii", - "base64", - "base64url", - "binary", - "hex", - "latin1", - "ucs-2", - "ucs2", - "utf-16le", - "utf-8", - "utf16le", - "utf8" - ], - "type": "string" - }, - { - "type": "null" - } - ] - }, - "readableEnded": { - "description": "Becomes `true` when [`'end'`](https://nodejs.org/docs/latest-v22.x/api/stream.html#event-end) event is emitted.", - "type": "boolean" - }, - "readableFlowing": { - "description": "This property reflects the current state of a `Readable` stream as described\nin the [Three states](https://nodejs.org/docs/latest-v22.x/api/stream.html#three-states) section.", - "type": [ - "null", - "boolean" - ] - }, - "readableHighWaterMark": { - "description": "Returns the value of `highWaterMark` passed when creating this `Readable`.", - "type": "number" - }, - "readableLength": { - "description": "This property contains the number of bytes (or objects) in the queue\nready to be read. The value provides introspection data regarding\nthe status of the `highWaterMark`.", - "type": "number" - }, - "readableObjectMode": { - "description": "Getter for the property `objectMode` of a given `Readable` stream.", - "type": "boolean" - }, - "destroyed": { - "description": "Is `true` after `readable.destroy()` has been called.", - "type": "boolean" - }, - "closed": { - "description": "Is `true` after `'close'` has been emitted.", - "type": "boolean" - }, - "errored": { - "description": "Returns error if the stream has been destroyed with an error.", - "anyOf": [ - { - "$ref": "#/components/schemas/Error" - }, - { - "type": "null" - } - ] - } - }, - "required": [ - "bytesRead", - "closed", - "destroyed", - "errored", - "path", - "pending", - "readable", - "readableAborted", - "readableDidRead", - "readableEncoding", - "readableEnded", - "readableFlowing", - "readableHighWaterMark", - "readableLength", - "readableObjectMode" - ] - }, - "ArrayBufferLike": { - "anyOf": [ - { - "$ref": "#/components/schemas/ArrayBuffer" - }, - { - "$ref": "#/components/schemas/SharedArrayBuffer" - } - ] - }, - "ArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@toStringTag@23": { - "type": "string" - } - }, - "required": [ - "__@toStringTag@23", - "byteLength" - ] - }, - "SharedArrayBuffer": { - "type": "object", - "properties": { - "byteLength": { - "type": "number" - }, - "__@species@481": { - "$ref": "#/components/schemas/SharedArrayBuffer" - }, - "__@toStringTag@23": { - "type": "string", - "const": "SharedArrayBuffer" - } - }, - "required": [ - "__@species@481", - "__@toStringTag@23", - "byteLength" - ] - }, - "Error": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "message": { - "type": "string" - }, - "stack": { - "type": "string" - }, - "cause": {} - }, - "required": [ - "message", - "name" - ] } } } diff --git a/samples/swagger/pet/_petId@number/uploadImage/index.ts b/samples/swagger/pet/_petId@number/uploadImage/index.ts index 35a8230..5a8a4a5 100644 --- a/samples/swagger/pet/_petId@number/uploadImage/index.ts +++ b/samples/swagger/pet/_petId@number/uploadImage/index.ts @@ -1,6 +1,5 @@ /* eslint-disable */ import type { DefineMethods } from 'aspida'; -import type { ReadStream } from 'fs'; import type * as Types from '../../../@types'; export type Methods = DefineMethods<{ @@ -14,7 +13,7 @@ export type Methods = DefineMethods<{ /** Additional data to pass to server */ additionalMetadata?: string | undefined; /** file to upload */ - file?: (File | ReadStream) | undefined; + file?: File | undefined; }; }; }>; diff --git a/tests/index.test.ts b/tests/index.test.ts new file mode 100644 index 0000000..6ed07af --- /dev/null +++ b/tests/index.test.ts @@ -0,0 +1,26 @@ +import fs from 'fs'; +import { afterAll, beforeAll, describe, expect, test } from 'vitest'; +import build from '../src'; +import type { ConfigFile } from '../src/getConfig'; + +describe('cli test', () => { + beforeAll(() => fs.mkdirSync('_samples')); + afterAll(() => fs.promises.rmdir('_samples', { recursive: true })); + + test('main', () => { + const configs: ConfigFile[] = require('../aspida.config.js'); + + return Promise.all( + configs.map(async (config) => { + const originalFile = config.openapi?.outputFile ?? `${config.input}.json`; + const outputFile = `_${originalFile}`; + + await build({ ...config, openapi: { outputFile } })[0]; + + expect(fs.readFileSync(outputFile, 'utf8')).toBe( + fs.readFileSync(originalFile, 'utf8').replace(/\r/g, ''), + ); + }), + ); + }); +});