Skip to content

Instantly share code, notes, and snippets.

@mikepatrick
Created December 27, 2017 21:45
Show Gist options
  • Save mikepatrick/34ce459662c8e827653a0badfaa27f08 to your computer and use it in GitHub Desktop.
Save mikepatrick/34ce459662c8e827653a0badfaa27f08 to your computer and use it in GitHub Desktop.
json schema to typescript demo
{
"id":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"$schema":"http://json-schema.org/draft-04/schema#",
"title":"Template",
"description":"An Azure deployment template",
"type":"object",
"properties":{
"$schema":{
"type":"string",
"description":"JSON schema reference"
},
"contentVersion":{
"type":"string",
"pattern":"(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)",
"description":"A 4 number format for the version number of this template file. For example, 1.0.0.0"
},
"variables":{
"type":"object",
"description":"Variable definitions"
},
"parameters":{
"type":"object",
"description":"Input parameter definitions",
"additionalProperties":{
"$ref":"#/definitions/parameter"
}
},
"resources":{
"type":"array",
"description":"Collection of resources to be deployed",
"items":{
"oneOf":[
{
"allOf":[
{
"$ref":"#/definitions/resourceBase"
},
{
"oneOf":[
{
"$ref":"https://schema.management.azure.com/schemas/2017-09-01-preview/Microsoft.DataFactory.json#/resourceDefinitions/factories"
}
]
}
]
},
{
"allOf":[
{
"$ref":"#/definitions/resourceBaseExternal"
},
{
"oneOf":[
{
"$ref":"https://schema.management.azure.com/schemas/2014-04-01/SuccessBricks.ClearDB.json#/resourceDefinitions/databases"
},
{
"$ref":"https://schema.management.azure.com/schemas/2015-01-01/Sendgrid.Email.json#/resourceDefinitions/accounts"
}
]
}
]
},
{
"allOf":[
{
"$ref":"#/definitions/ARMResourceBase"
},
{
"oneOf":[
{
"$ref":"https://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/resourceDefinitions/deployments"
},
{
"$ref":"https://schema.management.azure.com/schemas/2016-02-01/Microsoft.Resources.json#/resourceDefinitions/deployments"
},
{
"$ref":"https://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/resourceDefinitions/links"
},
{
"$ref":"https://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json#/resourceDefinitions/locks"
},
{
"$ref":"https://schema.management.azure.com/schemas/2014-10-01-preview/Microsoft.Authorization.json#/resourceDefinitions/roleAssignments"
}
]
}
]
}
]
}
},
"outputs":{
"type":"object",
"description":"Output parameter definitions",
"additionalProperties":{
"$ref":"#/definitions/output"
}
}
},
"additionalProperties":false,
"required":[
"$schema",
"contentVersion",
"resources"
],
"definitions":{
"ARMResourceBase":{
"type":"object",
"properties":{
"name":{
"type":"string",
"description":"Name of the resource"
},
"type":{
"type":"string",
"description":"Resource type"
},
"condition":{
"oneOf":[
{
"type":"boolean"
},
{
"$ref":"#/definitions/expression"
}
],
"description":"Condition of the resource"
},
"apiVersion":{
"type":"string",
"description":"API Version of the resource type"
},
"dependsOn":{
"type":"array",
"items":{
"type":"string"
},
"description":"Collection of resources this resource depends on"
}
},
"required":[
"name",
"type",
"apiVersion"
]
},
"proxyResourceBase":{
"allOf":[
{
"$ref":"#/definitions/ARMResourceBase"
},
{
"properties":{
"location":{
"$ref":"#/definitions/resourceLocations",
"description":"Location to deploy resource to"
}
}
}
]
},
"resourceBase":{
"allOf":[
{
"$ref":"#/definitions/ARMResourceBase"
},
{
"properties":{
"location":{
"$ref":"#/definitions/resourceLocations",
"description":"Location to deploy resource to"
},
"tags":{
"type":"object",
"description":"Name-value pairs to add to the resource"
},
"copy":{
"$ref":"#/definitions/resourceCopy"
},
"comments":{
"type":"string"
}
}
}
]
},
"resourceBaseExternal":{
"$ref":"#/definitions/resourceBase",
"required":[
"plan"
]
},
"resourceSku":{
"type":"object",
"properties":{
"name":{
"type":"string",
"description":"Name of the sku"
},
"tier":{
"type":"string",
"description":"Tier of the sku"
},
"size":{
"type":"string",
"description":"Size of the sku"
},
"family":{
"type":"string",
"description":"Family of the sku"
},
"capacity":{
"type":"integer",
"description":"Capacity of the sku"
}
},
"required":[
"name"
]
},
"resourceCopy":{
"type":"object",
"properties":{
"name":{
"type":"string",
"description":"Name of the copy"
},
"count":{
"oneOf":[
{
"$ref":"#/definitions/expression"
},
{
"type":"integer"
}
],
"description":"Count of the copy"
},
"mode":{
"type":"string",
"enum":[
"Parallel",
"Serial"
],
"description":"The copy mode"
},
"batchSize":{
"oneOf":[
{
"$ref":"#/definitions/expression"
},
{
"type":"integer"
}
],
"description":"The serial copy batch size"
}
}
},
"resourceKind":{
"type":"string",
"maxLength":64,
"pattern":"(^[a-zA-Z0-9_.()-]+$)",
"description":"Kind of resource"
},
"resourcePlan":{
"type":"object",
"properties":{
"name":{
"type":"string",
"description":"Name of the plan"
},
"promotionCode":{
"type":"string",
"description":"Plan promotion code"
},
"publisher":{
"type":"string",
"description":"Name of the publisher"
},
"product":{
"type":"string",
"description":"Name of the product"
},
"version":{
"type":"string",
"description":"Version of the product"
}
},
"required":[
"name"
],
"description":"Plan of the resource"
},
"resourceLocations":{
"anyOf":[
{
"type":"string"
},
{
"enum":[
"East Asia",
"Southeast Asia",
"Central US",
"East US",
"East US 2",
"West US",
"North Central US",
"South Central US",
"North Europe",
"West Europe",
"Japan West",
"Japan East",
"Brazil South",
"Australia East",
"Australia Southeast",
"Central India",
"West India",
"South India",
"Canada Central",
"Canada East",
"West Central US",
"West US 2",
"UK South",
"UK West",
"Korea Central",
"Korea South",
"global"
]
}
]
},
"parameter":{
"type":"object",
"properties":{
"type":{
"$ref":"#/definitions/parameterTypes",
"description":"Type of input parameter"
},
"defaultValue":{
"$ref":"#/definitions/parameterValueTypes",
"description":"Default value to be used if one is not provided"
},
"allowedValues":{
"type":"array",
"description":"Value can only be one of these values"
},
"metadata":{
"type":"object",
"description":"Metadata for the parameter, can be any valid JSON object"
},
"minValue":{
"type":"integer",
"description":"Minimum value for the int type parameter"
},
"maxValue":{
"type":"integer",
"description":"Maximum value for the int type parameter"
},
"minLength":{
"type":"integer",
"description":"Minimum length for the string or array type parameter"
},
"maxLength":{
"type":"integer",
"description":"Maximum length for the string or array type parameter"
}
},
"required":[
"type"
],
"description":"Input parameter definitions"
},
"output":{
"type":"object",
"properties":{
"type":{
"$ref":"#/definitions/parameterTypes",
"description":"Type of output value"
},
"value":{
"$ref":"#/definitions/parameterValueTypes",
"description":"Value assigned for output"
}
},
"required":[
"type",
"value"
],
"description":"Set of output parameters"
},
"parameterTypes":{
"enum":[
"string",
"securestring",
"int",
"bool",
"object",
"secureObject",
"array"
]
},
"parameterValueTypes":{
"type":[
"string",
"boolean",
"integer",
"number",
"object",
"array",
"null"
]
},
"keyVaultReference":{
"type":"object",
"properties":{
"keyVault":{
"type":"object",
"properties":{
"id":{
"type":"string",
"minLength":1
}
},
"required":[
"id"
],
"additionalProperties":false
},
"secretName":{
"type":"string",
"minLength":1
},
"secretVersion":{
"type":"string",
"minLength":1
}
},
"required":[
"keyVault",
"secretName"
],
"additionalProperties":false
},
"expression":{
"type":"string",
"pattern":"^\\[(json|if|and|or|not|concat|parameters|variables|deployment|reference|resourceId|resourceGroup|subscription|list.*|base64|providers|copyIndex|padLeft|replace|toLower|toUpper|startsWith|endsWith|length|split|skip|take|contains|intersection|union|first|last|indexOf|lastIndexOf|add|sub|mul|div|mod|min|max|range|string|int|float|bool|trim|uri|uniqueString|substring|base64ToString|base64ToJson|uriComponentToString|uriComponent|dataUriToString|dataUri|array|createArray|coalesce|empty|less|lessOrEquals|greater|greaterOrEquals|equals)\\(.*\\).*\\]$",
"description":"Deployment template expression. Expressions are enclosed in [] and must start with a function of json(), if(), and(), or(), not(), concat(), parameters(), variables(), deployment(), reference(), resourceId(), resourceGroup(), subscription(), list*(), base64(), providers(), copyIndex(), padLeft(), replace(), toLower(), toUpper(), length(), split(), skip(), take(), add(), sub(), mul(), div(), mod(), string(), int(), trim(), uri(), uniqueString(), substring(), empty(), contains(), intersection(), union(), first(), last(), indexOf(), lastIndexOf(), startsWith(), endsWith(), min(), max(), range(), base64ToString(), base64ToJson(), uriComponentToString(), uriComponent(), dataUriToString(), dataUri(), array(), createArray(), coalesce(), float(), bool(), less(), lessOrEquals(), greater(), greaterOrEquals(), equals()"
},
"numberOrExpression":{
"oneOf":[
{
"type":"number"
},
{
"$ref":"#/definitions/expression"
}
]
},
"Iso8601Duration":{
"type":"string",
"pattern":"^P(\\d+Y)?(\\d+M)?(\\d+D)?(T(((\\d+H)(\\d+M)?(\\d+(\\.\\d{1,2})?S)?)|((\\d+M)(\\d+(\\.\\d{1,2})?S)?)|((\\d+(\\.\\d{1,2})?S))))?$"
},
"UTC":{
"type":"string",
"pattern":"^\\d{4}(-(0[1-9]|1[0-2])(-([012]\\d|3[01])(T((([01]\\d|2[0123]):[0-5]\\d)|(24:00))(:(([0-5]\\d)|60)(\\.\\d{1,}){0,1}){0,1}){0,1}((Z)|([+-]((([01]\\d|2[0123]):[0-5]\\d)|(24:00)))){0,1}){0,1}){0,1}$"
},
"apiVersion":{
"type":"string",
"pattern":"(^((\\d\\d\\d\\d-\\d\\d-\\d\\d)|([0-9]+(\\.[0-9]+)?))(-[a-zA-Z][a-zA-Z0-9]*)?$)",
"description":"API version of the resource type"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment