Skip to content

Commit

Permalink
Use specification readme file to generate the code. (#18996)
Browse files Browse the repository at this point in the history
  • Loading branch information
azabbasi authored Feb 24, 2021
1 parent 162b926 commit 95a015a
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions sdk/digitaltwins/Azure.DigitalTwins.Core/src/autorest.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
# Azure.DigitalTwins.Core

## Azure DigitalTwins swagger

## Local copy of the swagger document

A local copy of the official swagger documents are stored in this directory for convenience and testing purposes. Please make sure that you do not use these swagger documents for official code generation purposes.

## Official swagger document

The official swagger specification for Azure DigitalTwins can be found [here](https://raw.githubusercontent.com/Azure/azure-rest-api-specs/97db8d1015c2780c2704fe0f55537ff1f4740140/specification/digitaltwins/data-plane/Microsoft.DigitalTwins/preview/2020-05-31-preview/digitaltwins.json).

## Code generation

Run `generate.ps1` in this directory to generate the code.
Run `generate.ps1` in this directory or run `dotnet build /t:GenerateCode` to generate the code.

## AutoRest Configuration

> see <https://aka.ms/autorest>
``` yaml
#when generating from official source - The raw link must have a commit hash for C# generator
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/14fb40342c19f8b483e132038f8424ee62b745d9/specification/digitaltwins/data-plane/Microsoft.DigitalTwins/stable/2020-10-31/digitaltwins.json
tag: package-2020-10-31
require:
- https://raw.githubusercontent.com/Azure/azure-rest-api-specs/14fb40342c19f8b483e132038f8424ee62b745d9/specification/digitaltwins/data-plane/readme.md
```
### Directives
``` yaml
directive:
- from: swagger-document
where: $..[?(@.operationId=='DigitalTwins_GetComponent' || @.operationId=='DigitalTwins_GetRelationshipById' || @.operationId=='DigitalTwins_Add' || @.operationId=='DigitalTwins_GetById' || @.operationId=='DigitalTwins_AddRelationship')].responses.200.schema
transform: $.format = "binary";


#if you want to generate using local swagger copy:
#input-file: $(this-folder)/swagger/2020-`0-31/digitaltwins.json

#azure-arm: true
#license-header: MICROSOFT_MIT_NO_VERSION
#payload-flattening-threshold: 1
#namespace: Azure.DigitalTwins.Core
```
## This directive removes the specified enum values from the swagger so the code generator will expose IfNonMatch header as an option instead of always attaching it to requests with its only default value.
The following directive removes the specified enum values from the swagger so the code generator will expose IfNonMatch header as an option instead of always attaching it to requests with its only default value.
``` yaml
directive:
Expand Down

0 comments on commit 95a015a

Please sign in to comment.