Skip to content

Add operation-scoped OpenAPI generation and incremental type generator service - #43

Draft
nfroidure with Copilot wants to merge 2 commits into
mainfrom
copilot/allow-partial-generation
Draft

nfroidure with Copilot wants to merge 2 commits into
mainfrom
copilot/allow-partial-generation

Conversation

Copilot AI commented Oct 26, 2026 •

Copy link
Copy Markdown

The current flow emits a single full declaration set, which is limiting for framework use cases that need per-handler outputs and incremental regeneration. This PR adds operation-level partial generation and a service API to support full bootstrap generation plus targeted rebuilds.

  • Operation-scoped generation

    • Added filterOperations?: string[] to OpenAPITypesGenerationOptions (with default []).
    • Updated OpenAPI fragment building to emit only selected operations (by operationId) when filtering is enabled.
    • Preserves existing behavior when no operation filter is provided.
  • Incremental generation service

    • Added createTypeGeneratorService(...) with:
      • generateOpenAPISchema(content) for initial full generation.
      • generateSchemas(names) for partial regeneration of specific operations/schemas.
    • Added configurable resolveSchemaPath(name, kind, reference) to map generated artifacts to caller-defined file paths.
    • Added explicit error paths for invalid usage / unknown targets (E_OPEN_API_SCHEMA_NOT_GENERATED, E_SCHEMA_NOT_FOUND).
  • Public API and internal refactor

    • Exported GeneratedSchema, TypeGeneratorService, and TypeGeneratorServiceOptions.
    • Centralized OpenAPI context construction for consistent behavior across full and partial generation paths.
  • Documentation and focused coverage

    • Updated README with filterOperations and createTypeGeneratorService usage.
    • Added targeted tests for operation filtering, service-based full/partial generation, and failure modes.
  • Related hardening in touched code

    • Reworked buildIdentifier to a linear character-scan implementation, removing regex patterns that can degrade under pathological input.
const generator = createTypeGeneratorService({
  openAPITypesOptions: { basePath: 'src/schema/openapi.d.ts' },
  resolveSchemaPath: (name) => `src/handlers/${name}.d.ts`,
});

await generator.generateOpenAPISchema(openAPIContent);
const files = await generator.generateSchemas(['putEcho', 'Echo']);

Copilot AI linked an issue Oct 26, 2026 that may be closed by this pull request
Co-authored-by: nfroidure <229633+nfroidure@users.noreply.github.com>
Copilot AI changed the title [WIP] Add capability to allow partial schema generation Add operation-scoped OpenAPI generation and incremental type generator service Oct 26, 2026
Copilot AI requested a review from nfroidure October 26, 2026 10:28
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.

Allow partial generation

2 participants