microsoft / microsoft/typespec
Emit profiles
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
There is cases where you might want to run the same emitter multiple times(e.g. #8442) with different settings. There is also the potential need to define additional steps in the emitter flow(e.g. automatically apply versioning mutation)
```yaml
emit:
- @typespec/openapi3
- json-schema-yaml
- json-schema-json
profiles:
json-schema-yaml:
emitter: @typespec/json-schema
options:
file-type: yaml
json-schema-json:
emitter: @typespec/json-schema
options:
file-type: json
```
which would then allow defining those additional steps in some way like
```yaml
profiles:
json-schema-json:
emitter: @typespec/json-schema
mutators:
- some-mutator-lib/foo
options:
file-type: json
```
additionally `emit` could also take an inline profile for ease of setup
```yaml
emit:
- @typespec/openapi3
- emitter: @typespec/json-schema
options:
file-type: yaml
-emitter: @typespec/json-schema
options:
file-type: json
```
## Things to figure out
- How does that interact with the exisitng `options` field, should `options` be for the common setup, should we recommend migrating to `profiles`, should `options` be able to use as a way to define the default options for all emitters using that profiles
```yaml
options:
@typespec/json-schema:
int64-strategy: string
profiles:
json-schema-yaml:
emitter: @typespec/json-schema
extends: "@typespec/json-schema" # with extends, could then technically extend another profile
options:
file-type: yaml
json-schema-json:
emitter: @typespec/json-schema
options:
_: {{options.@typespec/json-schema}} # some kind of syntax that reference and spread elements
file-type: json
```
Contributor guide
Assessment
This issue has not been assessed yet.