Skip to content

feat(nx-plugin): add NX Plugin with OpenAPI client generator and executor #1947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
77f3f02
feat(nx-plugin): add nx plugin to generate and update client code
seriouslag Apr 14, 2025
424b825
feat(config): add exports field and support for CommonJS format in Vi…
seriouslag Apr 14, 2025
c8f11e7
fix(turbo.json): enable caching for build task
seriouslag Apr 14, 2025
24ccc93
fix(nx-plugin): update build output
seriouslag Apr 14, 2025
6eb396d
refactor(nx-plugin): update schema prompts and descriptions for clari…
seriouslag Apr 14, 2025
cb7c7bc
chore(nx-plugin): remove ts-node dependency and update JSON file copy…
seriouslag Apr 14, 2025
13df17e
feat(vitest): add setup files configuration to Vitest base config
seriouslag Apr 14, 2025
20296bb
feat(turbo.json): add inputs configuration for improved build process
seriouslag Apr 14, 2025
722b752
feat(client): update example to use actual code from the spec to avoi…
seriouslag Apr 14, 2025
90730a9
feat(config): update setup file reference in Vitest base config to us…
seriouslag Apr 14, 2025
abca7a5
feat(turbo.json): add build task configuration for Nuxt project
seriouslag Apr 14, 2025
774c960
fix(nx-plugin): fix plugin build output and enhance caching
seriouslag Apr 17, 2025
0d82a48
refactor(nx-plugin): enhance plugin handling and directory management
seriouslag Apr 25, 2025
85d2df5
feat(nx-plugin): enhance OpenAPI spec comparison functionality
seriouslag Apr 27, 2025
8fecfa9
chore(dependencies): downgrade find-my-way to version 9.2.0 and add o…
seriouslag Apr 27, 2025
1f2325f
feat(nx-plugin): add base tsconfig options for improved configuration…
seriouslag Apr 28, 2025
9621692
feat(nx-plugin): enhance OpenAPI and Swagger spec comparison utilities
seriouslag Apr 29, 2025
a5c075e
feat(nx-plugin): update to support NX 21 continuous pipelines
seriouslag May 14, 2025
895a0b3
major: add node 24 in CI, remove node 18 as a supported target
seriouslag May 14, 2025
aab87bc
refactor(nx-plugin): improve file formatting utilities
seriouslag May 15, 2025
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
node-version: ['18.20.5', '20.11.1', '22.11.0']
node-version: ['20.19.0', '22.12.0']
steps:
- uses: actions/[email protected]
with:
Expand All @@ -38,7 +38,7 @@ jobs:
run: pnpm build --filter="@hey-api/**"

- name: Build examples
if: matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
if: matrix.node-version == '24.0.1' && matrix.os == 'ubuntu-latest'
run: pnpm build --filter="@examples/**"

- name: Run linter
Expand All @@ -54,7 +54,7 @@ jobs:
run: pnpm test:e2e

- name: Publish preview packages
if: github.event_name == 'pull_request' && matrix.node-version == '22.11.0' && matrix.os == 'ubuntu-latest'
if: github.event_name == 'pull_request' && matrix.node-version == '24.0.1' && matrix.os == 'ubuntu-latest'
run: ./scripts/publish-preview-packages.sh
env:
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
22.11.0
22.12.0
3 changes: 3 additions & 0 deletions examples/openapi-ts-fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@
"typescript": "5.8.3",
"vite": "6.2.6",
"vitest": "3.1.1"
},
"overrides": {
"find-my-way": "9.2.0"
}
}
11 changes: 11 additions & 0 deletions examples/openapi-ts-nuxt/turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this file to cache builds

"$schema": "../../node_modules/turbo/schema.json",
"extends": ["//"],
"tasks": {
"build": {
"cache": true,
"dependsOn": ["^build"],
"outputs": [".nuxt/**"]
}
}
}
8 changes: 4 additions & 4 deletions examples/openapi-ts-sample/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
Section,
} from '@radix-ui/themes';

// @ts-expect-error
import { postFoo } from './client/sdk.gen';
import { addPet } from './client/sdk.gen';

function App() {
const onClick = async () => {
postFoo({
addPet({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this file to use actual generated code, I was getting type errors how it was

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sample is meant to be a playground for local development and testing. I thought I ignored it in ESLint?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe was an issue with my IDE, why not use actual code instead of adding broken imports and ignoring it with comments?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember, I was probably testing something and didn't clean it up. It's similar to the sample snapshot script except it contains a whole app with UI. The idea is to be able to test drive the output since snapshots are never actually executed. Obviously should be way more polished!

body: {
foo: [[1, 2]],
name: 'test',
photoUrls: ['test'],
},
});
};
Expand Down
29 changes: 27 additions & 2 deletions examples/openapi-ts-sample/src/client/client.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
// This file is auto-generated by @hey-api/openapi-ts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran the code gen


import { createClient, createConfig } from '@hey-api/client-fetch';
import {
type ClientOptions as DefaultClientOptions,
type Config,
createClient,
createConfig,
} from '@hey-api/client-fetch';

import { createClientConfig } from '../hey-api';
import type { ClientOptions } from './types.gen';

export const client = createClient(createClientConfig(createConfig()));
/**
* The `createClientConfig()` function will be called on client initialization
* and the returned object will become the client's initial configuration.
*
* You may want to initialize your client this way instead of calling
* `setConfig()`. This is useful for example if you're using Next.js
* to ensure your client always has the correct values.
*/
export type CreateClientConfig<T extends DefaultClientOptions = ClientOptions> =
(
override?: Config<DefaultClientOptions & T>,
) => Config<Required<DefaultClientOptions> & T>;

export const client = createClient(
createClientConfig(
createConfig<ClientOptions>({
baseUrl: 'https://petstore3.swagger.io/api/v3',
}),
),
);
60 changes: 2 additions & 58 deletions examples/openapi-ts-sample/src/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,59 +38,6 @@ export const OrderSchema = {
},
} as const;

export const CustomerSchema = {
properties: {
address: {
items: {
$ref: '#/components/schemas/Address',
},
type: 'array',
xml: {
name: 'addresses',
wrapped: true,
},
},
id: {
example: 100000,
format: 'int64',
type: 'integer',
},
username: {
example: 'fehguy',
type: 'string',
},
},
type: 'object',
xml: {
name: 'customer',
},
} as const;

export const AddressSchema = {
properties: {
city: {
example: 'Palo Alto',
type: 'string',
},
state: {
example: 'CA',
type: 'string',
},
street: {
example: '437 Lytton',
type: 'string',
},
zip: {
example: 94301,
type: 'string',
},
},
type: 'object',
xml: {
name: 'address',
},
} as const;

export const CategorySchema = {
properties: {
id: {
Expand Down Expand Up @@ -130,11 +77,11 @@ export const UserSchema = {
type: 'string',
},
password: {
example: 12345,
example: '12345',
type: 'string',
},
phone: {
example: 12345,
example: '12345',
type: 'string',
},
userStatus: {
Expand Down Expand Up @@ -206,9 +153,6 @@ export const PetSchema = {
tags: {
items: {
$ref: '#/components/schemas/Tag',
xml: {
name: 'tag',
},
},
type: 'array',
xml: {
Expand Down
Loading