Skip to content

feat: update ParametersTypeCoder and ParameterExportTypeCoder to emit output under version subdirectories#1960

Open
Copilot wants to merge 3 commits intomainfrom
copilot/update-typecoders-output-versions
Open

feat: update ParametersTypeCoder and ParameterExportTypeCoder to emit output under version subdirectories#1960
Copilot wants to merge 3 commits intomainfrom
copilot/update-typecoders-output-versions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 26, 2026

Summary

ParametersTypeCoder and ParameterExportTypeCoder were not following the types/<version>/... output convention already used by SchemaTypeCoder and ResponseTypeCoder. This change brings them into alignment so all type coders (except OperationTypeCoder) isolate per-version output under types/<version>/.

ParametersTypeCoder.modulePath()

  • Before: parameters/<path>.types.ts (no types/ prefix, wrong subdirectory)
  • After: types/<version>/paths/<path>.parameters.ts when versioned, types/paths/<path>.parameters.ts when not

ParameterExportTypeCoder.modulePath()

  • Removed the public _modulePath!: string field that was set post-construction by callers
  • modulePath() now computes the path directly from this.version and this.requirement.url, identical logic to VersionedArgTypeCoder

OperationTypeCoder cleanup

  • Removed the now-unused modulePath parameter from exportParameterType() and buildDollarArgType(), and the coder._modulePath = modulePath assignment

Tests

  • Updated existing ParametersTypeCoder modulePath test to expect the new path format
  • Added versioned and empty-version modulePath tests for ParametersTypeCoder
  • New test file test/typescript-generator/parameter-export-type-coder.test.ts covering versioned and non-versioned modulePath() behaviour
Original Prompt

SchemaTypeCoder and ResponseTypeCoder already emit their output under types/<version>/... when a non-empty version is set. The remaining TypeCoder subclasses that produce version-specific type files must be updated to follow the same convention.

Context

The multi-version code generation strategy is:

Every TypeCoder except OperationTypeCoder writes its output into a types/<version>/ subdirectory when a version is present, so that the types for each version are fully isolated. OperationTypeCoder is the exception: it lives at the shared path and imports/merges types from all version subdirectories (see companion issue).

SchemaTypeCoder and ResponseTypeCoder already implement this:

types/v1/components/MySchema.ts
types/v1/responses/MyResponse.ts
types/v2/components/MySchema.ts
types/v2/responses/MyResponse.ts

The following coders still need to be updated:

  • ParametersTypeCoder – emits types/paths/<path>.parameters.ts
  • ResponsesTypeCoder – emits types for the combined response object
  • ParameterExportTypeCoder – emits individual exported parameter types

Proposed change

For each coder listed above, update modulePath() to insert the version segment between types/ and the remainder of the path when this.version is non-empty, mirroring the pattern already used in SchemaTypeCoder and ResponseTypeCoder:

// before
return `types/paths/${pathString}.parameters.ts`;

// after
return pathJoin("types", this.version, "paths", `${pathString}.parameters.ts`);
// → "types/v1/paths/pets.parameters.ts" when version = "v1"
// → "types/paths/pets.parameters.ts"    when version = ""

No other behaviour should change; only the output file location is affected.

Acceptance criteria

  • ParametersTypeCoder.modulePath() returns types/<version>/paths/... when version is non-empty and types/paths/... when empty
  • ResponsesTypeCoder.modulePath() (if it declares one) follows the same convention
  • ParameterExportTypeCoder.modulePath() follows the same convention
  • Existing unit tests for modulePath() on each affected coder continue to pass
  • New unit tests assert the versioned path for a non-empty version on each affected coder
  • Single-spec (no version) generation produces identical output to today

Manual acceptance tests

  • Single-spec (no version) generates parameter type files at types/paths/<path>.parameters.ts with no version segment inserted
  • Multi-version spec (e.g. version: "v1") generates parameter type files at types/v1/paths/<path>.parameters.ts
  • ParameterExportTypeCoder exports (e.g. HTTP_GET_$_Query) land in types/v1/paths/<path>.types.ts when version = "v1" and types/paths/<path>.types.ts when version = ""
  • Routes without a version continue to work as before with no generated-output changes
  • TypeScript compilation of generated output succeeds for both versioned and non-versioned specs

Tasks

  • Updated ParametersTypeCoder.modulePath() to use pathJoin("types", this.version, "paths", pathString) + ".parameters.ts"
  • Replaced ParameterExportTypeCoder._modulePath field with a self-contained modulePath() that computes the versioned path from this.version and this.requirement.url
  • Removed now-unused modulePath parameter from OperationTypeCoder.exportParameterType() and buildDollarArgType() (and their call sites)
  • Updated existing ParametersTypeCoder modulePath test; added versioned and empty-version assertions
  • Created test/typescript-generator/parameter-export-type-coder.test.ts with non-versioned, versioned, and empty-version modulePath tests
  • Added patch-level changeset

@pmcelhaney pmcelhaney marked this pull request as ready for review April 26, 2026 01:50
Copilot AI changed the title [WIP] Update remaining TypeCoders to emit output under version subdirectories feat: update ParametersTypeCoder and ParameterExportTypeCoder to emit output under version subdirectories Apr 26, 2026
Copilot AI requested a review from pmcelhaney April 26, 2026 02:01
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.

generator: update remaining TypeCoders to emit output under version subdirectories

2 participants