diff --git a/next-ui/openapi-generator.mts b/next-ui/openapi-generator.mts index 0156512e0..7aee26434 100644 --- a/next-ui/openapi-generator.mts +++ b/next-ui/openapi-generator.mts @@ -1,26 +1,36 @@ -import fs from "node:fs"; -import openapiTS, { astToString } from "openapi-typescript"; -import ts from "typescript"; +import fs from 'node:fs' +import openapiTS, { astToString } from 'openapi-typescript' +import ts from 'typescript' // From https://openapi-ts.dev/node // We use the Node.js API as the CLI does not support Date types -const mySchema = new URL("../komga/docs/openapi.json", import.meta.url) +const mySchema = new URL('../komga/docs/openapi.json', import.meta.url) -const DATE = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("Date")); // `Date` -const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); // `null` +const DATE = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('Date')) // `Date` +const FILE = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('File')) // `File` +const BLOB = ts.factory.createTypeReferenceNode(ts.factory.createIdentifier('Blob')) // `Blob` +const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()) // `null` const ast = await openapiTS(mySchema, { - transform(schemaObject) { - if (schemaObject.format === "date-time") { - return schemaObject.nullable - ? ts.factory.createUnionTypeNode([DATE, NULL]) - : DATE; + transform(schemaObject, metadata) { + if (schemaObject.format === 'date-time') { + return schemaObject.nullable ? ts.factory.createUnionTypeNode([DATE, NULL]) : DATE + } + if (schemaObject.format === 'binary') { + console.log(schemaObject) + console.log(metadata) + if (metadata.path.includes('multipart~1form-data')) { + return schemaObject.nullable ? ts.factory.createUnionTypeNode([FILE, NULL]) : FILE + } + if (metadata.path.includes('application~1octet-stream')) { + return schemaObject.nullable ? ts.factory.createUnionTypeNode([BLOB, NULL]) : BLOB + } } }, -}); +}) -const contents = astToString(ast); +const contents = astToString(ast) // (optional) write to file -fs.writeFileSync("./src/generated/openapi/komga.d.ts", contents); +fs.writeFileSync('./src/generated/openapi/komga.d.ts', contents) diff --git a/next-ui/src/generated/openapi/komga.d.ts b/next-ui/src/generated/openapi/komga.d.ts index bebaf4751..9de3da13d 100644 --- a/next-ui/src/generated/openapi/komga.d.ts +++ b/next-ui/src/generated/openapi/komga.d.ts @@ -3046,7 +3046,11 @@ export interface components { * @example Version 1.9.0 contains the second feature drop for Ebooks support. */ summary?: string; - /** @description Tags describing the item */ + /** + * @description Tags describing the item + * @example upgrade + * @example komga + */ tags: string[]; /** * @description Plain text title @@ -5469,7 +5473,7 @@ export interface operations { content: { "multipart/form-data": { /** Format: binary */ - file: string; + file: File; }; }; }; @@ -6155,7 +6159,7 @@ export interface operations { content: { "multipart/form-data": { /** Format: binary */ - file: string; + file: File; }; }; }; @@ -7242,9 +7246,9 @@ export interface operations { }; requestBody?: { content: { - "application/json": { + "multipart/form-data": { /** Format: binary */ - file: string; + file: File; }; }; }; @@ -7644,7 +7648,7 @@ export interface operations { content: { "multipart/form-data": { /** Format: binary */ - file: string; + file: File; }; }; }; @@ -8518,7 +8522,7 @@ export interface operations { content: { "multipart/form-data": { /** Format: binary */ - file: string; + file: File; }; }; };