Skip to content

Commit

Permalink
refactor: simplify openapi-typescript compat code
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed May 29, 2024
1 parent 1934061 commit 55649cf
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import { useNuxt } from '@nuxt/kit'
import type { OpenAPI3, OpenAPITSOptions } from 'openapi-typescript'
import type { ApiEndpoint } from './module'

// Add types for compatibility between openapi-typescript v6 and v7
declare module 'openapi-typescript' {
/** @since openapi-typescript@7 */
function _astToString(ast: unknown): string
export const astToString: typeof _astToString | undefined
}

export async function generateDeclarationTypes(
endpoints: Record<string, ApiEndpoint>,
globalOpenAPIOptions: OpenAPITSOptions,
Expand Down Expand Up @@ -44,6 +37,7 @@ async function generateSchemaTypes(options: {

try {
const ast = await openAPITS(schema, {
// @ts-expect-error: openapi-typescript >= 7 dropped this option
commentHeader: '',
...options.openAPITSOptions,
...options.endpoint.openAPITS,
Expand Down

0 comments on commit 55649cf

Please sign in to comment.