microsoft/typespec

Public

mirrored from https://github.com/microsoft/typespecAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a6b7827fcd2db3bf604d42e235216c8d5b244f13

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

docs/release-notes/release-2022-07-08.md

98lines · modepreview

---
title: July 2022
---

# Release Notes July 2022 (2022-07-08)

This release contains **breaking changes**

- Emitter options normalized to use kebab-case instead of camelCase.
- `@serviceHost` decorator replaced by `@server` decorator
- Versioning decorators now use enumerated values instead of strings

## Emitter options

This release brings a stricter option definition for emitters and requires usage of those options to be specified with the fully qualified name to prevent conflicts.
All options have also been renamed to match `kebab-case` naming.
The options can also be specified via the `tspconfig.yaml` file.

### Migrating Command Line Scripts

If you had for example `--option operationPollingLocation=tenant`

1. Use `tspconfig.yaml` project file **Recommended**

   If you don't have that file yet, create it next to `package.json`, this file can be used to configure the emitters.

   ```yaml
   emitters:
     <fully-qualified-emitter-package-name>:
         <optionName>: <optionValue>

   # For example
   emitters:
     @typespec/openapi3:
       output-file: ./openapi.json
   ```

2. Via the `--option` flag

   You can still use the `--option` flag but you'll need to specify the fully qualified name of the option.

   ```bash
   --option @<emitter-package>.<optionName>=<optionValue>

   # For example
   --option @typespec/openapi3.output-file=openapi.json
   ```

#### Renamed Emitter Options

| Before                 | Now           |
| ---------------------- | ------------- |
| **@typespec/openapi3** |
| `outputFile`           | `output-file` |

## `@serviceHost` decorator replaced with `@server` decorator

The `@serviceHost` decorator that decorated the root namespace was used to specify the domain name of the base service endpoint. This functionality has been replaced by the `@server` decorator, which allows specifying full and parametrized Uris for the service endpoint, as described [here](https://microsoft.github.io/typespec/docs/standard-library/http/#service-definition-and-metadata)

### Before

```typespec
@serviceHost("example.com")
namespace MyService;
```

### After

```typespec
@server("https://example.com")
namespace MyService;
```

## Versioning uses enums instead of strings

Versions must now be specified using string-valued enumerations, and each of the versioning decorators must reference an enum value rather than using the version string directly.

```typespec
// Before
@versioned("2021-01-12" | "2022-01-15-preview")
namespace Api;

// After
@versioned(Versions)
namespace Api;

enum Versions { v2021_01_12: "2021-01-12", v2022_01_15_preview: "2022-01-15-preview" }
```

```typespec
// Before
@added("2022-01-15-preview")
model Foo {}

// After
@added(Versions.v2022_01_15_preview)
model Foo {}
```