Skip to content

require-versioned-service

Id
@azure-tools/typespec-client-generator-core/require-versioned-service

Severity: warning

This diagnostic is issued when @clientApiVersions is applied to a service namespace that is not versioned.

  • Area: API-version decorator validation. Generation continues, but @clientApiVersions has no service version list to extend on an unversioned namespace.
  • Not affected: The unversioned service operations are otherwise generated normally.
@service
@clientApiVersions(ApiVersions) // namespace is not decorated with `@versioned`
namespace My.Service {
enum ApiVersions {
v1,
v2,
}
}

TCGC reports:

Service "My.Service" must be versioned if you want to apply the "@clientApiVersions" decorator

Add TypeSpec versioning to the service namespace or remove @clientApiVersions.

@service
@versioned(Versions)
@clientApiVersions(ApiVersions)
namespace My.Service {
enum Versions {
v1,
v2,
}
enum ApiVersions {
v1,
v2,
}
}

This diagnostic should not be suppressed. Add versioning to the service (with @versioned), or remove @clientApiVersions if the service is not versioned.