TypeSpec library for emitting openapi from the TypeSpec REST protocol binding
npm install @azure-tools/typespec-autorest
- Via the command line
tsp compile . --emit=@azure-tools/typespec-autorest
- Via the config
emit:
- "@azure-tools/typespec-autorest"
Type: string
Deprecated DO NOT USE. Use built-in emitter-output-dir instead
Type: string
Name of the output file. Output file will interpolate the following values:
- service-name: Name of the service if multiple
- version: Version of the service if multiple
- azure-resource-provider-folder: Value of the azure-resource-provider-folder option
- version-status: Only enabled if azure-resource-provider-folder is set.
preview
if version contains preview, stable otherwise.
Default: {azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json
Example: Single service no versioning
openapi.yaml
Example: Multiple services no versioning
openapi.Org1.Service1.yaml
openapi.Org1.Service2.yaml
Example: Single service with versioning
openapi.v1.yaml
openapi.v2.yaml
Example: Multiple service with versioning
openapi.Org1.Service1.v1.yaml
openapi.Org1.Service1.v2.yaml
openapi.Org1.Service2.v1.0.yaml
openapi.Org1.Service2.v1.1.yaml
Example: azureResourceProviderFolder is provided
arm-folder/AzureService/preview/2020-01-01.yaml
arm-folder/AzureService/preview/2020-01-01.yaml
Type: string
Directory where the examples are located. Default: {cwd}/examples
.
Type: string
Type: string
Type: string
Path to the common-types.json file folder. Default: '${project-root}/../../common-types/resource-management'
Type: "crlf" | "lf"
Set the newline character for emitting files.
Type: boolean
Omit unreachable types. By default all types declared under the service namespace will be included. With this flag on only types references in an operation will be emitted.
Type: string
Decide how to deal with the Version enum when when omit-unreachable-types
is not set. Default to 'omit'
Type: "inline-only" | "never"
If the generated openapi types should have the x-typespec-name
extension set with the name of the TypeSpec type that created it.
This extension is meant for debugging and should not be depended on.
Type: boolean
Create read-only property schema for lro status
@example
- attaches example files to an operation. Multiple examples can be specified.
@example
can be specified on Operations.
@Autorest.example(pathOrUri: valueof string, title: valueof string)
Operation
Name | Type | Description |
---|---|---|
pathOrUri | valueof string |
path or Uri to the example file. |
title | valueof string |
name or description of the example file. |
@useRef
- is used to replace the TypeSpec model type in emitter output with a pre-existing named OpenAPI schema such as Azure Resource Manager common types.
@useRef
can be specified on Models and ModelProperty.
@Autorest.useRef(jsonRef: valueof string)
Model | ModelProperty
Name | Type | Description |
---|---|---|
jsonRef | valueof string |
path or Uri to an OpenAPI schema. |