-
-
Notifications
You must be signed in to change notification settings - Fork 203
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
37ec549
to
d84ba4c
Compare
|
d84ba4c
to
fb901bc
Compare
fb901bc
to
438dac9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1947 +/- ##
==========================================
- Coverage 22.52% 22.52% -0.01%
==========================================
Files 324 324
Lines 31857 31858 +1
Branches 1232 1232
==========================================
Hits 7177 7177
- Misses 24671 24672 +1
Partials 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/client-axios
@hey-api/client-fetch
@hey-api/client-next
@hey-api/client-nuxt
@hey-api/nuxt
@hey-api/nx-plugin
@hey-api/openapi-ts
@hey-api/vite-plugin
commit: |
0a60e87
to
d4711ce
Compare
acb3de8
to
c889844
Compare
@@ -0,0 +1,11 @@ | |||
{ |
There was a problem hiding this comment.
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
|
||
function App() { | ||
const onClick = async () => { | ||
postFoo({ | ||
addPet({ |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
@@ -1,7 +1,32 @@ | |||
// This file is auto-generated by @hey-api/openapi-ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran the code gen
@@ -10,6 +10,19 @@ | |||
"scripts": { | |||
"build": "tsup" | |||
}, | |||
"exports": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was facing issues with our new configs, adding the exports and adding cjs fixed the issues,
"default": "./dist/index.cjs" | ||
} | ||
}, | ||
"./setup": "./src/setup.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exporting the setup file as a direct source file for other vitests to use as a setup file.
@@ -0,0 +1,5 @@ | |||
// FAIL LOUDLY on unhandled promise rejections / errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this file because vitest fails if an error is uncaught, but no trace is given to the logs. This change adds the trace. This will help future debugging.
@@ -25,6 +25,7 @@ export function createVitestConfig( | |||
}, | |||
}, | |||
root, | |||
setupFiles: ['@config/vite-base/setup'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding our new vitest setup file with the new export path
@@ -2,7 +2,7 @@ | |||
"$schema": "./node_modules/turbo/schema.json", | |||
"tasks": { | |||
"build": { | |||
"cache": false, | |||
"cache": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabled caching for quicker local dev
df83798
to
c527716
Compare
- fix typo in vitest.config output - change vitest.config to mts for better type support - list vite and vitest as a dep if enabled - change vitest to single fork runner - change build to only output cjs to support nx plugins - add caching and nx linking if spec file is in another project
- Replace direct mkdir calls with makeDir utility for consistent directory creation. - Update plugin handling in client generation to support additional plugins. - Modify tests and schemas to reflect changes in plugin structure and options. - Improve error handling and logging in updateApi executor. - Add formatting functionality for generated files and update README for clarity.
- Replace the existing openapi-diff dependency with api-smart-diff for improved comparison accuracy. - Add comprehensive test cases to validate spec comparison logic across various scenarios.
…verrides in package.json files to support node 18
… management - Introduce `baseTsConfigName` and `baseTsConfigPath` options in the OpenAPI client generator and update executor schemas. - Enhance README documentation to reflect new options and their usage. - Implement `getBaseTsConfigPath` utility to resolve tsconfig paths based on provided options. - Update tests to cover new tsconfig path handling logic.
- Introduce functions to standardize OpenAPI and Swagger specs, including version detection and conversion. - Implement `removeExamples` function to clean up specs before comparison, ensuring accurate diff results. - Add comprehensive tests for new functionality, covering various scenarios for OpenAPI 3.1 and Swagger 2.0 specs. - Update existing comparison logic to utilize standardized specs for improved accuracy.
aab87bc
to
0dedaa8
Compare
0dedaa8
to
52a1e75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
f0259ea
to
f4b65ed
Compare
f4b65ed
to
92f6777
Compare
… object type before accessing 'case' property
… for directory creation
Rebased the PR. |
This NX plugin will generate an NX package from an OpenAPI spec file and run the openapi-ts on the spec.
This is useful for NX projects.
Also very useful to let AI agents know how to use the plugin to automate setting up client code to fit into an NX project.
TODO:
Stretch in this PR:
Questions:
Q: How to handle updates to the OpenAPI spec file?
A: We have added an executor and a call to each generated project. Each project can run the executor to update the spec file and regenerate the client code.
Q: How do we list the plugin in the NX plugin repository
A: https://nx.dev/extending-nx/recipes/publish-plugin#list-your-nx-plugin
Fixes: #1910
Related PRs: