February 2023
New Features
Emitter Framework
The new emitter framework makes it simpler to build emitters from TypeSpec to other assets. It provides an easy way to handle TypeSpec types and provides a template for asset emitters to spell out the emitter tasks. It provides helpers to solve many difficult problems, including:
- Constructing references between types
- Handling circular references
- Propagating type context based on containers or references
- Class-based inheritance to encourage reuse and specialization of existing emitters
Details are available on the documentation website or in the [repository documentation] (https://github.com/microsoft/typespec/blob/main/docs/extending-typespec/emitter-framework.md).
Cli support for emitters in development
Use the path to the emitter to specify emitter options, rather than the emitter name.
Allow @autoroute
and @route
to be used together
Provide standard rules for combining @route
and @autoroute
decorators
- Allow
@route
applied to an operation to override route settings from the interface - Allow
@route
on an operation to prepend the paths provided by@autoroute
Simplified versioning dependencies
Introduced the @useDependency
decorator to replace @versionedDependency
decorator. Simplify dependencies between versioned namespaces, by allowing each version to be decorated with the appropriate versioned dependency, rather than requiring the user to construct a dependency map.
Breaking Changes
Breaking changes in this release resulted from removal of previously decorated types and functions, including:
uri
scalar removed. Use theurl
scalar instead.- Removed deprecated metadata types with the ‘type’ suffix.
- Use
Enum
instead ofEnumType
- Use
EnumMember
instead ofEnumMemberType
- Use
Interface
instead ofInterfaceType
- Use
Model
instead ofModelType
- Use
ModelProperty
instead ofModelTypeProperty
- Use
Namespace
instead ofNamespaceType
- Use
Operation
instead ofOperationType
- Use
Tuple
instead ofTupleType
- Use
Union
instead ofUnionType
- Use
- Removed
Map<K, V>
type, useRecord<V>
instead - Removed
@serviceTitle
and@serviceVersion
decorators. Use the@service
decorator instead. - Removed helper and accessor functions associated with
@serviceTitle
and@serviceVersion
decorators- Replace
getServiceNamespace
,getServiceTitle
,getServiceVersion
, andgetServiceNamespaceString
withgetService
orlistServices
- Replace
setServiceNamespace
withaddService
- Replace
- Removed
@segmentSeparator
, use@actionSeparator
instead - Removed
@produces
and@consumes
decorators. Use@header contentType: <ContentType>
instead in the operation return type - Removed
getSegmentSeparator
function. UsegetActionSeparator
instead - Removed
getProduces
andgetConsumes
functions. UsegetContentTypes
instead
Deprecations
Deprecates the @versionedDependency
decorator in favor of the @useDependency
decorator
For versioned libraries, @useDependency
is applied to the version enum members
Before (versioned namespace)
After (Versioned namespace)
For unversioned libraries that reference versioned libraries, simply replace @versionedDependency
with @useDependency