Skip to content

Commit

Permalink
Added docs and history.
Browse files Browse the repository at this point in the history
  • Loading branch information
beregond committed Nov 2, 2015
1 parent f034b46 commit a0176ea
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
83 changes: 83 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,89 @@ Features
For more information, please see topic about validation in documentation.

* Lazy loading, best for circular references:

..code-block:: python

class Primary(models.Base):

name = fields.StringField()
secondary = fields.EmbeddedField('Secondary')


class Secondary(models.Base):

data = fields.IntField()
first = fields.EmbeddedField('Primary')

You can use either `Model`, full path `path.to.Model` or relative imports
`.Model` or `...Model`.

* Using definitions to generate schema for circular references:

..code-block:: python

class File(models.Base):

name = fields.StringField()
size = fields.FloatField()


class Directory(models.Base):

name = fields.StringField()
children = fields.ListField(['Directory', File])


class Filesystem(models.Base):

name = fields.StringField()
children = fields.ListField([Directory, File])

>>> Filesystem.to_json_schema()
{
"type": "object",
"properties": {
"name": {"type": "string"}
"children": {
"items": {
"oneOf": [
"#/definitions/directory",
"#/definitions/file"
]
},
"type": "list"
}
},
"additionalProperties": false,
"definitions": {
"directory": {
"additionalProperties": false,
"properties": {
"children": {
"items": {
"oneOf": [
"#/definitions/directory",
"#/definitions/file"
]
},
"type": "list"
},
"name": {"type": "string"}
},
"type": "object"
},
"file": {
"additionalProperties": false,
"properties": {
"name": {"type": "string"},
"size": {"type": "float"}
},
"type": "object"
}
}
}

* Compare JSON schemas:

.. code-block:: python
Expand Down
1 change: 1 addition & 0 deletions history/1446502220344385-053b8c8
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added lazy loading of types.
1 change: 1 addition & 0 deletions history/1446502242966755-885bdb6
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added schema generation for circular models.

0 comments on commit a0176ea

Please sign in to comment.