From d129d2bb77fd07d390374231db2cedde3d2cd6a4 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 7 Apr 2026 00:27:16 +0200 Subject: [PATCH] fix: stricter openapi 2.0 type --- .changeset/short-walls-battle.md | 5 +++++ packages/spec-types/package.json | 8 ++++---- packages/spec-types/src/openapi/v2/spec.ts | 2 +- packages/spec-types/tsconfig.json | 3 ++- packages/spec-types/tsdown.config.ts | 10 ++++++++++ packages/spec-types/turbo.json | 10 ++++++++++ 6 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 .changeset/short-walls-battle.md create mode 100644 packages/spec-types/tsdown.config.ts create mode 100644 packages/spec-types/turbo.json diff --git a/.changeset/short-walls-battle.md b/.changeset/short-walls-battle.md new file mode 100644 index 000000000..699685528 --- /dev/null +++ b/.changeset/short-walls-battle.md @@ -0,0 +1,5 @@ +--- +"@hey-api/spec-types": patch +--- + +**openapi**: fix: stricter 2.0 version type diff --git a/packages/spec-types/package.json b/packages/spec-types/package.json index 5a00b6b3d..67840ebd6 100644 --- a/packages/spec-types/package.json +++ b/packages/spec-types/package.json @@ -37,16 +37,16 @@ ], "type": "module", "sideEffects": false, - "types": "./dist/index.d.ts", + "types": "./dist/index.d.mts", "exports": { ".": { - "types": "./dist/index.d.ts" + "types": "./dist/index.d.mts" }, "./package.json": "./package.json" }, "scripts": { - "build": "tsc --build", - "dev": "tsc --build --watch", + "build": "tsdown", + "dev": "tsdown --watch", "prepublishOnly": "pnpm build", "typecheck": "tsgo --noEmit" }, diff --git a/packages/spec-types/src/openapi/v2/spec.ts b/packages/spec-types/src/openapi/v2/spec.ts index 31f6bdd40..f709a6e80 100644 --- a/packages/spec-types/src/openapi/v2/spec.ts +++ b/packages/spec-types/src/openapi/v2/spec.ts @@ -65,7 +65,7 @@ export interface Document { /** * **Required**. Specifies the Swagger Specification version being used. It can be used by the Swagger UI and other clients to interpret the API listing. The value MUST be `"2.0"`. */ - swagger: string; + swagger: '2.0'; /** * A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#operation-object Operation Object} must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. */ diff --git a/packages/spec-types/tsconfig.json b/packages/spec-types/tsconfig.json index 78e34cbd5..051662ba8 100644 --- a/packages/spec-types/tsconfig.json +++ b/packages/spec-types/tsconfig.json @@ -6,5 +6,6 @@ "outDir": "dist", "rootDir": "src" }, - "include": ["src"] + "include": ["src"], + "references": [{ "path": "../types" }] } diff --git a/packages/spec-types/tsdown.config.ts b/packages/spec-types/tsdown.config.ts new file mode 100644 index 000000000..a425c6ee4 --- /dev/null +++ b/packages/spec-types/tsdown.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'tsdown'; + +export default defineConfig({ + attw: { + ignoreRules: ['cjs-resolves-to-esm'], + profile: 'esm-only', + }, + publint: true, + sourcemap: true, +}); diff --git a/packages/spec-types/turbo.json b/packages/spec-types/turbo.json new file mode 100644 index 000000000..c75ef5fe1 --- /dev/null +++ b/packages/spec-types/turbo.json @@ -0,0 +1,10 @@ +{ + "$schema": "../../node_modules/turbo/schema.json", + "extends": ["//"], + "tasks": { + "build": { + "dependsOn": [], + "outputs": ["dist/**"] + } + } +} -- 2.51.2