openapi2jsonschema2


Nameopenapi2jsonschema2 JSON
Version 1.1.5 PyPI version JSON
download
home_pagehttps://github.com/cam3ron2/openapi2jsonschema2
SummaryA utility to extract JSON Schema from a valid OpenAPI specification
upload_time2024-12-13 20:51:11
maintainerNone
docs_urlNone
authorGareth Rushgrove
requires_python<4.0,>=3.9
licenseMIT
keywords openapi jsonschema kubeconform
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- Space: CLDCOE -->
<!-- Parent: NIQ Managed Actions -->
<!-- Type: page -->
<!-- Layout: article -->
# openapi2jsonschema2
<!-- Include: disclaimer.tmpl -->
<!-- Include: ac:toc -->

A utility to extract [JSON Schema](http://json-schema.org/) from a
valid [OpenAPI](https://www.openapis.org/) specification.

> Forked and updated from [openapi2jsonschema](https://github.com/instrumenta/openapi2jsonschema). The original project does not appear to be maintained. All credit to the original authors.

## Why

OpenAPI contains a list of type `definitions` using a superset of JSON
Schema. These are used internally by various OpenAPI compatible tools. I
found myself however wanting to use those schemas separately, outside
existing OpenAPI tooling. Generating separate schemas for types defined
in OpenAPI allows for all sorts of indepent tooling to be build which
can be easily maintained, because the canonical definition is shared.

## Installation

`openapi2jsonschema2` is implemented in Python. Assuming you have a
Python intepreter and pip installed you should be able to install with:

```shell
pip install openapi2jsonschema2
```

This has not yet been widely tested and is currently in a _works on my
machine_ state.

## Usage

The simplest usage is to point the `openapi2jsonschema2` tool at a URL
containing a JSON (or YAML) OpenAPI definition like so:

```shell
openapi2jsonschema2 https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json
```

This will generate a set of schemas in a `schemas` directory. The tool
provides a number of options to modify the output:

```shell
$ openapi2jsonschema2 --help
Usage: openapi2jsonschema2 [OPTIONS] SCHEMA

  Converts a valid OpenAPI specification into a set of JSON Schema files

Options:
  -o, --output PATH  Directory to store schema files
  -p, --prefix TEXT  Prefix for JSON references (only for OpenAPI versions
                     before 3.0)
  --stand-alone      Whether or not to de-reference JSON schemas
  --kubernetes       Enable Kubernetes specific processors
  --strict           Prohibits properties not in the schema
                     (additionalProperties: false)
  --help             Show this message and exit.
```

## Example

My specific use-case was being able to validate a Kubernetes
configuration file without a Kubernetes client like `kubectl` and
without the server. For that I have a bash script,
[available here](https://github.com/instrumenta/kubernetes-json-schema/blob/master/build.sh).

The output from running this script can be seen in the accompanying
[instrumenta/kubernetes-json-schema](https://github.com/instrumenta/kubernetes-json-schema).

<!-- Include: footer.tmpl -->

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/cam3ron2/openapi2jsonschema2",
    "name": "openapi2jsonschema2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "openapi, jsonschema, kubeconform",
    "author": "Gareth Rushgrove",
    "author_email": "gareth@morethanseven.net",
    "download_url": "https://files.pythonhosted.org/packages/0e/fd/a5f72f5f322fdbf546bf5567bbc7e7e9987391b8b50b2b3bd98d37daf0c3/openapi2jsonschema2-1.1.5.tar.gz",
    "platform": null,
    "description": "<!-- Space: CLDCOE -->\n<!-- Parent: NIQ Managed Actions -->\n<!-- Type: page -->\n<!-- Layout: article -->\n# openapi2jsonschema2\n<!-- Include: disclaimer.tmpl -->\n<!-- Include: ac:toc -->\n\nA utility to extract [JSON Schema](http://json-schema.org/) from a\nvalid [OpenAPI](https://www.openapis.org/) specification.\n\n> Forked and updated from [openapi2jsonschema](https://github.com/instrumenta/openapi2jsonschema). The original project does not appear to be maintained. All credit to the original authors.\n\n## Why\n\nOpenAPI contains a list of type `definitions` using a superset of JSON\nSchema. These are used internally by various OpenAPI compatible tools. I\nfound myself however wanting to use those schemas separately, outside\nexisting OpenAPI tooling. Generating separate schemas for types defined\nin OpenAPI allows for all sorts of indepent tooling to be build which\ncan be easily maintained, because the canonical definition is shared.\n\n## Installation\n\n`openapi2jsonschema2` is implemented in Python. Assuming you have a\nPython intepreter and pip installed you should be able to install with:\n\n```shell\npip install openapi2jsonschema2\n```\n\nThis has not yet been widely tested and is currently in a _works on my\nmachine_ state.\n\n## Usage\n\nThe simplest usage is to point the `openapi2jsonschema2` tool at a URL\ncontaining a JSON (or YAML) OpenAPI definition like so:\n\n```shell\nopenapi2jsonschema2 https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json\n```\n\nThis will generate a set of schemas in a `schemas` directory. The tool\nprovides a number of options to modify the output:\n\n```shell\n$ openapi2jsonschema2 --help\nUsage: openapi2jsonschema2 [OPTIONS] SCHEMA\n\n  Converts a valid OpenAPI specification into a set of JSON Schema files\n\nOptions:\n  -o, --output PATH  Directory to store schema files\n  -p, --prefix TEXT  Prefix for JSON references (only for OpenAPI versions\n                     before 3.0)\n  --stand-alone      Whether or not to de-reference JSON schemas\n  --kubernetes       Enable Kubernetes specific processors\n  --strict           Prohibits properties not in the schema\n                     (additionalProperties: false)\n  --help             Show this message and exit.\n```\n\n## Example\n\nMy specific use-case was being able to validate a Kubernetes\nconfiguration file without a Kubernetes client like `kubectl` and\nwithout the server. For that I have a bash script,\n[available here](https://github.com/instrumenta/kubernetes-json-schema/blob/master/build.sh).\n\nThe output from running this script can be seen in the accompanying\n[instrumenta/kubernetes-json-schema](https://github.com/instrumenta/kubernetes-json-schema).\n\n<!-- Include: footer.tmpl -->\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A utility to extract JSON Schema from a valid OpenAPI specification",
    "version": "1.1.5",
    "project_urls": {
        "Homepage": "https://github.com/cam3ron2/openapi2jsonschema2",
        "Repository": "https://github.com/cam3ron2/openapi2jsonschema2"
    },
    "split_keywords": [
        "openapi",
        " jsonschema",
        " kubeconform"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb8e49ae672b7d99887e0b7a7dff7c8604b769c37da6df356259c6d14297065e",
                "md5": "1ccfec6fa6833332004b67bb665d055b",
                "sha256": "26ca416158969e6fbff5c78bc6795b1d0323b597f3f842de22986901ea174eb2"
            },
            "downloads": -1,
            "filename": "openapi2jsonschema2-1.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1ccfec6fa6833332004b67bb665d055b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 8397,
            "upload_time": "2024-12-13T20:51:09",
            "upload_time_iso_8601": "2024-12-13T20:51:09.182712Z",
            "url": "https://files.pythonhosted.org/packages/cb/8e/49ae672b7d99887e0b7a7dff7c8604b769c37da6df356259c6d14297065e/openapi2jsonschema2-1.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0efda5f72f5f322fdbf546bf5567bbc7e7e9987391b8b50b2b3bd98d37daf0c3",
                "md5": "7a784daa10234256f772b99acf5fe490",
                "sha256": "7febba6a7374e97d00705e0c7fa29fa2b7118a6863f490d70cdd60930e6c4df3"
            },
            "downloads": -1,
            "filename": "openapi2jsonschema2-1.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "7a784daa10234256f772b99acf5fe490",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 6348,
            "upload_time": "2024-12-13T20:51:11",
            "upload_time_iso_8601": "2024-12-13T20:51:11.420846Z",
            "url": "https://files.pythonhosted.org/packages/0e/fd/a5f72f5f322fdbf546bf5567bbc7e7e9987391b8b50b2b3bd98d37daf0c3/openapi2jsonschema2-1.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-13 20:51:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "cam3ron2",
    "github_project": "openapi2jsonschema2",
    "github_not_found": true,
    "lcname": "openapi2jsonschema2"
}
        
Elapsed time: 1.05681s