Skip to content
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

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

Open
wants to merge 42 commits into
base: main
Choose a base branch
from

Conversation

seriouslag
Copy link

@seriouslag seriouslag commented Apr 2, 2025

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:

  • Add NX generator
  • Accept openapi spec input, dereference and bundle the spec file using functions from openapi-ts
  • Setup tests using vitest
  • Add an executor to update the API spec file and regenerate the client code
  • Get build working (facing issues with integrating into monorepo)
  • Make plugins configurable and add the ability to add additional openapi-ts plugins
  • Support additional client types

Stretch in this PR:

  • Support different test frameworks
  • Setup linting support
  • Auto symlink the package if in workspace mode?
  • Auto-run the sync executor after generating a new package?

Questions:
Q: How to handle when the OpenAPI spec file updates?
A: We have added an executor and a call to each generated project. Each project can run that executor to update the spec file and regenerate the client code.

Copy link

stackblitz bot commented Apr 2, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

changeset-bot bot commented Apr 2, 2025

⚠️ No Changeset found

Latest commit: 89ed489

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Apr 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hey-api-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 10, 2025 5:59am

@seriouslag seriouslag mentioned this pull request Apr 2, 2025
@seriouslag seriouslag force-pushed the feat/add-nx-plugin branch from c5c265e to 6173f6f Compare April 2, 2025 18:24
@seriouslag seriouslag force-pushed the feat/add-nx-plugin branch from c8eb060 to 293e95a Compare April 2, 2025 23:08
@seriouslag seriouslag changed the title feat(nx-plugin): add OpenAPI client generator and related files feat(nx-plugin): add NX Plugin with OpenAPI client generator and executor Apr 3, 2025
@seriouslag seriouslag force-pushed the feat/add-nx-plugin branch from 0c82add to d883d59 Compare April 3, 2025 21:37
@seriouslag seriouslag force-pushed the feat/add-nx-plugin branch from 914a287 to a8a003c Compare April 4, 2025 05:33
@mrlubos mrlubos marked this pull request as draft April 4, 2025 20:02
Copy link

codecov bot commented Apr 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.35%. Comparing base (729488e) to head (89ed489).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1909      +/-   ##
==========================================
- Coverage   24.14%   22.35%   -1.80%     
==========================================
  Files         193      250      +57     
  Lines       26861    21024    -5837     
  Branches      787      781       -6     
==========================================
- Hits         6486     4699    -1787     
+ Misses      20300    16319    -3981     
+ Partials       75        6      -69     
Flag Coverage Δ
unittests 22.35% <100.00%> (-1.80%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

logger.debug('No existing spec file found. Creating...');
}
logger.debug(`Writing new spec to: ${absoluteExistingSpecPath}`);
writeFileSync(absoluteExistingSpecPath, newSpecString);

Check failure

Code scanning / CodeQL

Potential file system race condition High

The file may have changed since it
was checked
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants