|
| 1 | +# Code Generation - Azure File SDK for Golang |
| 2 | + |
| 3 | +### Settings |
| 4 | + |
| 5 | +```yaml |
| 6 | +go: true |
| 7 | +clear-output-folder: false |
| 8 | +version: "^3.0.0" |
| 9 | +license-header: MICROSOFT_MIT_NO_VERSION |
| 10 | +input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/bbea558ac43d6ebec72455233c84b0158c89fcda/specification/storage/data-plane/Microsoft.FileStorage/preview/2020-10-02/file.json" |
| 11 | +credential-scope: "https://storage.azure.com/.default" |
| 12 | +output-folder: ../generated |
| 13 | +file-prefix: "zz_" |
| 14 | +openapi-type: "data-plane" |
| 15 | +verbose: true |
| 16 | +security: AzureKey |
| 17 | +modelerfour: |
| 18 | + group-parameters: false |
| 19 | + seal-single-value-enum-by-default: true |
| 20 | + lenient-model-deduplication: true |
| 21 | +export-clients: true |
| 22 | +use: "@autorest/[email protected]" |
| 23 | +``` |
| 24 | +
|
| 25 | +### Don't include share name, directory, or file name in path - we have direct URIs |
| 26 | +
|
| 27 | +``` yaml |
| 28 | +directive: |
| 29 | +- from: swagger-document |
| 30 | + where: $["x-ms-paths"] |
| 31 | + transform: > |
| 32 | + for (const property in $) |
| 33 | + { |
| 34 | + if (property.includes('/{shareName}/{directory}/{fileName}')) |
| 35 | + { |
| 36 | + $[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName") && false == param['$ref'].endsWith("#/parameters/DirectoryPath") && false == param['$ref'].endsWith("#/parameters/FilePath"))}); |
| 37 | + } |
| 38 | + else if (property.includes('/{shareName}/{directory}')) |
| 39 | + { |
| 40 | + $[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName") && false == param['$ref'].endsWith("#/parameters/DirectoryPath"))}); |
| 41 | + } |
| 42 | + else if (property.includes('/{shareName}')) |
| 43 | + { |
| 44 | + $[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ShareName"))}); |
| 45 | + } |
| 46 | + } |
| 47 | +``` |
| 48 | +
|
| 49 | +### Add Last-Modified to SetMetadata |
| 50 | +
|
| 51 | +``` yaml |
| 52 | +directive: |
| 53 | +- from: swagger-document |
| 54 | + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=metadata"] |
| 55 | + transform: > |
| 56 | + $.put.responses["200"].headers["Last-Modified"] = { |
| 57 | + "type": "string", |
| 58 | + "format": "date-time-rfc1123", |
| 59 | + "description": "Returns the date and time the file was last modified. Any operation that modifies the file, including an update of the file's metadata or properties, changes the last-modified time of the file." |
| 60 | + } |
| 61 | +``` |
| 62 | +
|
| 63 | +### Add Content-MD5 to Put Range from URL |
| 64 | +
|
| 65 | +``` yaml |
| 66 | +directive: |
| 67 | +- from: swagger-document |
| 68 | + where: $["x-ms-paths"]["/{shareName}/{directory}/{fileName}?comp=range&fromURL"] |
| 69 | + transform: > |
| 70 | + $.put.responses["201"].headers["Content-MD5"] = { |
| 71 | + "type": "string", |
| 72 | + "format": "byte", |
| 73 | + "description": "This header is returned so that the client can check for message content integrity. The value of this header is computed by the File service; it is not necessarily the same value as may have been specified in the request headers." |
| 74 | + } |
| 75 | +``` |
| 76 | +
|
| 77 | +### ShareServiceProperties, ShareMetrics, ShareCorsRule, and ShareRetentionPolicy |
| 78 | +
|
| 79 | +``` yaml |
| 80 | +directive: |
| 81 | +- rename-model: |
| 82 | + from: Metrics |
| 83 | + to: ShareMetrics |
| 84 | +- rename-model: |
| 85 | + from: CorsRule |
| 86 | + to: ShareCorsRule |
| 87 | +- rename-model: |
| 88 | + from: RetentionPolicy |
| 89 | + to: ShareRetentionPolicy |
| 90 | +- rename-model: |
| 91 | + from: StorageServiceProperties |
| 92 | + to: ShareServiceProperties |
| 93 | + |
| 94 | +- from: swagger-document |
| 95 | + where: $.definitions |
| 96 | + transform: > |
| 97 | + $.ShareMetrics.properties.IncludeAPIs["x-ms-client-name"] = "IncludeApis"; |
| 98 | + $.ShareServiceProperties.xml = {"name": "StorageServiceProperties"}; |
| 99 | + $.ShareCorsRule.xml = {"name": "CorsRule"}; |
| 100 | +- from: swagger-document |
| 101 | + where: $.parameters |
| 102 | + transform: > |
| 103 | + $.StorageServiceProperties.name = "ShareServiceProperties"; |
| 104 | +``` |
| 105 | +
|
| 106 | +### Rename FileHttpHeaders to ShareFileHTTPHeaders and remove file prefix from properties |
| 107 | +
|
| 108 | +``` yaml |
| 109 | +directive: |
| 110 | +- from: swagger-document |
| 111 | + where: $.parameters |
| 112 | + transform: > |
| 113 | + $.FileCacheControl["x-ms-parameter-grouping"].name = "share-file-http-headers"; |
| 114 | + $.FileCacheControl["x-ms-client-name"] = "cacheControl"; |
| 115 | + $.FileContentDisposition["x-ms-parameter-grouping"].name = "share-file-http-headers"; |
| 116 | + $.FileContentDisposition["x-ms-client-name"] = "contentDisposition"; |
| 117 | + $.FileContentEncoding["x-ms-parameter-grouping"].name = "share-file-http-headers"; |
| 118 | + $.FileContentEncoding["x-ms-client-name"] = "contentEncoding"; |
| 119 | + $.FileContentLanguage["x-ms-parameter-grouping"].name = "share-file-http-headers"; |
| 120 | + $.FileContentLanguage["x-ms-client-name"] = "contentLanguage"; |
| 121 | + $.FileContentMD5["x-ms-parameter-grouping"].name = "share-file-http-headers"; |
| 122 | + $.FileContentMD5["x-ms-client-name"] = "contentMd5"; |
| 123 | + $.FileContentType["x-ms-parameter-grouping"].name = "share-file-http-headers"; |
| 124 | + $.FileContentType["x-ms-client-name"] = "contentType"; |
| 125 | +``` |
0 commit comments