May 2023
New Features
@typespec/compiler features
- Add
@encodedecorator, with new formats for date and duration encoding support"rfc3339","rfc7231'forutcDateTime,offsetDateTimetypes"unixTimestamp"support forutcDateTimetype"iso8601"support fordurationtypes"base64","base64url"support forbytestypes
- Allow default values for required model properties and parameters
sourceModelproperty added toModeltypessourceOperationproperty added toOperationtypesModelandScalartypes added toTypeSpec.Reflectionnamespace
@typespec/http features
- add
@sharedRoutedecorator - allow union types within a response status code
@typespec/openapi3 features
- Enhanced support for shared routes
- Support for union types within a response status code
Bug Fixes
- General fixes to generated reference documentation for all modules
@typespec/compiler fixes
- Fix: compiler mismatch error recommendation
- Fix: Interface with templated operation causing crash if defined after use
- Fix: Issue with templated operations in templated interface would get cached only by keying on the operation template args.
- Fix:
missing-indexdiagnostic showing at the wrong location - Fix:
--emitpointing to emitter js entrypoint resolve correct options - Fix:
scalartemplate parameter name conflict with each other
@typespec/migrate fixes
- Fix: incorrect resolution of tsp version
- Fix: always loading current version of compiler
@typespec/openapi3 fixes
- Fix openapi3 emitter to mark request body required
- Fix issue where shared request bodies did not emit correctly.
@typespec/rest
- Add validation to ensure that @action or @collectionAction operations have a specified name when used with
@sharedRoute
@typespec/versioning
- Fix: Crash during validation when using certain templated models from versioned library
- Added validation preventing version enums from having duplicate values.
- Fix issue where βisβ dependencies were not detected.
- Raise error if versioned spec specifies a single service version.
Breaking Changes
@typespec/compiler: isTemplateDeclaration will only return true for the original declaration and not partially instantiated templates
If library or emitter code needs to detect a partially instantiated template, the code will need to check isTemplateInstance and isTemplateDeclaration properties are false.
Deprecations
@typespec/compiler: Use @encode instead of @format for encoding scalars and properties of type bytes
The new @encode decorator should be used whenever the serialized type on the wire differs from the analogous TypeSpec type
Old deprecated usage of @format decorator
model Foo { @format("base64url") bar: bytes;}New usage of @encode decorator
model Foo { @encode("base64url") bar: bytes;}http: Use @sharedRoute instead of the shared property of @route options
The new @sharedRoute decorator replaces @route options for identifying operations that share a route
Old deprecated usage of @route decorator shared option
@route( "/doStuff", { shared: true, })op doIntStuff(input: int32): int32;
@route( "/doStuff", { shared: true, })op doStringStuff(input: string): string;New usage of @sharedRoute decorator
@sharedRoute@route("/doStuff")op doIntStuff(input: int32): int32;
@sharedRoute@route("/doStuff")op doStringStuff(input: string): string;