Merged
Conversation
Includes interactive config init wizard and dry-run confirmation prompt using @inquirer/prompts alongside the original 6 features: config file loading, extended config, --dry-run, error messages, circular ref detection, and allOf composition.
Verify that self-referencing (User.manager -> User) and recursive (Node.children -> Node[]) schemas are handled without infinite loops. The current IR extraction already handles this by keeping $ref as string properties without recursion.
…ures
- Add existsSync check before reading, throws "Cannot find spec file: {path}"
- Wrap YAML/JSON parse in try/catch, throws "Failed to parse {path}: {error}"
- Improve unrecognized format message with expected formats hint
- Add tests for both error cases
Add resolveAllOf() function that merges properties from all allOf variants. For $ref variants, it looks up the referenced schema and collects its properties. For inline variants, it collects properties directly. Required arrays are unioned from all variants. Wire into extractIR() schema loop to detect schemaDef.allOf and resolve before property extraction.
Add console.warn at the top of extractIR when the spec has no paths defined, so users get a clear message about 0 operations being extracted rather than silently generating empty output.
- Add baseURL and apiFetchImportPath to writeGeneratedFiles options - Pass baseURL to generateHooks in flat mode - Pass baseURL to generateApiFetch in split mode - Pass apiFetchImportPath to generateHooks in flat mode - Add tests for baseURL passthrough in both flat and split modes
Verify the full pipeline (load -> IR -> generate -> write) correctly handles allOf specs. The test loads allof-composition.yaml, runs the pipeline, and verifies that User interface has merged properties from BaseEntity (id, createdAt) and inline (name, email), and that hooks for listUsers and createUser are generated.
- Add loadConfigFile() for dynamic import of config files - Add findConfigFile() to auto-search for apigen.config.ts/js - Add -c/--config and --base-url CLI options - Merge config: CLI flags override file config, file config overrides defaults
Change stringContaining('0 operations') to stringContaining("no 'paths'")
to match the actual warning message more precisely.
- Add FileInfo type and collectFileInfo() to writer for dry-run mode - writeGeneratedFiles returns FileInfo[] when dryRun is true, writes nothing - Add --dry-run CLI flag that previews files with sizes - In TTY mode, prompts to confirm before proceeding with generation - In non-TTY (CI), prints summary and exits
- Add promptForConfig() wizard: prompts for output dir, mock, split, baseURL - Add writeConfigFile() to save apigen.config.ts with defineConfig - When no config file and no -i flag, wizard runs after spec input prompt - Wizard offers to save config for future runs
Update all docs to reflect new features: config file loading, --config/--base-url/--dry-run flags, extended ConfigInput with split/baseURL/apiFetchImportPath, interactive wizard, allOf composition, and circular ref detection. Fix test count (87/13), add missing test files and fixtures to contributing guide.
Properties typed as `object` but named `address`, `contact`, etc. were
incorrectly getting faker string values instead of `{}` because the
name-based heuristic ran before the type check. Move object/unknown
type guards above the fakerValueForField fallback in mockPropertyValue.
Found via real-world testing against masterdata-tool (58 operations).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements all 6 Tier 1 recommendations from the CLI audit, plus 2 interactive enhancements, making apigen CI/CD-ready and beginner-friendly with zero breaking changes.
Features
resolveAllOf()merges properties from$refand inline variants--configflag + auto-search forapigen.config.ts/.jssplit,baseURL,apiFetchImportPathfields added to ConfigInputapigen.config.tsStats
Test plan
bun test— 88/88 pass, 0 failbun run typecheck— cleanbun run build— successful--dry-run— shows file preview with sizes, exits without writing in non-TTY--config apigen.config.js— loads config, generates correctly--config apigen.config.ts— works via Bun; Node.js requires--experimental-strip-types(known limitation)Usercorrectly mergesBaseEntitypropertiesKnown limitations
.tsconfig files require Bun or Node.js--experimental-strip-types..jsconfig works everywhere.-ior config file exits withExitPromptError.