Skip to content

Commit 0312a78

Browse files
authored
Merge pull request #272 from python-openapi/feature/update-readme
Update README
2 parents 5deb3c2 + 46b9b51 commit 0312a78

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

README.rst

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ openapi-schema-validator
33
************************
44

55
.. image:: https://img.shields.io/pypi/v/openapi-schema-validator.svg
6-
:target: https://pypi.python.org/pypi/openapi-schema-validator
6+
:target: https://pypi.org/project/openapi-schema-validator/
77
.. image:: https://github.com/python-openapi/openapi-schema-validator/actions/workflows/python-tests.yml/badge.svg
88
:target: https://github.com/python-openapi/openapi-schema-validator/actions
99
.. image:: https://img.shields.io/codecov/c/github/python-openapi/openapi-schema-validator/master.svg?style=flat
1010
:target: https://codecov.io/github/python-openapi/openapi-schema-validator?branch=master
1111
.. image:: https://img.shields.io/pypi/pyversions/openapi-schema-validator.svg
12-
:target: https://pypi.python.org/pypi/openapi-schema-validator
12+
:target: https://pypi.org/project/openapi-schema-validator/
1313
.. image:: https://img.shields.io/pypi/format/openapi-schema-validator.svg
14-
:target: https://pypi.python.org/pypi/openapi-schema-validator
14+
:target: https://pypi.org/project/openapi-schema-validator/
1515
.. image:: https://img.shields.io/pypi/status/openapi-schema-validator.svg
16-
:target: https://pypi.python.org/pypi/openapi-schema-validator
16+
:target: https://pypi.org/project/openapi-schema-validator/
1717

1818
About
1919
#####
2020

21-
Openapi-schema-validator is a Python library that validates schema against:
21+
openapi-schema-validator is a Python library that validates schemas against:
2222

2323
* `OpenAPI Schema Specification v3.0 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject>`__ which is an extended subset of the `JSON Schema Specification Wright Draft 00 <http://json-schema.org/>`__.
2424
* `OpenAPI Schema Specification v3.1 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject>`__ which is an extended superset of the `JSON Schema Specification Draft 2020-12 <http://json-schema.org/>`__.
@@ -44,7 +44,7 @@ Alternatively you can download the code and install from the repository:
4444

4545
.. code-block:: console
4646
47-
pip install -e git+https://github.com/python-openapi/openapi-schema-validator.git#egg=openapi_schema_validator
47+
pip install "git+https://github.com/python-openapi/openapi-schema-validator.git"
4848
4949
5050
Usage
@@ -60,6 +60,22 @@ The first argument is always the value you want to validate.
6060
The second argument is always the OpenAPI schema object.
6161
The ``cls`` keyword argument is optional and defaults to ``OAS32Validator``.
6262
Use ``cls`` when you need a specific validator version/behavior.
63+
64+
.. code-block:: python
65+
66+
from openapi_schema_validator import OAS30Validator
67+
from openapi_schema_validator import OAS31Validator
68+
from openapi_schema_validator import validate
69+
70+
# OpenAPI 3.0 behavior
71+
validate(instance, schema, cls=OAS30Validator)
72+
73+
# OpenAPI 3.1 behavior
74+
validate(instance, schema, cls=OAS31Validator)
75+
76+
# OpenAPI 3.2 behavior (default)
77+
validate(instance, schema)
78+
6379
Common forwarded keyword arguments include ``registry`` (reference context)
6480
and ``format_checker`` (format validation behavior).
6581
By default, ``validate`` uses a local-only empty registry to avoid implicit
@@ -111,6 +127,10 @@ To validate an OpenAPI schema:
111127
112128
validate({"name": "John", "city": "London"}, schema)
113129
130+
Expected failure output:
131+
132+
.. code-block:: text
133+
114134
Traceback (most recent call last):
115135
...
116136
ValidationError: Additional properties are not allowed ('city' was unexpected)
@@ -180,35 +200,6 @@ OpenAPI 3.1+ follows JSON Schema semantics for string typing in this library.
180200
- for raw binary payloads, model via media type (for example
181201
``application/octet-stream``) rather than schema string formats
182202

183-
Quick Reference
184-
---------------
185-
186-
.. list-table::
187-
:header-rows: 1
188-
:widths: 28 24 24 24
189-
190-
* - Context
191-
- ``"text"`` (str)
192-
- ``b"text"`` (bytes)
193-
- Notes
194-
* - OAS 3.0 + ``OAS30Validator``
195-
- Pass
196-
- Pass for ``format: binary``
197-
- Compatibility behavior for Python runtime payloads
198-
* - OAS 3.0 + ``OAS30StrictValidator``
199-
- Pass
200-
- Fail
201-
- Strict 3.0 validation mode
202-
* - OAS 3.1 + ``OAS31Validator``
203-
- Pass
204-
- Fail
205-
- Use ``contentEncoding``/``contentMediaType`` and media types
206-
* - OAS 3.2 + ``OAS32Validator``
207-
- Pass
208-
- Fail
209-
- Same semantics as OAS 3.1
210-
211-
212203
Regex Behavior
213204
==============
214205

0 commit comments

Comments
 (0)