Cadl AutoRest Library
This is a Cadl library that will emit an enriched OpenAPI 2.0 specification that can be consumed by AutoRest.
The generated OpenAPI spec will have custom x-ms-
extensions properties and conform to standards required by AutoRest to generate a more accurate SDK.
Getting started
- Include
@azure-tools/cadl-autorest
dependencies in package.json
{
...
"dependencies": {
...
"@azure-tools/cadl-autorest": "latest"
}
}
- Run
npm install
to install the dependency - Import
@azure-tools/cadl-autorest
in yourmain.cadl
file
import "@azure-tools/cadl-autorest";
- Run
cadl compile
. This will result in aswagger.json
file crated in./cadl-output/swagger.json
Use in autorest
Manually
Generate the OpenAPI spec as shown above then run autorest cli directly on it.
Via Autorest
AutoRest provides a plugin that will directly take Cadl as input. Make sure to use Autorest Core >=3.6.0
autorest --cadl --input-file=./main.cadl
Configuration
Output path
Specify the --output-path
option, this changes the directory where the OpenAPI specification (openapi.json) wil be omitted:
cadl compile --output-path=`./custom`