packages/openapi-ts/README.md
Clone this repository
For self-hosted knots, clone URLs may differ based on your setup.
Download tar.gz
Only add file prefix to external schema names when there's a naming conflict. This results in cleaner schema names like "User" instead of "file1_User" when there's no ambiguity.
Changes:
- Modified remap() to try unprefixed names first
- Only add file prefix when the unprefixed name is already taken
- Updated fixDanglingRefs() to handle both prefixed and unprefixed names
- Updated test snapshots to reflect new cleaner naming
- Verified conflict resolution still works correctly
Example:
- No conflict: "SchemaA" (was "file1_SchemaA")
- With conflict: First gets "User", second gets "file2_User"
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Created expectBundledSchemaToMatchSnapshot() helper to eliminate repeated code in all 5 bundle tests. The helper handles:
- Creating output and snapshot paths
- Ensuring directory exists
- Writing bundled result to temp file
- Comparing with snapshot
This reduces duplication and makes tests more maintainable.
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Following the pattern from Zod v4 tests, convert bundle tests from value comparisons to snapshot testing for better visibility of bundled specs.
Changes:
- Added __snapshots__ directory with JSON snapshot files for each test
- Updated bundle.test.ts to use toMatchFileSnapshot matcher
- All 5 tests now write bundled output to temp directory and compare with snapshots
- Snapshots provide complete visibility of bundled spec structure
- Removed verbose assertion code, replaced with simple snapshot comparisons
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
When an external file references a schema from another external file using a local-looking ref (e.g., #/components/schemas/SchemaB), the bundle() function would:
1. Try to resolve it relative to the current file
2. Fail and log "Skipping unresolvable $ref"
3. Leave the ref as-is in the bundled output
4. Create a dangling reference since SchemaB is hoisted with a different name
Added fixDanglingRefs() post-processing step that:
- Identifies dangling internal $refs
- Matches them to hoisted schemas from other files
- Rewrites them to the correct hoisted names
Test case added: cross-file reference scenario
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
- Created test specs with YAML files mimicking Redfish structure
- Added comprehensive test for versioned schema names
- Verified sibling schemas are hoisted correctly with YAML
- All 4 bundle tests pass
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
- Created test specs with external files containing multiple schemas
- Added test case for sibling schema hoisting in bundle.test.ts
- All tests pass - sibling schemas are correctly hoisted
- Tested with local files, nested references, and HTTP URLs
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Add `patch.input` and shorthand `patch()` option for full specification transformations
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>