feat(typespec-metadata): add apiVersion field using TCGC resolution - #5065
feat(typespec-metadata): add apiVersion field using TCGC resolution#5065iscai-msft wants to merge 19 commits into
Conversation
f3029f1 to
a532259
Compare
Add apiVersion to LanguagePackageMetadata interface, resolved via
createSdkContext from @azure-tools/typespec-client-generator-core.
Resolution logic:
- Map size > 1 → "multiple-versions"
- Map size == 1 → the single value ("all" or actual version string)
- Empty/undefined → undefined
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
a532259 to
0ce39ea
Compare
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
Add integration tests that compile TypeSpec input and verify the apiVersions map from TCGC, matching the test style in typespec-client-generator-core/test/package/api-versions-metadata.test.ts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
… output Tests now compile TypeSpec input, run the full emitter, and assert the apiVersion field on the emitted metadata snapshot (not just the TCGC map). Also adds api-version as a passthrough emitter option. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
The e2e tests in api-version.test.ts fully cover apiVersion behavior by testing the actual emitter output. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
| * - An actual resolved version string (e.g. `"2023-10-01"`) for a single version | ||
| * - `undefined` when no API version information is available | ||
| */ | ||
| apiVersion?: string; |
There was a problem hiding this comment.
Should this be in language metadata or typespec metadata? Is it possible to have different API version value for each language?
There was a problem hiding this comment.
you're right, I guess each language could specify different values in tspconfig.yaml, so it shouldn't be the case but it could be
There was a problem hiding this comment.
would you prefer to ignore that possibility and move it to typespec metadata, or keep it where it is in language metadata
There was a problem hiding this comment.
Nope. Let's keep it in language metadata. It's easier to parse all get the distinct on the consumer side.
The lockfile was generated with internal registry URLs that fail CI tarball verification. workspace:^ dependencies don't need lockfile changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
17f535c to
2a8df3d
Compare
|
All changed packages have been documented.
Show changes
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7d63e253-0c42-46ea-88b1-3e0aa1dddebe
commit: |
…erTester Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
|
You can try these changes here
|
… for passthrough Remove api-version from MetadataEmitterOptions and its schema since TCGC reads it directly from EmitContext. Set additionalProperties: true so unknown options like api-version pass through in tspconfig without validation errors. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…data map Read apiVersion directly from sdkContext (which TCGC populates from context.options["api-version"]) to handle the 'all' case. Fall back to resolved apiVersions map for specific version resolution. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 75e5e691-2de3-4305-9855-bee4534c6690
api-version passthrough is not needed — TCGC resolves versions from TypeSpec versioning decorators when no explicit api-version is configured. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 75e5e691-2de3-4305-9855-bee4534c6690
…tadata Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 75e5e691-2de3-4305-9855-bee4534c6690
Add an isPreview boolean field to sdkPackage.metadata so consumers can determine if the SDK targets preview API versions without recomputing from version strings. - true if any targeted API version matches the preview string regex - false if all versions are stable - undefined if no versioning is present Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4d3f5528-7e0e-4828-ab85-b85ba9dffc5d
This reverts commit ef4b4bc.
…-carnival # Conflicts: # pnpm-lock.yaml
f89aac7 to
f82a9fb
Compare
Resolves whether the SDK targets preview or stable API versions by checking client apiVersions against TCGC's previewStringRegex. The @previewVersion decorator case will be handled once TCGC exposes isPreview on its metadata. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: c95a24d5-2785-44e4-9599-ac2f5cb37a2c
Summary
Adds an
apiVersionfield to theLanguagePackageMetadatainterface inpackages/typespec-metadata, resolved viacreateSdkContextfrom@azure-tools/typespec-client-generator-core.Changes
src/metadata.ts: AddedapiVersion?: stringtoLanguagePackageMetadatawith doc comment explaining possible valuessrc/emitter.ts: CallscreateSdkContextand resolvessdkPackage.metadata.apiVersionsmapsrc/collector.ts: ThreadsresolvedApiVersionthroughcollectLanguagePackages→buildLanguageMetadata→createLanguageMetadatapackage.json: Added@azure-tools/typespec-client-generator-coreas"workspace:^"dependencytest/collector.test.ts: Added "apiVersion extraction" describe block with 5 testsResolution Logic
"multiple-versions""all"or actual version like"2023-10-01")undefined