cd swagger
autorest README.md [email protected]/[email protected]
gofmt -w Go_BlobStorage/*
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/storage/data-plane/Microsoft.BlobStorage/preview/2020-10-02/blob.json
go: true
output-folder: Go_BlobStorage
namespace: azblob
go-export-clients: false
enable-xml: true
file-prefix: zz_generated_
directive:
- from: swagger-document
where: $["x-ms-paths"]
transform: >
for (const property in $)
{
if (property.includes('/{containerName}/{blob}'))
{
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ContainerName") && false == param['$ref'].endsWith("#/parameters/Blob"))});
}
else if (property.includes('/{containerName}'))
{
$[property]["parameters"] = $[property]["parameters"].filter(function(param) { return (typeof param['$ref'] === "undefined") || (false == param['$ref'].endsWith("#/parameters/ContainerName"))});
}
}
directive:
- from: swagger-document
where: $.definitions
transform: >
$["BlobMetadata"] = {
"type": "object",
"xml": {
"name": "Metadata"
},
"additionalProperties": {
"type": "string"
}
}
directive:
- from: swagger-document
where: $.parameters.ImmutabilityPolicyMode
transform: >
$.enum = [
"mutable",
"unlocked",
"locked"
]
directive:
- from: swagger-document
where: $["x-ms-paths"].*.*.responses.*.headers["x-ms-immutability-policy-mode"]
transform: >
$.enum = [
"mutable",
"unlocked",
"locked"
]
directive:
- from: swagger-document
where: $.definitions.BlobPropertiesInternal.properties.ImmutabilityPolicyMode
transform: >
$.enum = [
"mutable",
"unlocked",
"locked"
]
This does work, it's just not documented, or in the swagger unfortunately. Some directives jank it in.
These directives may need to be removed eventually, once these items are included.
For some reason, permissions gets added 3x, so a check for includes is added.
directive:
- from: swagger-document
where: $.parameters.ListBlobsInclude
transform: >
if (!$.items.enum.includes("permissions"))
$.items.enum.push("permissions")
directive:
- from: swagger-document
where: $.definitions.BlobPropertiesInternal
transform: >
$.properties["Owner"] = {
"type": "string"
};
$.properties["Group"] = {
"type": "string"
};
$.properties["Permissions"] = {
"type": "string"
};
$.properties["Acl"] = {
"type": "string"
};
directive:
- from: swagger-document
where: $["x-ms-paths"].*.*.responses.*.headers["ETag"]
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.definitions.BlobPropertiesInternal.properties.Etag
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.definitions.ContainerProperties.properties.Etag
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.IfMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.IfNoneMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.SourceIfMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $.parameters.SourceIfNoneMatch
transform: >
$.format = "etag"
directive:
- from: swagger-document
where: $["x-ms-paths"].*
transform: >
$.parameters = $.parameters.filter(x => x["$ref"] == undefined || !(x["$ref"] == "#/parameters/ContainerName" || x["$ref"] == "#/parameters/Blob"))
directive:
- from: swagger-document
where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist"]["get"]
transform: >
$.parameters = $.parameters.filter(x => x["$ref"] == undefined || !(x["$ref"] == "#/parameters/Marker" || x["$ref"] == "#/parameters/MaxResults"))
directive:
- from: swagger-document
where: $["x-ms-paths"]["/{containerName}/{blob}?comp=pagelist&diff"]["get"]
transform: >
$.parameters = $.parameters.filter(x => x["$ref"] == undefined || !(x["$ref"] == "#/parameters/Marker" || x["$ref"] == "#/parameters/MaxResults"))