Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .claude/CLAUDE.md
Empty file.
15 changes: 0 additions & 15 deletions .claude/settings.json

This file was deleted.

9 changes: 0 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@ updates:
default-days: 1
versioning-strategy: increase
groups:
uncheck:
patterns:
- uncheck
- oxlint
- oxfmt
dev-dependencies-minor-patch:
dependency-type: development
exclude-patterns:
- uncheck
- oxlint
- oxfmt
update-types:
- minor
- patch
11 changes: 11 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ jobs:
if: matrix.node-version == 24
with:
token: ${{ secrets.CODECOV_TOKEN }}

publish_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- uses: pnpm/action-setup@v6

- run: pnpm i

- run: pnpm exec pkg-pr-new publish './packages/*' --pnpm --compact
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
!.github/
!.vitepress/
!.claude/
.claude/worktrees/
!.agents/
!.zed/

Expand Down
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["oxc.oxc-vscode"]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "explicit"
}
}
22 changes: 1 addition & 21 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
{
"format_on_save": "on",
"formatter": {
"external": {
"command": "./node_modules/.bin/oxfmt",
"arguments": ["--stdin-filepath", "{buffer_path}"]
}
},
// Apply oxlint's auto fixes on save:
"code_actions_on_format": {
"source.fixAll.oxc": true
},
"lsp": {
"typescript-language-server": {
"settings": {
"typescript": {
"preferences": {
"includePackageJsonAutoImports": "on"
}
}
}
}
}
"formatter": [{ "code_action": "source.fixAll.oxc" }, { "language_server": { "name": "oxfmt" } }]
}
28 changes: 28 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# AGENTS.md

## Repository

OpenAPI Spec: OpenAPI types and tools, in a pnpm monorepo.

- `packages/*`: the published packages, each with `src`, and `tests` and `benches` where it has them
- `scripts/`: repository scripts

## Commands

```bash
pnpm install
pnpm test # vitest
pnpm vitest run <path> # one test file
pnpm check # lint and type check, including *.test-d.ts
pnpm fix # check, applying fixes
pnpm format # format with oxfmt
pnpm repo:fix # fix monorepo issues (sherif)
pnpm bench
pnpm --filter @openapi-spec/downgrader prepack # build one package; tests don't need a build
```

Before finishing, run `pnpm format`, `pnpm check` and `pnpm test`. CI doesn't check formatting.

## Pull requests

Titles follow Conventional Commits, scoped by the affected packages, separated by a comma and a space: `fix(downgrader): ...`, `fix(downgrader, router): ...`. Leave out the scope when the change is too broad.
7 changes: 5 additions & 2 deletions oxfmt.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { defineConfig } from 'oxfmt'
import { middleapi } from 'uncheck/oxfmt'

export default defineConfig({
...middleapi,
ignorePatterns: ['.agents/skills/**', '.claude/skills/**'],
semi: false,
singleQuote: true,
quoteProps: 'consistent',
sortImports: true,
})
30 changes: 27 additions & 3 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
import { defineConfig } from 'oxlint'
import { middleapi } from 'uncheck/oxlint'

export default defineConfig({
extends: [middleapi],
ignorePatterns: ['.agents/skills/**', '.claude/skills/**'],
options: {
typeAware: true,
typeCheck: true,
},
categories: {
correctness: 'error',
suspicious: 'error',
},
plugins: ['eslint', 'typescript', 'unicorn', 'oxc', 'import'],
rules: {
Comment thread
dinwwwh marked this conversation as resolved.
Resolved
'typescript/no-unsafe-type-assertion': 'off',
'no-underscore-dangle': 'off',
'unicorn/no-thenable': 'off',

'eqeqeq': 'error',
'guard-for-in': 'error',
'no-prototype-builtins': 'error',
'no-throw-literal': 'error',
'prefer-promise-reject-errors': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-var': 'error',
'prefer-const': 'error',
'typescript/no-import-type-side-effects': 'error',
'unicorn/prefer-node-protocol': 'error',
},
overrides: [
{
files: ['**/*.test.ts', '**/*.test-d.ts'],
files: ['**/*.test.ts', '**/*.test-d.ts', '**/benches/**'],
rules: {
'no-unused-vars': 'off',
'no-shadow': 'off',
'unicorn/consistent-function-scoping': 'off',
'typescript/no-generated-empty-object-type': 'off',
},
},
],
Expand Down
25 changes: 10 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
"license": "MIT",
"type": "module",
"scripts": {
"prepare": "uncheck prepare --pre-commit",
"check": "uncheck",
"fix": "uncheck --fix",
"check": "oxlint",
"fix": "oxlint --fix",
"format": "oxfmt",
"repo:fix": "sherif --fix",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"bench": "vitest bench --run",
"sync:sponsors": "node scripts/sync-sponsors.ts && pnpm run fix '**/README.md'"
"sync:sponsors": "node scripts/sync-sponsors.ts && oxfmt '**/README.md'"
},
"devDependencies": {
"@codspeed/vitest-plugin": "^5.7.1",
Expand All @@ -21,19 +22,13 @@
"@vitest/coverage-v8": "^4.1.11",
"bumpp": "^12.3.0",
"changelogithub": "^15.0.5",
"oxfmt": "^0.74.0",
"oxlint": "^1.89.0",
"oxfmt": "^0.76.0",
"oxlint": "^1.91.0",
"oxlint-tsgolint": "^7.0.2005",
"pkg-pr-new": "^0.0.91",
"sherif": "^1.13.0",
"typescript": "^7.0.2",
"unbuild": "^3.6.1",
"uncheck": "^0.1.1",
"vitest": "^4.1.11"
},
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": "^12.4.1",
"onFail": "download"
}
}
"packageManager": "pnpm@12.16.1"
}
6 changes: 3 additions & 3 deletions packages/downgrader/benches/chained.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { downgradeSpecV31ToV30, downgradeSpecV32ToV31 } from '@openapi-spec/down
import type * as OpenAPIV3_2 from '@openapi-spec/types/v3.2'
import { bench, describe } from 'vitest'

import { corpusV32 } from '../tests/corpus'
import { doc as orpcDocument } from '../tests/orpc-document'
import { createApiV32 } from './__shared__/api'
import { corpusV32 } from '../tests/corpus.ts'
import { doc as orpcDocument } from '../tests/orpc-document.ts'
import { createApiV32 } from './__shared__/api.ts'

const API_100_RESOURCES = createApiV32(100)

Expand Down
8 changes: 4 additions & 4 deletions packages/downgrader/benches/v3.1-to-v3.0.bench.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { downgradeSchemaV31ToV30, downgradeSpecV31ToV30 } from '@openapi-spec/downgrader'
import { bench, describe } from 'vitest'

import { corpusV31 } from '../tests/corpus'
import { createApiV31 } from './__shared__/api'
import { corpusV31 } from '../tests/corpus.ts'
import { createApiV31 } from './__shared__/api.ts'
import {
callbackGraphV31,
pathItemChainV31,
referenceDiamondV31,
schemaDiamond,
} from './__shared__/graphs'
import { constOutsideEnum, ORDER_SCHEMA, PROPERTY_SCHEMA } from './__shared__/schemas'
} from './__shared__/graphs.ts'
import { constOutsideEnum, ORDER_SCHEMA, PROPERTY_SCHEMA } from './__shared__/schemas.ts'

const API_10_RESOURCES = createApiV31(10)
const API_100_RESOURCES = createApiV31(100)
Expand Down
8 changes: 4 additions & 4 deletions packages/downgrader/benches/v3.2-to-v3.1.bench.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { downgradeSchemaV32ToV31, downgradeSpecV32ToV31 } from '@openapi-spec/downgrader'
import { bench, describe } from 'vitest'

import { corpusV32 } from '../tests/corpus'
import { createApiV32 } from './__shared__/api'
import { callbackGraphV32, referenceDiamondV32, schemaDiamond } from './__shared__/graphs'
import { ORDER_SCHEMA, PROPERTY_SCHEMA } from './__shared__/schemas'
import { corpusV32 } from '../tests/corpus.ts'
import { createApiV32 } from './__shared__/api.ts'
import { callbackGraphV32, referenceDiamondV32, schemaDiamond } from './__shared__/graphs.ts'
import { ORDER_SCHEMA, PROPERTY_SCHEMA } from './__shared__/schemas.ts'

const API_10_RESOURCES = createApiV32(10)
const API_100_RESOURCES = createApiV32(100)
Expand Down
23 changes: 10 additions & 13 deletions packages/downgrader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,26 @@
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs",
"default": "./dist/index.mjs"
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
},
"./v3.2-to-v3.1": {
"types": "./dist/v3.2-to-v3.1.d.mts",
"import": "./dist/v3.2-to-v3.1.mjs",
"default": "./dist/v3.2-to-v3.1.mjs"
"types": "./dist/v3.2-to-v3.1.d.ts",
"import": "./dist/v3.2-to-v3.1.js",
"default": "./dist/v3.2-to-v3.1.js"
},
"./v3.1-to-v3.0": {
"types": "./dist/v3.1-to-v3.0.d.mts",
"import": "./dist/v3.1-to-v3.0.mjs",
"default": "./dist/v3.1-to-v3.0.mjs"
"types": "./dist/v3.1-to-v3.0.d.ts",
"import": "./dist/v3.1-to-v3.0.js",
"default": "./dist/v3.1-to-v3.0.js"
}
}
},
"scripts": {
"prepack": "unbuild"
"prepack": "tsc"
},
"dependencies": {
"@openapi-spec/types": "workspace:^"
},
"unbuild": {
"declaration": "node16"
}
}
4 changes: 2 additions & 2 deletions packages/downgrader/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { downgradeSchemaV31ToV30, downgradeSpecV31ToV30 } from './v3.1-to-v3.0'
export { downgradeSchemaV32ToV31, downgradeSpecV32ToV31 } from './v3.2-to-v3.1'
export { downgradeSchemaV31ToV30, downgradeSpecV31ToV30 } from './v3.1-to-v3.0.ts'
export { downgradeSchemaV32ToV31, downgradeSpecV32ToV31 } from './v3.2-to-v3.1.ts'
12 changes: 6 additions & 6 deletions packages/downgrader/src/v3.1-to-v3.0.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as OpenAPIV3_0 from '@openapi-spec/types/v3.0'
import type * as OpenAPIV3_1 from '@openapi-spec/types/v3.1'

import type { Context, Convert } from './shared'
import type { Context, Convert } from './shared.ts'
import {
clone,
convertObject,
Expand All @@ -20,7 +20,7 @@ import {
map,
resolve,
resolvePointer,
} from './shared'
} from './shared.ts'

// Keywords 3.0 lacks that restrict values, so removing one loosens a schema.
const RESTRICTING_KEYWORDS = new Set([
Expand Down Expand Up @@ -726,7 +726,7 @@ function tagsOf(schema: Record<string, unknown>, ctx: Context): Tags {
? property.enum
: [property.const]
: undefined
if (Array.isArray(held) && held.every((value) => typeof value !== 'object' || value === null)) {
if (Array.isArray(held) && held.every((item) => typeof item !== 'object' || item === null)) {
values.set(name, { values: held, required: required.includes(name) })
}
}
Expand Down Expand Up @@ -1029,12 +1029,12 @@ function keptRejectsNull(schema: unknown, ctx: Context): boolean {
// A schema with no `type` that rejects null all the same: an `enum` or
// `const` without null, as msgspec writes an `Enum`, an `allOf` with a member
// that rejects null, as OData writes a derived object, or a union whose
// branches each do, as Zod writes a registered union. Unless `inline`, a
// branches each do, as Zod writes a registered union. Unless `isInline`, a
// `oneOf` with an object branch, as Zod writes a discriminated union, and
// GitHub and Notion a tagged one, does not count, since NSwag writes a type it
// never defines for a nullable `$ref` to one, where the `anyOf` pair gives an
// empty class, though it reads an inline one as its first branch.
function untypedRejectsNull(schema: unknown, ctx: Context, inline = false): boolean {
function untypedRejectsNull(schema: unknown, ctx: Context, isInline = false): boolean {
if (!isRecord(schema) || schema.type !== undefined) {
return false
}
Expand All @@ -1049,7 +1049,7 @@ function untypedRejectsNull(schema: unknown, ctx: Context, inline = false): bool
(Array.isArray(branches) &&
branches.length > 0 &&
branches.every((branch) => refRejectsNull(branch, ctx)) &&
(inline ||
(isInline ||
!(branches === schema.oneOf && branches.some((branch) => isObjectBranch(branch, ctx)))))
)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/downgrader/src/v3.2-to-v3.1.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as OpenAPIV3_1 from '@openapi-spec/types/v3.1'
import type * as OpenAPIV3_2 from '@openapi-spec/types/v3.2'

import type { Context, Convert } from './shared'
import type { Context, Convert } from './shared.ts'
import {
clone,
convertObject,
Expand All @@ -20,7 +20,7 @@ import {
map,
resolve,
resolvePointer,
} from './shared'
} from './shared.ts'

const V32_DIALECT_PREFIX = 'https://spec.openapis.org/oas/3.2/dialect/'
const V31_DIALECT = 'https://spec.openapis.org/oas/3.1/dialect/base'
Expand Down
6 changes: 3 additions & 3 deletions packages/downgrader/tests/corpus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import { downgradeSpecV31ToV30, downgradeSpecV32ToV31 } from '@openapi-spec/downgrader'
import type * as OpenAPIV3_2 from '@openapi-spec/types/v3.2'

import { doc as mega } from '../../types/tests/schema-tests-3.2/mega'
import { corpusV31, corpusV32 } from './corpus'
import { expectValidDowngrade } from './validate'
import { doc as mega } from '../../types/tests/schema-tests-3.2/mega.ts'
import { corpusV31, corpusV32 } from './corpus.ts'
import { expectValidDowngrade } from './validate.ts'

function downgradeTwice(doc: OpenAPIV3_2.OpenAPIObject) {
return downgradeSpecV31ToV30(downgradeSpecV32ToV31(doc))
Expand Down
Loading
Loading