|
| 1 | +# Readme Configuration Guide for Azure SDK for Javascript (Typescript) |
| 2 | +This file describe how to configure readme files to make it available for Azure SDK for Javascript (Typescript) code generation. |
| 3 | + |
| 4 | +## Common Configuration |
| 5 | +Configure basic package information. |
| 6 | + |
| 7 | +### Basic Information |
| 8 | +Configure package title/description/tag. |
| 9 | +~~~~ |
| 10 | +// file: readme.md |
| 11 | +
|
| 12 | +``` yaml |
| 13 | +title: xxxxConfigurationClient |
| 14 | +description: xxxx Configuration Client |
| 15 | +openapi-type: arm |
| 16 | +tag: package-xxxx-xx-xx |
| 17 | +``` |
| 18 | +~~~~ |
| 19 | + |
| 20 | +### tag |
| 21 | +Tags are used to define what swagger files are used in specific client SDK. In Single-API client, only one tag can be used to generate SDK client. |
| 22 | +A tag can contains a bunch of swagger files which are used to generate the SDK. |
| 23 | + |
| 24 | +The name of a tag should be in form of package-yyyy-mm-dd[-xxx], for example below tag names are available: |
| 25 | +- package-2020-02-03 |
| 26 | +- package-2020-03-22-preview |
| 27 | +- package-2020-05-03-only |
| 28 | + |
| 29 | +while the below tag names are invalid names: |
| 30 | +- 2020-03-04 |
| 31 | +- package-preview-2020-03-04 |
| 32 | + |
| 33 | +A tag can be configured like below: |
| 34 | +~~~~ |
| 35 | +// file: readme.md |
| 36 | +
|
| 37 | +
|
| 38 | +### Tag: package-2019-12-01 |
| 39 | +
|
| 40 | +These settings apply only when `--tag=package-2019-12-01` is specified on the command line. |
| 41 | +
|
| 42 | +``` yaml $(tag) == 'package-2019-12-01' |
| 43 | +input-file: |
| 44 | +- Microsoft.Compute/stable/2019-12-01/compute.json |
| 45 | +- Microsoft.Compute/stable/2019-12-01/runCommands.json |
| 46 | +- Microsoft.Compute/stable/2019-12-01/gallery.json |
| 47 | +``` |
| 48 | +~~~~ |
| 49 | + |
| 50 | + |
| 51 | +## Swagger to SDK |
| 52 | +To make Azure SDK for Javascript (Typescript) can be generated from the tag, swagger-to-sdk need to be configured: |
| 53 | + |
| 54 | +~~~ |
| 55 | +// file: readme.md |
| 56 | +
|
| 57 | +## Swagger to SDK |
| 58 | +
|
| 59 | +This section describes what SDK should be generated by the automatic system. |
| 60 | +This is not used by Autorest itself. |
| 61 | +
|
| 62 | +``` yaml $(swagger-to-sdk) |
| 63 | +swagger-to-sdk: |
| 64 | + - repo: azure-sdk-for-js |
| 65 | + - ... |
| 66 | +
|
| 67 | +
|
| 68 | +## Typescript |
| 69 | +
|
| 70 | +See configuration in [readme.typescript.md](./readme.typescript.md) |
| 71 | +~~~ |
| 72 | + |
| 73 | +## Typescript Configuration |
| 74 | +Typescript dedicated configurations are configured in readme.typescript.md. |
| 75 | +the typical package-name is usually like `@azure/arm-xxx` where the xxx is related with the service name. |
| 76 | +and the typical output-folder in the azure-sdk-for-js is like `$(typescript-sdks-folder)/sdk/xxx/arm-xxx` where the xxx is related with the service name. |
| 77 | +A typical readme.typescript.md is like this: |
| 78 | +~~~ |
| 79 | +// file: readme.typescript.md |
| 80 | +
|
| 81 | +## TypeScript |
| 82 | +
|
| 83 | +These settings apply only when `--typescript` is specified on the command line. |
| 84 | +Please also specify `--typescript-sdks-folder=<path to root folder of your azure-sdk-for-js clone>`. |
| 85 | +
|
| 86 | +``` yaml $(typescript) |
| 87 | +typescript: |
| 88 | + azure-arm: true |
| 89 | + package-name: "@azure/arm-apimanagement" |
| 90 | + output-folder: "$(typescript-sdks-folder)/sdk/apimanagement/arm-apimanagement" |
| 91 | + clear-output-folder: true |
| 92 | + generate-metadata: true |
| 93 | +``` |
| 94 | +
|
| 95 | +~~~ |
| 96 | + |
| 97 | +## Multi-api |
| 98 | +Currently the Azure SDK for Javascript (Typescript) doesn't support multi-api which means each operation contained in one package should only contains one api-version's. and Azure SDK for Javascript (Typescript) only supports single api package. |
| 99 | + |
| 100 | +## Multi-packages |
| 101 | +The batch is a tag list which are used in the one RP has multi-package scenarios. For example, |
| 102 | +the Resources RP has several independent packages like features, lock, policy. |
| 103 | +First of all, you need to have different yaml block for each package to define the default tag for that specific package. |
| 104 | +~~~ |
| 105 | +// file: readme.md |
| 106 | +## Configuration |
| 107 | +
|
| 108 | +### Basic Information |
| 109 | +
|
| 110 | +These are the global settings for the Resource API. |
| 111 | +
|
| 112 | +``` yaml |
| 113 | +openapi-type: arm |
| 114 | +``` |
| 115 | +
|
| 116 | +``` yaml $(package-features) |
| 117 | +tag: package-features-2015-12 |
| 118 | +``` |
| 119 | +
|
| 120 | +``` yaml $(package-locks) |
| 121 | +tag: package-locks-2016-09 |
| 122 | +``` |
| 123 | +
|
| 124 | +``` yaml $(package-policy) |
| 125 | +tag: package-policy-2019-09 |
| 126 | +``` |
| 127 | +
|
| 128 | +``` yaml $(package-resources) |
| 129 | +tag: package-resources-2020-06 |
| 130 | +``` |
| 131 | +
|
| 132 | +~~~ |
| 133 | +Then for each default tag, you can define the input swagger like normal tag. |
| 134 | +~~~ |
| 135 | +
|
| 136 | +### Tag: package-features-2015-12 |
| 137 | +
|
| 138 | +These settings apply only when `--tag=package-features-2015-12` is specified on the command line. |
| 139 | +
|
| 140 | +``` yaml $(tag) == 'package-features-2015-12' |
| 141 | +input-file: |
| 142 | +- Microsoft.Features/stable/2015-12-01/features.json |
| 143 | +``` |
| 144 | +
|
| 145 | +### Tag: package-locks-2016-09 |
| 146 | +
|
| 147 | +These settings apply only when `--tag=package-locks-2016-09` is specified on the command line. |
| 148 | +
|
| 149 | +``` yaml $(tag) == 'package-locks-2016-09' |
| 150 | +input-file: |
| 151 | +- Microsoft.Authorization/stable/2016-09-01/locks.json |
| 152 | +``` |
| 153 | +
|
| 154 | +### Tag: package-policy-2019-09 |
| 155 | +
|
| 156 | +These settings apply only when `--tag=package-policy-2019-09` is specified on the command line. |
| 157 | +
|
| 158 | +``` yaml $(tag) == 'package-policy-2019-09' |
| 159 | +input-file: |
| 160 | +- Microsoft.Authorization/stable/2019-09-01/policyAssignments.json |
| 161 | +- Microsoft.Authorization/stable/2019-09-01/policyDefinitions.json |
| 162 | +- Microsoft.Authorization/stable/2019-09-01/policySetDefinitions.json |
| 163 | +
|
| 164 | +# Needed when there is more than one input file |
| 165 | +override-info: |
| 166 | + title: PolicyClient |
| 167 | +``` |
| 168 | +
|
| 169 | +### Tag: package-resources-2020-06 |
| 170 | +
|
| 171 | +These settings apply only when `--tag=package-resources-2020-06` is specified on the command line. |
| 172 | +
|
| 173 | +``` yaml $(tag) == 'package-resources-2020-06' |
| 174 | +input-file: |
| 175 | +- Microsoft.Resources/stable/2020-06-01/resources.json |
| 176 | +``` |
| 177 | +~~~ |
| 178 | + |
| 179 | +Finally, in your readme.typescript.md you should include what packages you want to include in the Azure SDK for Javascript (Typescript). |
| 180 | +And in each package's section define the default package name output folder in azure-sdk-for-js repo etc. |
| 181 | + |
| 182 | +~~~ |
| 183 | +## TypeScript |
| 184 | +
|
| 185 | +These settings apply only when `--typescript` is specified on the command line. |
| 186 | +Please also specify `--typescript-sdks-folder=<path to root folder of your azure-sdk-for-js clone>`. |
| 187 | +
|
| 188 | +```yaml $(typescript) && !$(profile) |
| 189 | +typescript: |
| 190 | + azure-arm: true |
| 191 | + batch: true |
| 192 | + generate-metadata: true |
| 193 | +batch: |
| 194 | + - package-features: true |
| 195 | + - package-locks: true |
| 196 | + - package-policy: true |
| 197 | + - package-resources: true |
| 198 | +``` |
| 199 | +
|
| 200 | +```yaml $(typescript) && $(package-features) && !$(profile) |
| 201 | +typescript: |
| 202 | + package-name: "@azure/arm-features" |
| 203 | + output-folder: "$(typescript-sdks-folder)/sdk/features/arm-features" |
| 204 | + clear-output-folder: true |
| 205 | +``` |
| 206 | +
|
| 207 | +```yaml $(typescript) && $(package-locks) && !$(profile) |
| 208 | +typescript: |
| 209 | + package-name: "@azure/arm-locks" |
| 210 | + output-folder: "$(typescript-sdks-folder)/sdk/locks/arm-locks" |
| 211 | + clear-output-folder: true |
| 212 | +``` |
| 213 | +
|
| 214 | +```yaml $(typescript) && $(package-policy) && !$(profile) |
| 215 | +typescript: |
| 216 | + package-name: "@azure/arm-policy" |
| 217 | + output-folder: "$(typescript-sdks-folder)/sdk/policy/arm-policy" |
| 218 | + clear-output-folder: true |
| 219 | +``` |
| 220 | +
|
| 221 | +```yaml $(typescript) && $(package-resources) && !$(profile) |
| 222 | +typescript: |
| 223 | + package-name: "@azure/arm-resources" |
| 224 | + output-folder: "$(typescript-sdks-folder)/sdk/resources/arm-resources" |
| 225 | + clear-output-folder: true |
| 226 | +``` |
| 227 | +
|
| 228 | +~~~ |
| 229 | + |
| 230 | + |
| 231 | +## Run codegen |
| 232 | +After configure all the readme files, autorest can be used to generate SDK. |
| 233 | +~~~ |
| 234 | +autorest --typescript --typescript-sdks-folder=/home/qiaozha/code/azure-sdk-for-js --license-header=MICROSOFT_MIT_NO_VERSION /home/qiaozha/code/azure-rest-api-specs/specification/storage/resource-manager/readme.md [email protected]/[email protected] |
| 235 | +~~~ |
0 commit comments