Metadata-Version: 2.1
Name: to-json-schema
Version: 1.0.1
Home-page: https://github.com/zilehuda/to-json-schema/
Author: zilehuda
Author-email: 
License: MIT
Project-URL: Source, https://github.com/zilehuda/to-json-schema/
Project-URL: Tracker, https://github.com/zilehuda/to-json-schema/issues
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Description-Content-Type: text/x-rst; charset=UTF-8
Provides-Extra: testing
License-File: LICENSE.txt

===================
to-json-schema
===================

A simple package that convert dictionary or a list into json-schema using the OpenAPI standards.

Installation
------------

to-json-schema can be installed via ``pip``:

.. code-block:: sh

   $ pip install to-json-schema

Quickstart
----------

You can now convert your python dict into json-schema:

.. code-block:: python

   from to_json_schema.to_json_schema import SchemaBuilder

    data = {
        "country": "Pakistan",
        "city": "Karachi",
        "population": 16051521,
        "is_capital": False,
        "key_qualities": ["food", "multi-cultural"],
    }

    schema_builder = SchemaBuilder()
    json_schema = schema_builder.to_json_schema(data)

    >>> {'type': 'object', 'properties': {'country': {'type': 'string'}, 'city': {'type': 'string'}, 'population': {'type': 'integer'}, 'is_capital': {'type': 'boolean'}, 'key_qualities': {'type': 'array', 'items': {'type': 'string'}}}}

You can also convert list of dict, string, integer into-json schema

.. code-block:: python
    
    from to_json_schema.to_json_schema import SchemaBuilder

    data = [{"foo": 12, "bar": 14}, {"moo": 52, "car": 641}, {"doo": 6, "tar": 84}]

    schema_builder = SchemaBuilder()
    json_schema = schema_builder.to_json_schema(data)
    
    >>> {'type': 'array', 'items': {'type': 'object', 'properties': {'foo': {'type': 'integer'}, 'bar': {'type': 'integer'}, 'moo': {'type': 'integer'}, 'car': {'type': 'integer'}, 'doo': {'type': 'integer'}, 'tar': {'type': 'integer'}}}}

