Autorest provides a set of built-in directives for common scenarios to simplify things.
Those directives are defined here
directive:
- where-operation: <operationId>
transform: ... # Your transform code
- where-operation-match: <fullregex with // and flags>
transform: ... # Your transform code
Examples:
- where-operation: MyOperation
transform: $["x-marked"] = true
- where-operation-match: /mygroup_.*/i
transform: $["x-marked"] = true
directive:
- where-model: <modelName>
transform: ... # Your transform code
directive:
- remove-operation: <operationId>
- remove-operation-match: <regex>
Examples:
directive:
# Remove operation with operationId: Foo_Get
- remove-operation: Foo_Get
# Remove all operations with matching operationIds
- remove-operation-match: /^foo_g.*/i
directive:
- rename-operation:
from: <operationId>
to: <new-operationId>
Examples:
directive:
# Rename operation with operationId: Foo_Get to Bar_Get
- rename-operation:
from: Foo_Get
to: Bar_Get
directive:
- remove-model: <name>
Examples:
directive:
# Remove model named MyModel
- remove-model: MyModel
directive:
- rename-model:
from: <name>
to: <new-name>
Examples:
directive:
# Rename model named MyModel to NewModel
- rename-model:
from: MyModel
to: NewModel
Remove the property on a model, to be used with where-model
directive:
- where-model: <model-name>
remove-property: <property-name>
Examples:
directive:
# Remove property foo on model named MyModel
- where-model: MyModel
remove-property: foo
Rename the property on a model(Rename the actual property name and doesn't change x-ms-client-name
.), to be used with where-model
directive:
- where-model: <model-name>
rename-property:
from: <property-name>
to: <new-property-name>
Examples:
directive:
# Rename property foo to bar on model named MyModel
- where-model: MyModel
rename-property:
from: foo
to: bar
Remove a parameter. To be used with where-operation
or where: '$.paths..'
for all operations.
directive:
- remove-parameter:
in: <type> # header,query,cookie(Same options allowed in OpenAPI)
name: <name> # Name of the parameter
Examples:
directive:
# Remove header named myHeader on operation Foo_Get
- where-operation: Foo_Get
remove-parameter:
in: header
name: myHeader
# Remove query parmeter named page on all operations
- where: "$.paths..*"
remove-parameter:
in: header
name: page