Skip to content

Latest commit

 

History

History
90 lines (61 loc) · 2.67 KB

configuration.md

File metadata and controls

90 lines (61 loc) · 2.67 KB

Configuration

Instead of putting all the switches on the command line, AutoRest can use a configuration file.

The format of this file can be one of three formats:

  • (.yaml) YAML - a yaml file with configuration in it
  • (.json) JSON - a json file with configuration in it.
  • (.md) markdown -- a literate configuration file, with triple-backtick YAML or JSON code blocks. Literate configuration files have the advantage of being able to mix documentation and settings easily, and code blocks can be turned on and off with your own switches.
    We use a lot of literate configuration files both internally in AutoRest and in the Azure Rest API specs repository as well.

Configuration file examples

The options available in a configuration file are the same as the ones on the command line. (with the exception of --debug and --verbose, which are only activated on the command line)

Just remove the double-dash and format appropriately.

For more advanced configuration scenarios, see

YAML

sample.yaml configuration file:

--- 
# it's the same options as command line options, just drop the double-dash!
input-file: myswagger.json
namespace: MyCompany.Rest
output-folder: output

Usage:

> autorest sample.yaml 

JSON

sample.json configuration file:

{
  "input-file": "myswagger.json",
  "namespace": "MyCompany.Rest",
  "output-folder": "output"
}

Usage:

> autorest sample.yaml 

Markdown - Literate Configuration

Since literate configuration files offer a lot more flexibility, AutoRest offers a bit more support for them.

If your file is named readme.md, autorest will find it automatically when run from the folder where the readme.md file is

AutoRest identifies a markdown file as a literate configuration file when it contains the magic string > see https://aka.ms/autorest on a line by itself.

readme.md configuration file:

# My API 

This file contains the configuration for generating My API from the OpenAPI specification.

> see https://aka.ms/autorest

``` yaml
# it's the same options as command line options, just drop the double-dash!
input-file: myswagger.json
namespace: MyCompany.Rest
output-folder: output
```

## Alternate settings

This section is only activated if the `--make-it-rain` switch is added to the command line

``` yaml $(make-it-rain)
namespace: MyCompany.Special.Rest
```

For more details, see Literate File Formats and autorest configuration files (Note: documentation needs updating...)