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
2 changes: 1 addition & 1 deletion .github/actions/setup-node-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
using: composite
steps:
- name: Install pnpm
uses: pnpm/action-setup@903f9c1a6ebcba6cf41d87230be49611ac97822e # v6.0.3
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8

- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: &node-versions [22.x, 24.x]
node-version: &node-versions [22.x, 24.x, 26.x]

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand All @@ -25,7 +25,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: pnpm run build

Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
run: |
tar -xf ${{runner.temp}}/workspace.tar -C .

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: pnpm run build:docs

Expand All @@ -109,7 +109,7 @@ jobs:
run: |
tar -xf ${{runner.temp}}/workspace.tar -C .

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: pnpm run ci-test

Expand Down Expand Up @@ -141,7 +141,7 @@ jobs:
run: |
tar -xf ${{runner.temp}}/workspace.tar -C .

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: pnpm integration:clean
- run: pnpm integration:generate --schema-builder ${{ matrix.schema-builder }}
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
run: |
tar -xf ${{runner.temp}}/workspace.tar -C .

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: SCHEMA_BUILDER=zod-v3 pnpm e2e:generate
- run: pnpm e2e:validate
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ jobs:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@903f9c1a6ebcba6cf41d87230be49611ac97822e # v6.0.3
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8

- name: Use Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version-file: '.nvmrc'
node-version: 26.2.0
cache: "pnpm"

- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
id: nextjs-cache
Expand All @@ -31,7 +32,7 @@ jobs:
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: pnpm run build
- run: pnpm run build:docs
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@903f9c1a6ebcba6cf41d87230be49611ac97822e # v6.0.3
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8

- name: Use Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
registry-url: "https://registry.npmjs.org"
node-version-file: '.nvmrc'
node-version: 26.2.0
cache: "pnpm"

- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
Expand All @@ -41,7 +41,7 @@ jobs:

node scripts/validate-package-version.mjs "${TAG_VERSION}"

- run: pnpm install --frozen-lockfile
- run: pnpm ci

- run: pnpm run build

Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

71 changes: 36 additions & 35 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ PR with a detailed description is fine too.

## Setup

1. Install a node version manager that respects `.nvmrc` files, such as
[fnm](https://github.com/Schniz/fnm)
2. Enable [corepack](https://nodejs.org/api/corepack.html) using `corepack
enable`
3. Install `devDependencies` using `pnpm`
1. Install [mise](https://mise.jdx.dev/)
2. Run `mise trust && mise i` (Ensures Node.js >= 22.x is used)
3. Install dependencies using `pnpm install`

## Workflow

Expand All @@ -37,21 +35,9 @@ See [package.json](./package.json) for available scripts.
Main ones of interest are `build`, `test`, `lint`. E.g:

```shell
pnpm build
pnpm test
pnpm lint
```

To regenerate the integration tests:

```shell
pnpm integration:generate
```

And to build them / check the code output is valid:

```shell
pnpm integration:validate
pnpm run build
pnpm run test
pnpm run lint
```

There's also a `ci-pipeline` script that can be used as a pre-push check, e.g:
Expand Down Expand Up @@ -85,34 +71,49 @@ The config can be seen here [./biome.json](./biome.json)
## Testing

```shell
pnpm test
pnpm integration:generate && pnpm integration:validate
pnpm run test # unit tests
pnpm run integration:generate && pnpm run integration:validate # integration test
pnpm run e2e:generate && pnpm run e2e:validate # e2e tests
```

We have two types of testing in play:
We have three types of testing in play:

* Unit tests using `jest`
* Unit tests
* Integration tests
* E2E tests

### Unit Testing

All new code should include unit tests. These are the most useful in terms of catching regressions,
and run the fastest.

Use `pnpm run test`

The unit testing is currently a bit on the "light" side - the project started
as a fun experiment on a weekend and there is still some back filling to do.
New code, and particularly bug fixes should include unit tests.
### Integration Tests

There is also a heavy reliance on integration tests, where we use the openapi
specifications for large API surfaces to run the code generation and check that
the result builds, currently this includes:
We use publically available, large API surfaces to run our integration tests. Currently, this includes:

* Github API
* Stripe API
* Okta API (partial)
* Petstore API (from Swagger)
* Okta API (Identity and OAuth)
* Petstore API
* Azure Core Service and Resource Manager (TypeSpec)
* A Todo List API (written for this repo, showcases definitions split across
multiple files)

At this stage we don't actually execute the code generated for these API's, but
this would be a nice improvement for the future. The Github client in
particular gets a fair amount of use for automating tasks against my
workplace's Github organisation.
the build check ensures that the generated code is syntactically correct and
type-safe.

Use `pnpm run integration:generate && pnpm run integration:validate`

### E2E Tests

E2E tests involve generating code for a specific specification and running
actual functional tests against it to ensure the runtime behavior is correct.

Use `pnpm run e2e:generate` to generate the test code and `pnpm run e2e:validate` to run
the tests.

## Publishing

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The repository is structured as a mono repo of several npm packages that work to

* [openapi-code-generator](./packages/openapi-code-generator)
* [typescript-axios-runtime](./packages/typescript-axios-runtime)
* [typescript-common-runtime](./packages/typescript-common-runtime)
* [typescript-express-runtime](./packages/typescript-express-runtime)
* [typescript-fetch-runtime](./packages/typescript-fetch-runtime)
* [typescript-koa-runtime](./packages/typescript-koa-runtime)
Expand Down
3 changes: 3 additions & 0 deletions biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"complexity": {
"noForEach": "error"
},
"correctness": {
"noUnusedImports": "error"
},
"suspicious": {
"noImportCycles": "error"
},
Expand Down
4 changes: 4 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tools]
node = '26.2.0'
pnpm = '11.5.0'

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"refresh": "./scripts/refresh-data.sh",
"lint": "biome check --fix .",
"build": "node ./scripts/generate-ajv-validator.js && pnpm -r --workspace-concurrency=4 run bundle && tsc -b tsconfig.json",
"build:docs": "pnpm --filter @nahkies/openapi-code-generator-documentation build",
"build:docs": "pnpm --filter @nahkies/openapi-code-generator-documentation run build",
"build:watch": "tsc -b tsconfig.json -w",
"test": "jest",
"integration:clean": "pnpm --filter @integration/* clean",
"integration:clean": "pnpm --filter @integration/* run clean",
"integration:generate": "node ./scripts/generate.mjs",
"integration:validate": "pnpm -r --workspace-concurrency=2 validate",
"e2e:generate": "pnpm --filter e2e clean && pnpm --filter e2e generate",
"e2e:validate": "pnpm --filter e2e build && pnpm --filter e2e test",
"integration:validate": "pnpm -r --filter @integration/* --workspace-concurrency=2 run validate",
"e2e:generate": "pnpm --filter e2e run clean && pnpm --filter e2e run generate",
"e2e:validate": "pnpm --filter e2e run build && pnpm --filter e2e run test",
"ci-test": "jest --coverage",
"ci-lint": "biome ci .",
"ci-pipeline": "./scripts/ci-pipeline.sh",
Expand Down Expand Up @@ -82,5 +82,5 @@
"engines": {
"node": ">=22"
},
"packageManager": "pnpm@10.34.1+sha512.b58fbde6dca66a929538021581f648b4570b6ca19b18e7cbd7f2c07a7b24454155388dacdf08f2af3678e88a6d1fe04f9d609df24bf51735a060ea041b374ab7"
"packageManager": "pnpm@11.5.0+sha512.dbfcc4f81cf48597afd4bc391ffdf12c11f1a9fb83a395bfa6b0a2d9cc2fd8ffebafdb1ccbd529632153f793904c2615b7f09fe1a345473fd1c35845172a8eb1"
}
12 changes: 8 additions & 4 deletions packages/documentation/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {getPageMap} from "nextra/page-map"
import {Footer, Layout, Link, Navbar} from "nextra-theme-docs"
import "nextra-theme-docs/style.css"
import type {Metadata} from "next"
import Script from "next/script"
import type {ReactNode} from "react"

export const metadata: Metadata = {
Expand Down Expand Up @@ -78,11 +79,14 @@ export default async function RootLayout({children}: {children: ReactNode}) {
<meta name="robots" content="index,follow" />
<link rel="canonical" href={baseUrl} />

<script
defer={true}
data-domain="openapi-code-generator.nahkies.co.nz"
src="https://plausible.nahkies.co.nz/js/script.js"
<Script
async
src="https://plausible.nahkies.co.nz/js/pa-0fbOteYkFF3Wja9FWEfQB.js"
/>
<Script id="plausible-init">
{`window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
plausible.init()`}
</Script>
</Head>
<body>
<Layout
Expand Down
5 changes: 5 additions & 0 deletions packages/documentation/src/app/not-found.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
title: Page not found
description: This page doesn't exist
---

# Page not found

Sorry this page doesn't exist 😞
Expand Down
Loading