openapi2jsonschema_ng


Nameopenapi2jsonschema_ng JSON
Version 0.9.0 PyPI version JSON
download
home_pagehttps://gitlab.com/nirvati/openapi2jsonschema
SummaryA utility to extract JSON Schema from a valid OpenAPI specification
upload_time2023-10-02 05:45:11
maintainer
docs_urlNone
authorGareth Rushgrove
requires_python>=3.8,<4.0
licenseApache-2.0
keywords openapi jsonschema
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            This is a fork of openapi2jsonschema that can be installed for modern Python.
It still exposes the same interface, and the executable is still called `openapi2jsonschema`.

---

# openapi2jsonschema

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


## 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

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

```
pip install openapi2jsonschema-ng
```

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 `openapi2jsonschema` tool at a URL
containing a JSON (or YAML) OpenAPI definition like so:

```
openapi2jsonschema 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:

```
$ openapi2jsonschema --help
Usage: openapi2jsonschema [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 usecase 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).


            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/nirvati/openapi2jsonschema",
    "name": "openapi2jsonschema_ng",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "openapi,jsonschema",
    "author": "Gareth Rushgrove",
    "author_email": "gareth@morethanseven.net",
    "download_url": "https://files.pythonhosted.org/packages/80/81/5802c989a00031c9912062bcbaa696826a2be366cfe4d5f16b9542b67e99/openapi2jsonschema_ng-0.9.0.tar.gz",
    "platform": null,
    "description": "This is a fork of openapi2jsonschema that can be installed for modern Python.\nIt still exposes the same interface, and the executable is still called `openapi2jsonschema`.\n\n---\n\n# openapi2jsonschema\n\nA utility to extract [JSON Schema](http://json-schema.org/) from a\nvalid [OpenAPI](https://www.openapis.org/) specification.\n\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\n## Installation\n\n`openapi2jsonschema` is implemented in Python. Assuming you have a\nPython intepreter and pip installed you should be able to install with:\n\n```\npip install openapi2jsonschema-ng\n```\n\nThis has not yet been widely tested and is currently in a _works on my\nmachine_ state.\n\n\n## Usage\n\nThe simplest usage is to point the `openapi2jsonschema` tool at a URL\ncontaining a JSON (or YAML) OpenAPI definition like so:\n\n```\nopenapi2jsonschema 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```\n$ openapi2jsonschema --help\nUsage: openapi2jsonschema [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\n## Example\n\nMy specific usecase 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",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A utility to extract JSON Schema from a valid OpenAPI specification",
    "version": "0.9.0",
    "project_urls": {
        "Homepage": "https://gitlab.com/nirvati/openapi2jsonschema",
        "Repository": "https://gitlab.com/nirvati/openapi2jsonschema"
    },
    "split_keywords": [
        "openapi",
        "jsonschema"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc112a87ac20359853893f73e3c5025ce314860c5d01014fb1e062a832a80e34",
                "md5": "aa133bea76af1b90f3327a1c12e6ccce",
                "sha256": "566925f0146330f7682519c3830bfeccfc4f550a0233938156ae2b0a68131a56"
            },
            "downloads": -1,
            "filename": "openapi2jsonschema_ng-0.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "aa133bea76af1b90f3327a1c12e6ccce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 8099,
            "upload_time": "2023-10-02T05:45:10",
            "upload_time_iso_8601": "2023-10-02T05:45:10.368792Z",
            "url": "https://files.pythonhosted.org/packages/fc/11/2a87ac20359853893f73e3c5025ce314860c5d01014fb1e062a832a80e34/openapi2jsonschema_ng-0.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80815802c989a00031c9912062bcbaa696826a2be366cfe4d5f16b9542b67e99",
                "md5": "2b3b139c2a889208f7ef12ae1c8458b7",
                "sha256": "adfa05ca96fb62ee9335d2a668644a2d9c9d9722cb4ccdad4f31b077e089fe7f"
            },
            "downloads": -1,
            "filename": "openapi2jsonschema_ng-0.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2b3b139c2a889208f7ef12ae1c8458b7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 5935,
            "upload_time": "2023-10-02T05:45:11",
            "upload_time_iso_8601": "2023-10-02T05:45:11.995674Z",
            "url": "https://files.pythonhosted.org/packages/80/81/5802c989a00031c9912062bcbaa696826a2be366cfe4d5f16b9542b67e99/openapi2jsonschema_ng-0.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-02 05:45:11",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "nirvati",
    "gitlab_project": "openapi2jsonschema",
    "lcname": "openapi2jsonschema_ng"
}
        
Elapsed time: 0.12127s