New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonschema-extractor

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonschema-extractor

"a framework to extract jsonschemas from a variety of models."

  • 2.0.2
  • PyPI
  • Socket score

Maintainers
1

==================== jsonschema-extractor

jsonschema-extractor is a library and extensible framework for extracting json schema <http://json-schema.org/>_ from various object and primitives.

.. image:: https://github.com/toumorokoshi/jsonschema-extractor/actions/workflows/python-package.yaml/badge.svg :target: https://github.com/toumorokoshi/jsonschema-extractor/actions/workflows/python-package.yaml

Out of the box support exists for:

  • attrs <https://attrs.readthedocs.io/>_
  • typing <https://docs.python.org/3/library/typing.html>_

Usage

.. code-block:: python

from typing import List
import jsonschema_extractor
assert jsonschema_extractor.extract(List[int]) == {
    "type": "array",
    "items": {"type": "integer"}
}

Attrs-example

.. code-block:: python

import attr
from attr.validators import instance_of
import jsonschema_extractor

@attr.define
class Example(object):
    integer: int = attr.field()
    foo = attr.field(metadata={"jsonschema": {"type": "string", "format": "uuid"}})
    validator_list: List[float] = attr.field()
    string: str = attr.field(
        default="foo",
        metadata={"description": "This is an description."}
    )

assert extractor.extract(Example) == {
    "type": "object",
    "title": "Example",
    "properties": {
        "string": {"description": "This is an description.", "type": "string"},
        "integer": {"type": "integer"},
        "validator_list": {"items": {"type": "number"}, "type": "array"},
        "foo": {"type": "string", "format": "uuid"},
    },
    "required": ["integer", "foo", "validator_list"],
}

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc