Skip to content

Autorest v3 based generator cheatsheet

iscai-msft edited this page Mar 2, 2020 · 13 revisions

Run pure Python on a YAML model

python -m autorest.code_generator code-model-v4-no-tags.yaml

Tests

Starting tests even if some files are not Python valid

pytest --continue-on-collection-errors

No traceback

pytest --continue-on-collection-errors --tb=no

Using autorest

npm install -g "@autorest/autorest"

autorest --use:@autorest/modelerfour@~4.0.9 --output-artifact:code-model-v4-no-tags --input-file:https://github.com/Azure/azure-rest-api-specs/blob/master/specification/storage/resource-manager/Microsoft.Storage/stable/2019-04-01/storage.json --output-folder=.

Calling mypy from root

mypy --config-file=mypy.ini autorest

VSCode debug

VScode launch configuration

    {
      "name": "Python: Attach",
      "type": "python",
      "request": "attach",
      "port": 5678,
      "host": "localhost"
    }

Then, set the env variable "AUTOREST_PYTHON_ATTACH_VSCODE_DEBUG" to any string (content doesn't matter)

When autorest is started, it will block automatically when starting the JSON server, waiting for attach from VScode

Clone this wiki locally