Skip to content

Instantly share code, notes, and snippets.

@Dr-Emann
Last active December 17, 2015 21:18
Show Gist options
  • Save Dr-Emann/5673379 to your computer and use it in GitHub Desktop.
Save Dr-Emann/5673379 to your computer and use it in GitHub Desktop.
Haxelib.json schema. Written in [json-schema](http://json-schema.org/)
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "A haxelib project",
"type": "object",
"properties": {
"name": { "$ref": "#/definitions/name" },
"license": {
"description": "The open source license under which the project is licensed",
"enum": ["GPL", "LGPL", "BSD", "Public", "MIT"]
},
"tags": {
"type": "array",
"items": {
"type": "string",
"minLength": 2
},
"uniqueItems": true
},
"description": {
"type": "string",
"minLength": 2
},
"contributors": {
"type": "array",
"items": { "$ref": "#/definitions/name" },
"minItems": 1,
"uniqueItems": true
},
"releasenote": {
"type": "string",
"minLength": 2
},
"version": { "$ref": "#/definitions/semver" },
"url": {
"type": "string",
"format": "uri"
},
"dependencies": {
"type": "object",
"additionalProperties": { "$ref": "#/definitions/dependancyVersion" }
}
},
"additionalProperties": false,
"required": ["name", "license", "description", "releasenote", "contributors", "version"],
"definitions": {
"name": {
"description": "The name of a haxelib project",
"type": "string",
"minLength": 3,
"pattern": "[A-Za-z0-9_.-]{3,}"
},
"semver": {
"type": "string",
"pattern": "^([0-9]+)\\.([0-9]+)\\.([0-9]+)(-(alpha|beta|rc)(\\.([0-9]+))?)?$"
},
"dependancyVersion": {
"oneOf": [
{ "$ref": "#/definitions/semver" },
{
"type": "string",
"maxLength": 0
}
]
}
}
}
@Dr-Emann
Copy link
Author

Dr-Emann commented Jun 3, 2013

Made a few changes, dependencies are allowed to use empty strings to not require a specific version and the regex for a haxelib project name used - in the wrong spot (it was being interpreted as a range, instead of a literal dash.

I found a nice validator for javascript here. It looks like it wouldn't be too hard to port to Haxe, and it already supports v4 of the JSON-Schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment