feat: add schemaName support for OpenAPI spec generation#171
Merged
andrewzolotukhin merged 6 commits intodevelopmentfrom Apr 15, 2026
Merged
feat: add schemaName support for OpenAPI spec generation#171andrewzolotukhin merged 6 commits intodevelopmentfrom
andrewzolotukhin merged 6 commits intodevelopmentfrom
Conversation
- Introduced .schemaName() method to schema builders for naming schemas. - Implemented SchemaRegistry to manage named schemas and prevent conflicts. - Enhanced generateOpenApiSpec to deduplicate schemas using $ref pointers. - Added tests for schemaName functionality and registry behavior. - Updated documentation to reflect new schema naming and deduplication features.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class schema naming metadata to @cleverbrush/schema and wires it through @cleverbrush/server-openapi / @cleverbrush/schema-json so OpenAPI generation can deduplicate repeated schema definitions via $ref + components.schemas.
Changes:
- Introduces
.schemaName(name)on all schema builders and exposes it viaintrospect().schemaName. - Adds
SchemaRegistry+walkSchemas()and updatesgenerateOpenApiSpec()to emitcomponents.schemasand$refpointers. - Extends
toJsonSchema()with anameResolverhook used to emit$refs, plus docs/tests/website updates.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| website/app/server-openapi/page.tsx | Website docs section describing $ref deduplication via named schemas |
| website/app/schema/sections/schema-name.tsx | New website docs section for .schemaName() |
| website/app/schema/sections/index.ts | Adds schema-name to schema docs navigation |
| website/app/schema/[[...slug]]/page.tsx | Registers SchemaNameSection in routing |
| website/app/schema-json/page.tsx | Documents nameResolver usage for $ref emission |
| libs/server-openapi/src/schemaRegistry.ts | Adds SchemaRegistry + walkSchemas() for collecting named schemas |
| libs/server-openapi/src/schemaRegistry.test.ts | Unit tests for registry behavior and schema walking |
| libs/server-openapi/src/schemaConverter.ts | Passes registry-backed nameResolver into toJsonSchema() |
| libs/server-openapi/src/index.ts | Exports registry utilities |
| libs/server-openapi/src/generateOpenApiSpec.ts | Pre-walks schemas, emits components.schemas, uses $ref in operations |
| libs/server-openapi/src/generateOpenApiSpec.test.ts | Adds tests for $ref deduplication behavior |
| libs/server-openapi/README.md | Documents named schema deduplication + registry utilities |
| libs/schema/src/builders/schemaName.test.ts | Adds runtime + type-level tests for .schemaName() |
| libs/schema/src/builders/SchemaBuilder.ts | Implements .schemaName() + introspect().schemaName |
| libs/schema/README.md | Documents .schemaName() |
| libs/schema-json/src/types.ts | Adds nameResolver option type/docs |
| libs/schema-json/src/toJsonSchema.ts | Implements nameResolver hook to emit $ref |
| libs/schema-json/README.md | Documents nameResolver and $ref limitations |
| .changeset/schema-name-ref-deduplication.md | Changeset for the feature across packages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Description
Type of Change
Checklist
npm run lintand fixed any issuesnpm run testand all tests passnpx changeset) if this changes package behavior