Skip to content

Request NX plugin #1910

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
seriouslag opened this issue Apr 2, 2025 · 8 comments · May be fixed by #1947
Open

Request NX plugin #1910

seriouslag opened this issue Apr 2, 2025 · 8 comments · May be fixed by #1947
Labels
feature 🚀 New feature or request

Comments

@seriouslag
Copy link
Contributor

seriouslag commented Apr 2, 2025

Description

An NX plugin with a generator to generate NX package and update spec/client code when a command is run.
Running the NX generator would ask for the spec file and project name, then output a new NX project with client code generated from openapi-ts.

The generated project would have an executor that could update the spec file and generate new client code.

This would be helpful when integrating into NX monorepos.

NX plugin docs
NX plugin getting started

PR of NX plugin


Example repo

# To run,
pnpm install
# Build the plugin, since the generator and executor use the dist files
npx nx run @test-plugin/nx-plugin:build
# Run the generator
npx nx g @test-plugin/nx-plugin:openapi-client pokemon-api --directory ./packages --scope @test-plugin --client @hey-api/client-fetch --spec https://raw.githubusercontent.com/seriouslag/pokemon-api-spec/refs/heads/main/spec.yaml --plugins @tanstack/react-query
# Run the update executor - this will download and compare the spec files
npx nx run @test-plugin/pokemon-api:updateApi
@seriouslag seriouslag added the feature 🚀 New feature or request label Apr 2, 2025
@mrlubos
Copy link
Member

mrlubos commented Apr 2, 2025

Can you link me to any documentation where I can read more about what you're building/solving?

@seriouslag
Copy link
Contributor Author

seriouslag commented Apr 2, 2025

Can you link me to any documentation where I can read more about what you're building/solving?

NX plugin docs
NX plugin getting started

@mrlubos
Copy link
Member

mrlubos commented Apr 2, 2025

And you'll be using this to create a client that's always up-to-date with the spec? Something like Nuxt modules or Vite plugin?

@seriouslag
Copy link
Contributor Author

seriouslag commented Apr 2, 2025

And you'll be using this to create a client that's always up-to-date with the spec? Something like Nuxt modules or Vite plugin?

My goal is to give the NX workspace users commands to generate package and update the client code in packages.

The user could run something as nx run-many -t updateApi, the plugin would fetch the latest API spec and compare to existing spec, if it is different then generate new client code.

@seriouslag
Copy link
Contributor Author

seriouslag commented Apr 2, 2025

Example repo showing a local NX plugin that adds a generator that will generate an package from an OpenAPI spec.

To run, `npm install && nx run @test-plugin/nx-plugin:build && nx g @test-plugin/nx-plugin:openapi-client pokemon-api --directory ./packages --scope @test-api --client @hey-api/client-fetch --spec https://raw.githubusercontent.com/seriouslag/pokemon-api-spec/refs/heads/main/spec.yaml --plugins @tanstack/react-query

@mrlubos
Copy link
Member

mrlubos commented Apr 2, 2025

How will you compare specs?

Why did you decide to use Redocli CLI vs something we already have in the repository?

Will you write the documentation for this plugin as well?

I'll probably have more questions later!

@seriouslag
Copy link
Contributor Author

seriouslag commented Apr 2, 2025

Q: How will you compare specs?
A: Using this library

Q: Why did you decide to use Redocli CLI vs something we already have in the repository?
A: Are there examples of bundling and dereferencing an OpenAPI spec of what is already in the repo? I used redo as it is what I use daily. Happy to dogfood in this repo.

Q: Will you write the documentation for this plugin as well?
A: I could use help with this. I have added readme.md

I'll probably have more questions later!

Looking forward to it.

@seriouslag
Copy link
Contributor Author

@mrlubos Removed Redocli, in favor of using functions in openapi-ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants