Skip to content

Changed doc indentation from 3 to 4 #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Recommended way (via pip):

.. code-block:: console

pip install openapi-core
pip install openapi-core

Alternatively you can download the code and install from the repository:

.. code-block:: console

pip install -e git+https://github.com/python-openapi/openapi-core.git#egg=openapi_core
pip install -e git+https://github.com/python-openapi/openapi-core.git#egg=openapi_core


First steps
Expand All @@ -61,32 +61,32 @@ Firstly create your specification object.

.. code-block:: python

from openapi_core import Spec
from openapi_core import Spec

spec = Spec.from_file_path('openapi.json')
spec = Spec.from_file_path('openapi.json')

Now you can use it to validate and unmarshal against requests and/or responses.

.. code-block:: python

from openapi_core import unmarshal_request
from openapi_core import unmarshal_request

# raises error if request is invalid
result = unmarshal_request(request, spec=spec)
# raises error if request is invalid
result = unmarshal_request(request, spec=spec)

Retrieve validated and unmarshalled request data

.. code-block:: python

# get parameters
path_params = result.parameters.path
query_params = result.parameters.query
cookies_params = result.parameters.cookies
headers_params = result.parameters.headers
# get body
body = result.body
# get security data
security = result.security
# get parameters
path_params = result.parameters.path
query_params = result.parameters.query
cookies_params = result.parameters.cookies
headers_params = result.parameters.headers
# get body
body = result.body
# get security data
security = result.security

Request object should implement OpenAPI Request protocol. Check `Integrations <https://openapi-core.readthedocs.io/en/latest/integrations.html>`__ to find officially supported implementations.

Expand All @@ -98,15 +98,15 @@ If you just want to validate your request/response data without unmarshalling, r
Related projects
################
* `openapi-spec-validator <https://github.com/python-openapi/openapi-spec-validator>`__
Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification.
Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification.
* `openapi-schema-validator <https://github.com/python-openapi/openapi-schema-validator>`__
Python library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1.
Python library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1.
* `bottle-openapi-3 <https://github.com/cope-systems/bottle-openapi-3>`__
OpenAPI 3.0 Support for the Bottle Web Framework
OpenAPI 3.0 Support for the Bottle Web Framework
* `pyramid_openapi3 <https://github.com/niteoweb/pyramid_openapi3>`__
Pyramid addon for OpenAPI3 validation of requests and responses.
Pyramid addon for OpenAPI3 validation of requests and responses.
* `tornado-openapi3 <https://github.com/correl/tornado-openapi3>`__
Tornado OpenAPI 3 request and response validation library.
Tornado OpenAPI 3 request and response validation library.


License
Expand Down
12 changes: 6 additions & 6 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Install `Poetry <https://python-poetry.org>`__ by following the `official instal

.. code-block:: console

poetry config virtualenvs.in-project true
poetry config virtualenvs.in-project true

Setup
^^^^^
Expand All @@ -42,13 +42,13 @@ To create a development environment and install the runtime and development depe

.. code-block:: console

poetry install
poetry install

Then enter the virtual environment created by Poetry:

.. code-block:: console

poetry shell
poetry shell

Static checks
^^^^^^^^^^^^^
Expand All @@ -59,18 +59,18 @@ To turn on pre-commit checks for commit operations in git, enter:

.. code-block:: console

pre-commit install
pre-commit install

To run all checks on your staged files, enter:

.. code-block:: console

pre-commit run
pre-commit run

To run all checks on all files, enter:

.. code-block:: console

pre-commit run --all-files
pre-commit run --all-files

Pre-commit check results are also attached to your PR through integration with Github Action.
40 changes: 20 additions & 20 deletions docs/customizations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ If you know you have a valid specification already, disabling the validator can
.. code-block:: python
:emphasize-lines: 5

from openapi_core import Spec
from openapi_core import Spec

spec = Spec.from_dict(
spec = Spec.from_dict(
spec_dict,
validator=None,
)
)

Media type deserializers
------------------------
Expand All @@ -28,20 +28,20 @@ You can also define your own ones. Pass custom defined media type deserializers
.. code-block:: python
:emphasize-lines: 13

def protobuf_deserializer(message):
def protobuf_deserializer(message):
feature = route_guide_pb2.Feature()
feature.ParseFromString(message)
return feature

extra_media_type_deserializers = {
extra_media_type_deserializers = {
'application/protobuf': protobuf_deserializer,
}
}

result = unmarshal_response(
result = unmarshal_response(
request, response,
spec=spec,
extra_media_type_deserializers=extra_media_type_deserializers,
)
)

Format validators
-----------------
Expand All @@ -55,20 +55,20 @@ Here's how you could add support for a ``usdate`` format that handles dates of t
.. code-block:: python
:emphasize-lines: 13

import re
import re

def validate_usdate(value):
def validate_usdate(value):
return bool(re.match(r"^\d{1,2}/\d{1,2}/\d{4}$", value))

extra_format_validators = {
extra_format_validators = {
'usdate': validate_usdate,
}
}

validate_response(
validate_response(
request, response,
spec=spec,
extra_format_validators=extra_format_validators,
)
)

Format unmarshallers
--------------------
Expand All @@ -82,17 +82,17 @@ Here's an example with the ``usdate`` format that converts a value to date objec
.. code-block:: python
:emphasize-lines: 13

from datetime import datetime
from datetime import datetime

def unmarshal_usdate(value):
def unmarshal_usdate(value):
return datetime.strptime(value, "%m/%d/%y").date

extra_format_unmarshallers = {
extra_format_unmarshallers = {
'usdate': unmarshal_usdate,
}
}

result = unmarshal_response(
result = unmarshal_response(
request, response,
spec=spec,
extra_format_unmarshallers=extra_format_unmarshallers,
)
)
16 changes: 8 additions & 8 deletions docs/extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ By default, objects are unmarshalled to dictionaries. You can use dynamically cr
.. code-block:: yaml
:emphasize-lines: 5

...
components:
...
components:
schemas:
Coordinates:
x-model: Coordinates
Expand All @@ -35,8 +35,8 @@ You can use your own dataclasses, pydantic models or models generated by third p
.. code-block:: yaml
:emphasize-lines: 5

...
components:
...
components:
schemas:
Coordinates:
x-model-path: foo.bar.Coordinates
Expand All @@ -52,11 +52,11 @@ You can use your own dataclasses, pydantic models or models generated by third p

.. code-block:: python

# foo/bar.py
from dataclasses import dataclass
# foo/bar.py
from dataclasses import dataclass

@dataclass
class Coordinates:
@dataclass
class Coordinates:
lat: float
lon: float

Expand Down
54 changes: 27 additions & 27 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ openapi-core
============

.. toctree::
:hidden:
:maxdepth: 2
:hidden:
:maxdepth: 2

unmarshalling
validation
integrations
customizations
security
extensions
contributing
unmarshalling
validation
integrations
customizations
security
extensions
contributing

Openapi-core is a Python library that adds client-side and server-side support
for the `OpenAPI v3.0 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md>`__
Expand All @@ -30,13 +30,13 @@ Installation

.. md-tab-set::

.. md-tab-item:: Pip + PyPI (recommented)
.. md-tab-item:: Pip + PyPI (recommented)

.. code-block:: console

pip install openapi-core

.. md-tab-item:: Pip + the source
.. md-tab-item:: Pip + the source

.. code-block:: console

Expand All @@ -49,32 +49,32 @@ Firstly create your specification object.

.. code-block:: python

from openapi_core import Spec
from openapi_core import Spec

spec = Spec.from_file_path('openapi.json')
spec = Spec.from_file_path('openapi.json')

Now you can use it to validate and unmarshal your requests and/or responses.

.. code-block:: python

from openapi_core import unmarshal_request
from openapi_core import unmarshal_request

# raises error if request is invalid
result = unmarshal_request(request, spec=spec)
# raises error if request is invalid
result = unmarshal_request(request, spec=spec)

Retrieve validated and unmarshalled request data

.. code-block:: python

# get parameters
path_params = result.parameters.path
query_params = result.parameters.query
cookies_params = result.parameters.cookies
headers_params = result.parameters.headers
# get body
body = result.body
# get security data
security = result.security
# get parameters
path_params = result.parameters.path
query_params = result.parameters.query
cookies_params = result.parameters.cookies
headers_params = result.parameters.headers
# get body
body = result.body
# get security data
security = result.security

Request object should implement OpenAPI Request protocol. Check :doc:`integrations` to find oficially supported implementations.

Expand All @@ -86,9 +86,9 @@ Related projects
----------------

* `openapi-spec-validator <https://github.com/python-openapi/openapi-spec-validator>`__
Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification.
Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification.
* `openapi-schema-validator <https://github.com/python-openapi/openapi-schema-validator>`__
Python library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1.
Python library that validates schema against the OpenAPI Schema Specification v3.0 and OpenAPI Schema Specification v3.1.

License
-------
Expand Down
Loading