<commit_before>formencode_jsonschema
=====================

Converts [formencode](http://www.formencode.org/en/latest/)'s schema to
[JSON Schema](http://json-schema.org/)
using [Marshmallow](https://marshmallow.readthedocs.org/en/latest/).

How to use it
-------------

You can use it like this.

```python
>>> from myproject.schemas import SomeFormencodeSchema
>>> from formencode_jsonschema import JSONSchema
>>> json_schema = JSONSchema()
>>> formencode_schema = SomeFormencodeSchema()
>>> result = json_schema.dump(formencode_schema)
>>> result.data
{
	"type": "object",
	"required": ["foo", ...],
    "properties": {
    	"foo": {
        	"type": "string"
        },
        "bar": ...
    }
}
```

Typed validator
---------------

You can explicitly define validator as JSON typed validator.

```python
from formencode import Schame, validators as v
from formencode_jsonschema import typed, JSONSchema


class SomeFormencodeSchema(Schema):
    foo = typed.BooleanTyped(v.UnicodeString(), required=False)
    bar = typed.JSONTyped({
    	"type": "string",
    }, v.Int())
```

```python
>>> json_schema = JSONSchema()
>>> formencode_schema = SomeFormencodeSchema()
>>> result = json_schema.dump(formencode_schema)
>>> result.data
{
	"type": "object",
	"required": ["bar"],
    "properties": {
    	"foo": {
        	"type": "boolean"
        },
        "bar": {
        	"type": "string"
        }
    }
}
```
<commit_msg>Add link to RTD<commit_after>formencode_jsonschema
=====================

Converts [formencode](http://www.formencode.org/en/latest/)'s schema to
[JSON Schema](http://json-schema.org/)
using [Marshmallow](https://marshmallow.readthedocs.org/en/latest/).

How to use it
-------------

You can use it like this.

```python
>>> from myproject.schemas import SomeFormencodeSchema
>>> from formencode_jsonschema import JSONSchema
>>> json_schema = JSONSchema()
>>> formencode_schema = SomeFormencodeSchema()
>>> result = json_schema.dump(formencode_schema)
>>> result.data
{
	"type": "object",
	"required": ["foo", ...],
    "properties": {
    	"foo": {
        	"type": "string"
        },
        "bar": ...
    }
}
```

Typed validator
---------------

You can explicitly define validator as JSON typed validator.

```python
from formencode import Schame, validators as v
from formencode_jsonschema import typed, JSONSchema


class SomeFormencodeSchema(Schema):
    foo = typed.BooleanTyped(v.UnicodeString(), required=False)
    bar = typed.JSONTyped({
    	"type": "string",
    }, v.Int())
```

```python
>>> json_schema = JSONSchema()
>>> formencode_schema = SomeFormencodeSchema()
>>> result = json_schema.dump(formencode_schema)
>>> result.data
{
	"type": "object",
	"required": ["bar"],
    "properties": {
    	"foo": {
        	"type": "boolean"
        },
        "bar": {
        	"type": "string"
        }
    }
}
```

Documentation
-------------

Document of formencode_jsonshcmea is hosted on [RTD](http://formencode-jsonschema.readthedocs.org/).

{'fraction_non_alphanumeric': 0.19237203077952492, 'fraction_numerical': 0.0, 'mean_word_length': 3.339622641509434, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 63, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4242076', 'n_tokens_mistral': 958, 'n_tokens_neox': 949, 'n_words': 205}