This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Yet Another Data format Description LanguagE

@role: admin | author | collaborator | "role with space"

user:
  name: str{3,20}
  age: int{10,200}
  gender: male | female
  roles: [@role]
  description?: str{,200}

translated to json-schema

{
  "additionalProperties": false,
  "definitions": {
    "role": {
      "enum": [
        "admin",
        "author",
        "collaborator",
        "role with space"
      ]
    }
  },
  "required": [
    "user"
  ],
  "type": "object",
  "properties": {
    "user": {
      "additionalProperties": false,
      "required": [
        "name",
        "age",
        "gender",
        "roles"
      ],
      "type": "object",
      "properties": {
        "gender": {
          "enum": [
            "male",
            "female"
          ]
        },
        "age": {
          "minimum": 10,
          "type": "integer",
          "maximum": 200
        },
        "name": {
          "minLength": 3,
          "type": "string",
          "maxLength": 20
        },
        "roles": {
          "items": {
            "$ref": "#/definitions/role"
          },
          "type": "array"
        },
        "description": {
          "type": "string",
          "maxLength": 200
        }
      }
    }
  }
}

api

use load/loads to translate yaddle into json-schema

from yaddle import load, loads
load(open("some.ydl"))
loads("""[str]{,3}""")

cli

cat schema.ydl | python -m yaddle.tool

more details

number

int{100,200}
{
    "type": "integer",
    "minimum": 100,
    "maximum": 200
}
num{,,0.1}
{
    "type": "number",
    "multipleOf": 0.1
}

string

str{1,2} /pattern/
{
    "type": "string",
    "minLength": 1,
    "maxLength": 20,
    "pattern": "pattern"
}
/pattern/
{
    "type": "string",
    "pattern": "pattern"
}

format date-time, email, hostname, ipv4, ipv6, uri

%email
{
    "format": "email"
}

array

[str]{1,10}
{
    "type": "array",
    "minItems": 1,
    "maxItems": 10,
    "items": {
        "type": "string"
    }
}
[str|num]
{
    "type": "array",
    "items": {
        oneOf: [
            {"type": "string"},
            {"type": "number"}
        ]
    }
}
[str, num]
{
    "type": "array",
    "items": [
        {"type": "string"},
        {"type": "number"}
    }
}

! for uniqueItems

[num]!
{
    "type": "array",
    "items": {
        {type: "number"}
    },
    "uniqueItems": true
}

object

  • all properties are required, except those one with a ? suffix
  • ... to allow additionalProperties
key: str
size?: number
...
{
    "type": "object",
    "properties": {
        "key": {
            "type": "string"
        },
        "size": {
            "type": "number"
        },
        "required": ["key"]
    }
    "additionalProperties": true
}

oneOf, anyOf, allOf

  • | for oneOf like @ref | @ref2
  • / for anyOf
  • & for allOf

reference

local reference

@address:
    street_address: str
    city: str
    state: str

billing_address: @address
shipping_address: @address
{
  "additionalProperties": false,
  "definitions": {
    "address": {
      "additionalProperties": false,
      "required": [
        "street_address",
        "city",
        "state"
      ],
      "type": "object",
      "properties": {
        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "street_address": {
          "type": "string"
        }
      }
    }
  },
  "required": [
    "billing_address",
    "shipping_address"
  ],
  "type": "object",
  "properties": {
    "billing_address": {
      "$ref": "#/definitions/address"
    },
    "shipping_address": {
      "$ref": "#/definitions/address"
    }
  }
}

referece remote schema(TBD)

@"http://example.com/schema"

@product:
    price: num{0,}
    title: str{,200}

referece it in another schema

@example: "http://example.com/schema"

products: [@example:product]

examples

example from http://json-schema.org/example2.html translated to yaddle

@diskDevice:
    type: disk
    divice: /^/dev/[^/]+(/[^/]+)*$/
@diskUUID:
    type: disk
    label: /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/
@nfs:
    type: nfs
    remotePath: /^(/[^/]+)+$/
    server: %host-name | %ipv4 | %ipv6
@tmpfs:
    type: tmpfs
    sizeInMB: int{16,512}

storage: @diskDevice | @diskUUID | @nfs | @tmpfs
fstype?: ext3 | ext4 | btrfs
options?: [str]{1,}!
readonly?: bool
Release History

Release History

0.0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
yaddle-0.0.2.tar.gz (6.3 kB) Copy SHA256 Checksum SHA256 Source Jul 26, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting