Skip to content

feat(core): createNodes plugin for openapi-client.json - #97

Merged
michaelbe812 merged 2 commits into
mainfrom
feat/crystal-create-nodes
Oct 5, 2026
Merged

michaelbe812 merged 2 commits into
mainfrom
feat/crystal-create-nodes

Conversation

@michaelbe812

Copy link
Copy Markdown
Contributor

Part of #84
Relates to #16

What

  • createNodesV2 plugin in core, exposed as @nx-plugin-openapi/core/plugin via root-level packages/core/plugin.ts (builds to dist/packages/core/plugin.js). No exports map; tsconfig path added for local use.
  • Reads **/openapi-client.json (one file per client, paths relative to the file, JSON schema at src/plugin/openapi-client.schema.json). It infers:
    • client project <name>: a generate target (generate-api, cache: true; inputs are the definition, the spec and an optional configFile; outputs are the output dir plus the lib src dirs)
    • update-spec if url is set (cache: false, check configuration). It is not a dependsOn of generate.
    • with split: <name>-types|api|core under targetRoot, tagged type:types / type:api / type:util plus the client tags. Each lib has an implicit dependency on the client, and build/typecheck get dependsOn: ['...', {projects:[client], target:'generate'}].
  • Options: generateTargetName, updateSpecTargetName, tags, dependentTargets.
  • Merge semantics: an existing project.json/package.json name in the client dir is used for references, and explicit config wins.
  • Docs: usage/inferred-targets with a sidebar entry.
{
  "name": "petstore",
  "spec": "petstore.openapi.json",
  "url": "https://petstore3.swagger.io/api/v3/openapi.json",
  "generator": "openapi-tools",
  "generatorOptions": {},
  "split": { "aliases": { "types": "@acme/petstore-types", "api": "@acme/petstore-api", "core": "@acme/petstore-core" } },
  "tags": ["scope:shared"]
}

Verification

  • nx run-many -t lint test build -p core passes (13 new createNodes tests with fixture trees).
  • Manual check in this repo (Nx 23.2.1): nx show projects lists petstore, petstore-types|api|core. nx run petstore-api:build runs petstore:generate (openapi-tools + split, 188 files). A rerun is a cache hit. update-spec --check reports drift.

Notes

  • '...' spread in dependsOn needs a recent Nx (tested on 23). Register the plugin after plugins that infer build/typecheck.
  • Each split lib needs one tracked file, or Nx fails with "project not found" while hashing (documented; add-client in the stacked PR writes READMEs).

🤖 Generated with Claude Code

michaelbe812 and others added 2 commits October 5, 2026 15:08
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@michaelbe812
michaelbe812 merged commit 74d4899 into main Oct 5, 2026
1 check 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