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
124 changes: 80 additions & 44 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 22
cache: 'pnpm'
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- name: Install dependencies
run: pnpm install
run: bun ci
- name: ESLint
run: pnpm lint
run: bun run lint
- name: Cargo fmt
run: cargo fmt -- --check
- name: Clippy
Expand Down Expand Up @@ -83,42 +84,43 @@ jobs:
settings:
- host: macos-latest
target: x86_64-apple-darwin
build: pnpm build --target x86_64-apple-darwin
build: bun run build --target x86_64-apple-darwin
- host: windows-latest
build: pnpm build --target x86_64-pc-windows-msvc
build: bun run build --target x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
build: pnpm build --target x86_64-unknown-linux-gnu --use-napi-cross
build: bun run build --target x86_64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: x86_64-unknown-linux-musl
build: pnpm build --target x86_64-unknown-linux-musl -x
build: bun run build --target x86_64-unknown-linux-musl -x
- host: macos-latest
target: aarch64-apple-darwin
build: pnpm build --target aarch64-apple-darwin
build: bun run build --target aarch64-apple-darwin
- host: ubuntu-latest
target: aarch64-unknown-linux-gnu
build: pnpm build --target aarch64-unknown-linux-gnu --use-napi-cross
build: bun run build --target aarch64-unknown-linux-gnu --use-napi-cross
- host: ubuntu-latest
target: aarch64-unknown-linux-musl
build: pnpm build --target aarch64-unknown-linux-musl -x
build: bun run build --target aarch64-unknown-linux-musl -x
- host: windows-latest
target: aarch64-pc-windows-msvc
build: pnpm build --target aarch64-pc-windows-msvc
build: bun run build --target aarch64-pc-windows-msvc
- host: ubuntu-latest
target: wasm32-wasip1-threads
build: pnpm build --target wasm32-wasip1-threads
build: bun run build --target wasm32-wasip1-threads
name: stable - ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v7
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
- name: Install
uses: dtolnay/rust-toolchain@stable
with:
Expand Down Expand Up @@ -151,7 +153,7 @@ jobs:
if: ${{ matrix.settings.setup }}
shell: bash
- name: Install dependencies
run: pnpm install
run: bun ci
- name: Build
run: ${{ matrix.settings.build }}
shell: bash
Expand Down Expand Up @@ -193,16 +195,19 @@ jobs:
runs-on: ${{ matrix.settings.host }}
steps:
- uses: actions/checkout@v7
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
cache: pnpm
architecture: ${{ matrix.settings.architecture }}
# macos-latest is arm64; match the optional platform packages to the
# x64 Node that setup-node installs above.
- name: Install dependencies
run: pnpm install
run: bun ci --cpu=${{ matrix.settings.architecture }}
- name: Download artifacts
uses: actions/download-artifact@v8
with:
Expand All @@ -212,7 +217,7 @@ jobs:
run: ls -R .
shell: bash
- name: Test bindings
run: pnpm test
run: bun run test
test-linux-binding:
name: Test ${{ matrix.target }} - node@${{ matrix.node }}
needs:
Expand All @@ -232,13 +237,10 @@ jobs:
runs-on: ${{ contains(matrix.target, 'aarch64') && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v7
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Output docker params
id: docker
run: |
Expand All @@ -258,10 +260,6 @@ jobs:
console.log('IMAGE=node:${{ matrix.node }}-slim')
}
" >> $GITHUB_OUTPUT
echo "PNPM_STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
# use --force to download the all platform/arch dependencies
- name: Install dependencies
run: pnpm install --force
- name: Download artifacts
uses: actions/download-artifact@v8
with:
Expand All @@ -282,8 +280,10 @@ jobs:
with:
image: ${{ steps.docker.outputs.IMAGE }}
name: test-binding
options: -v ${{ steps.docker.outputs.PNPM_STORE_PATH }}:${{ steps.docker.outputs.PNPM_STORE_PATH }} -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
args: npm run test
options: -v ${{ github.workspace }}:${{ github.workspace }} -w ${{ github.workspace }} --platform ${{ steps.docker.outputs.PLATFORM }}
# node images ship without bun; installing inside the container gives
# musl images their own platform binaries (oxc-node, oxlint).
args: sh -c "npx -y bun@1.4.2 ci && npm run test"
test-wasm-binding:
name: Test wasm32-wasi binding - node@${{ matrix.node }}
needs:
Expand All @@ -297,15 +297,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
cache: pnpm
- name: Install dependencies
run: pnpm install
run: bun ci
- name: Download artifacts
uses: actions/download-artifact@v8
with:
Expand All @@ -320,7 +321,7 @@ jobs:
run: ls -R .
shell: bash
- name: Test bindings (WASI forced)
run: pnpm test
run: bun run test
env:
# The generated loader only honours the literal strings 'true' and
# 'error'; 'error' would also force @oxc-node/core (ava's TS loader)
Expand All @@ -329,10 +330,43 @@ jobs:
# Node prints "ExperimentalWarning: WASI" on stderr, which CLI tests compare.
NODE_OPTIONS: --no-warnings
- name: Test bindings (native, WASI cross-check)
run: pnpm test
run: bun run test
env:
OPENAPI_NG_EXPECT_WASI_BINDING: '1'
NODE_OPTIONS: --no-warnings
smoke-bun-runtime:
name: CLI under bun runtime
needs:
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Install dependencies
run: bun ci
- name: Download native artifacts
uses: actions/download-artifact@v8
with:
name: bindings-x86_64-unknown-linux-gnu
path: .
- name: Download wasm artifacts
uses: actions/download-artifact@v8
with:
name: bindings-wasm32-wasip1-threads
path: .
- name: Generate (native)
run: |
bun bin/openapi-ng.js generate --input test/fixtures/petstore-rich.openapi.yaml --output out-native
test -f out-native/model.generated.ts
- name: Generate (WASI forced)
run: |
bun bin/openapi-ng.js generate --input test/fixtures/petstore-rich.openapi.yaml --output out-wasi
diff -r out-native out-wasi
env:
NAPI_RS_FORCE_WASI: 'true'
publish:
name: Publish
runs-on: ubuntu-latest
Expand All @@ -342,28 +376,30 @@ jobs:
- test-macOS-windows-binding
- test-linux-binding
- test-wasm-binding
- smoke-bun-runtime
steps:
- uses: actions/checkout@v7
with:
# release notes need every tag and the commits between them
fetch-depth: 0
- name: setup pnpm
uses: pnpm/action-setup@v6
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup node
uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install
run: bun ci
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
- name: create npm dirs
run: pnpm napi create-npm-dirs
run: bunx napi create-npm-dirs
- name: Move artifacts
run: pnpm artifacts
run: bun run artifacts
# With a WASI target, `napi artifacts` treats native.js and browser.js as
# managed root entries: it rewrites browser.js as an ESM stub and deletes
# native.js. The committed files are the real entries.
Expand Down
27 changes: 13 additions & 14 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
paths:
- 'website/**'
- '.github/workflows/docs.yml'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'bun.lock'
- 'bunfig.toml'
- 'stackblitz/petstore.openapi.yaml'
pull_request:
paths:
- 'website/**'
- '.github/workflows/docs.yml'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'bun.lock'
- 'bunfig.toml'
- 'stackblitz/petstore.openapi.yaml'

concurrency:
Expand All @@ -32,29 +32,28 @@ jobs:
pull-requests: write
steps:
- uses: actions/checkout@v7
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup bun
uses: oven-sh/setup-bun@v2
with:
bun-version-file: package.json
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Install dependencies
working-directory: website
run: pnpm install --frozen-lockfile
run: bun ci
- name: Build site
working-directory: website
run: pnpm build
run: bun run build
- name: Type-check
working-directory: website
run: pnpm check
run: bun run check
- name: Install Playwright browser
working-directory: website
run: pnpm exec playwright install --with-deps chromium
run: bunx playwright install --with-deps chromium
- name: Test
working-directory: website
run: pnpm test
run: bun run test
- name: Deploy to production
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: cloudflare/wrangler-action@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ tmp/

*.bak

# napi-rs per-platform package staging; CI recreates it at publish time.
npm/

website/public/playground-engine/
website/test-results/
website/playwright-report/
Expand Down
2 changes: 1 addition & 1 deletion .oxfmtrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"/*.cjs",
"/index.js",
"index.d.ts",
"pnpm-lock.yaml",
"bun.lock",
"/test/fixtures/malformed.yaml",
"__test__/snapshots/generate-native"
]
Expand Down
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ Wire a generated service into a component:
import { Component, inject } from '@angular/core';
import { PetRest } from './generated/rest/pet.rest.generated';

@Component({
/* ... */
})
@Component({/* ... */})
export class PetList {
readonly #pets = inject(PetRest);

Expand All @@ -64,7 +62,7 @@ A `validateRest(path, restMethod, opts)` helper wraps Angular signal-forms `vali
import { validateRest } from './generated/rest.validate';

validateRest(emailPath, accountRest.checkEmail, {
request: (ctx) => ({ email: ctx.value() }),
request: ctx => ({ email: ctx.value() }),
onError: () => ({ kind: 'email-taken' }),
});
```
Expand All @@ -76,16 +74,16 @@ Full walkthrough on [docs.openapi-ng.dev/getting-started](https://docs.openapi-n
## Development

```bash
pnpm install
pnpm build # release build (Rust + NAPI)
pnpm build:debug # debug build (faster compile)
pnpm test # Node integration tests (AVA)
cargo test # Rust unit tests
pnpm lint # oxlint
pnpm format # oxfmt + rustfmt + taplo
bun install
bun run build # release build (Rust + NAPI)
bun run build:debug # debug build (faster compile)
bun run test # Node integration tests (AVA)
cargo test # Rust unit tests
bun run lint # oxlint
bun run format # oxfmt + rustfmt + taplo
```

Rust changes require a rebuild (`pnpm build` or `pnpm build:debug`) before tests reflect them.
Rust changes require a rebuild (`bun run build` or `bun run build:debug`) before tests reflect them.

Bug reports and PRs welcome at [github.com/AVSystem/openapi-ng](https://github.com/AVSystem/openapi-ng).

Expand Down
Loading
Loading