Skip to content

Commit

Permalink
extra - docs
Browse files Browse the repository at this point in the history
  • Loading branch information
commonism committed Sep 19, 2023
1 parent b9d3272 commit 55b200d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
13 changes: 11 additions & 2 deletions aiopenapi3/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@


class Reduce(Document, Init):
log = logging.getLogger("aiopenapi3.extra.Reduced")
"""
The Reduce plugin removes all not listed PathItems from the paths, limits initialization to models required and removes non required schemas
"""

def __init__(self, operations: Dict[Union[str, Pattern], List[Union[str, Pattern]]]):
log = logging.getLogger("aiopenapi3.extra.Reduce")

def __init__(self, operations: Dict[Union[str, Pattern], List[Union[str, Pattern]]]) -> None:
"""
:param operations: paths/methods to reduce to
"""
self.operations: List[Union[str, Pattern]] = operations
super().__init__()

Expand Down Expand Up @@ -73,6 +80,8 @@ def initialized(self, ctx: "Init.Context") -> "Init.Context":


class Cull(Reduce):
"""The Cull plugin removes everything not required as early as possible"""

@staticmethod
def _extract_references(data, root=None):
"""
Expand Down
3 changes: 2 additions & 1 deletion docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ Cull & Reduce
-------------

Reduce & Cull are Plugins limiting the models built to the minimum required to match the requirements of the supplied Operations

Code below will eleminate all schemas not required to serve the operations identified by the pattern/string match and http methods associated.

.. code:: python
api = OpenAPI.load_sync(
Expand All @@ -367,4 +367,5 @@ Code below will eleminate all schemas not required to serve the operations ident
.. currentmodule:: aiopenapi3.extra
.. autoclass:: Reduce
:members: __init__
.. autoclass:: Cull
4 changes: 2 additions & 2 deletions docs/source/extra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Large Description Documents
To assist working with large description documents it is possible to limit the models build to the minimum required.
This "minimum required" by the requirements of the Operations.

Currently there is two Plugins to assist such reduction - :class:`aiopenapi3.extra.Reduce` and :class:`aiopenapi3.extra.Cull`.
Currently there are two Plugins to assist such reduction - :class:`aiopenapi3.extra.Reduce` and :class:`aiopenapi3.extra.Cull`.
Cull is faster, Reduce assists in debugging.

Large description documents which are autogenerated by converting other service description document formats -such as odata-
may benefit from additional changes to the description document to eliminate conversion artifacts depending on the converter used.

As an example for additional steps based on the Microsoft MS Graph API refer to :aioai3:ref:`tests.extra_test.MSGraph`.
As an example for additional steps based on the `Microsoft Graph API <https://github.com/microsoftgraph/msgraph-metadata>`_ refer to :aioai3:ref:`tests.extra_test.MSGraph`.

0 comments on commit 55b200d

Please sign in to comment.