Skip to content

feat(core): add-client generator - #98

Merged
michaelbe812 merged 1 commit into
mainfrom
feat/add-client-generator
Oct 5, 2026
Merged

michaelbe812 merged 1 commit into
mainfrom
feat/add-client-generator

Conversation

@michaelbe812

Copy link
Copy Markdown
Contributor

Stacked on #97 — merge after (rebase).

Part of #84
Relates to #5

What

  • add-client generator in core. Options: name, directory, scope?, spec (local path or URL), adapter (openapi-tools | hey-api), generatorOptions?, split (default true), importPrefix? (default: npm scope of root package.json), addToGitignore, skipFormat.
    • --adapter instead of --generator, because nx g reserves --generator. The definition field stays generator.
    • A URL spec is downloaded once to <directory>/<name>.openapi.json|yaml, written verbatim after formatting and added to .prettierignore so update-spec --check doesn't report false drift. The URL is stored for update-spec.
    • Writes openapi-client.json, registers @nx-plugin-openapi/core/plugin in nx.json if missing, and adds tsconfig paths for the split aliases (fails on a conflicting alias). It also writes a README.md per split lib (a project without tracked files breaks Nx task hashing) and gitignores the generated dirs. No project.json.
  • init: no longer hard-wires {projectRoot}/swagger.json / openapitools.json inputs. It only adds cache: true and keeps existing user config.
  • update-spec: fetchSpec is exported for reuse. The ignore-entry utils no longer add blank lines.
  • Docs: add-client flow in getting-started/quick-start.

Verification

  • nx run-many -t lint test build -p core passes (14 add-client + 2 init tests with createTreeWithEmptyWorkspace).
  • Manual check in this repo (Nx 23.2.1): nx g @nx-plugin-openapi/core:add-client petstore --directory=scratch/petstore --scope=shared --spec=https://petstore3.swagger.io/api/v3/openapi.json --adapter=hey-api. Then update-spec --check is up to date, nx show projects lists the 4 projects, and nx build petstore-api runs generate + split. Restoring the deleted src from cache works, and a consumer importing @demo/petstore-api / @demo/petstore-types typechecks.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@michaelbe812
michaelbe812 changed the base branch from feat/crystal-create-nodes to main October 5, 2026 13:10
@michaelbe812
michaelbe812 force-pushed the feat/add-client-generator branch from 6348b87 to 6d93381 Compare October 5, 2026 13:10
@michaelbe812
michaelbe812 merged commit 41183af into main Oct 5, 2026
2 checks passed
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.

1 participant