We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Description
I'm trying to use the docs example to transform the schema for Date & Blobs.
[{ "resource": "/Users/simon/Code/WebApp/packages/sdk/openapi.ts", "owner": "typescript", "code": "2322", "severity": 8, "message": "Type '(schemaObject: SchemaObject) => Identifier | UnionTypeNode | undefined' is not assignable to type '(schemaObject: SchemaObject, options: TransformNodeOptions) => TypeNode | TransformObject | undefined'.\n Type 'Identifier | UnionTypeNode | undefined' is not assignable to type 'TypeNode | TransformObject | undefined'.\n Type 'Identifier' is not assignable to type 'TypeNode | TransformObject | undefined'.\n Type 'Identifier' is not assignable to type 'TypeNode'.", "source": "ts", "startLineNumber": 12, "startColumn": 5, "endLineNumber": 12, "endColumn": 14 },{ "resource": "/Users/simon/Code/WebApp/packages/sdk/openapi.ts", "owner": "typescript", "code": "2741", "severity": 8, "message": "Property '_typeNodeBrand' is missing in type 'Identifier' but required in type 'TypeNode'.", "source": "ts", "startLineNumber": 15, "startColumn": 45, "endLineNumber": 15, "endColumn": 49, "relatedInformation": [ { "startLineNumber": 5204, "startColumn": 9, "endLineNumber": 5204, "endColumn": 23, "message": "'_typeNodeBrand' is declared here.", "resource": "/Users/simon/Code/WebApp/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.d.ts" } ] },{ "resource": "/Users/simon/Code/WebApp/packages/sdk/openapi.ts", "owner": "typescript", "code": "2322", "severity": 8, "message": "Type 'Identifier' is not assignable to type 'TypeNode'.", "source": "ts", "startLineNumber": 20, "startColumn": 45, "endLineNumber": 20, "endColumn": 49 }]
openapi-typescript
7.0.0-rc.0
v20.11.1
v5.5.5
macOS 14.5
Reproduction
Here's my TS file I'm using to generate my SDK:
import fs from "node:fs"; import openapiTS, { astToString } from "openapi-typescript"; import ts from "typescript"; const BLOB = ts.factory.createIdentifier("Blob"); // `Blob` const DATE = ts.factory.createIdentifier("Date"); // `Date` const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); // `null` const ast = await openapiTS( new URL(mySchema), { transform(schemaObject) { if (schemaObject.format === "date-time") { return schemaObject.nullable ? ts.factory.createUnionTypeNode([DATE, NULL]) : DATE; } if (schemaObject.format === "binary") { return schemaObject.nullable ? ts.factory.createUnionTypeNode([BLOB, NULL]) : BLOB; } }, }, ); const contents = astToString(ast); fs.writeFileSync("./src/api.ts", contents);
Expected result
No Typescript errors.
Checklist
npx @redocly/cli@latest lint
The text was updated successfully, but these errors were encountered:
Do you think this is related: microsoft/TypeScript#40263
Sorry, something went wrong.
Did you manage to solve this? 🙂 I ran into the same problem when following the docs example.
Nope, I'm not using this at the moment.
No branches or pull requests
Description
I'm trying to use the docs example to transform the schema for Date & Blobs.
openapi-typescript
7.0.0-rc.0
v20.11.1
v5.5.5
macOS 14.5
Reproduction
Here's my TS file I'm using to generate my SDK:
Expected result
No Typescript errors.
Checklist
npx @redocly/cli@latest lint
)The text was updated successfully, but these errors were encountered: