Skip to content

Instantly share code, notes, and snippets.

@derekmurawsky
Created July 16, 2025 20:30
Show Gist options
  • Select an option

  • Save derekmurawsky/eeeb98beb34475a721e1ae4ef54d7a2f to your computer and use it in GitHub Desktop.

Select an option

Save derekmurawsky/eeeb98beb34475a721e1ae4ef54d7a2f to your computer and use it in GitHub Desktop.
Example json schema for IPv4 and optional CIDR by reference
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "IPv4 or CIDR Format",
"$defs": {
"ipEntry": {
"type": "object",
"properties": {
"ip": {
"$ref": "#/definitions/ipv4_or_cidr",
"description": "IP address or CIDR range"
},
"active": {
"type": "boolean",
"description": "Indicates if the IP entry is currently in use"
}
},
"required": [
"ip"
]
}
},
"definitions": {
"ipv4_or_cidr": {
"type": "string",
"pattern": "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\\/([0-9]|[1-2][0-9]|3[0-2]))?$",
"description": "An IPv4 or CIDR address"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment