Skip to content
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

extra - expose module #312

Merged
merged 1 commit into from
Dec 31, 2024
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
10 changes: 10 additions & 0 deletions aiopenapi3/extra/cookies.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ def info(self) -> email.message.Message:
def __init__(
self, cookiejar: http.cookiejar.CookieJar = None, policy: Literal["jar", "securitySchemes"] = "jar"
) -> None:
"""

:param cookiejar: a cookiejar.CookieJar instance
:param policy: There are two policies:

* securitySchemes - only cookies whose name is in the securitySchemes are used. To match authentication \
requirements credentials are set via OpenAPI.authenticate(name=value)
* jar - all cookies are used, basically like a browser would do. Cookies not mentioned in securitySchemes \
are set besides OpenAPI.authenticate() to allow using them without adjusting the description document.
"""
self.cookiejar: http.cookiejar.CookieJar = cookiejar or http.cookiejar.CookieJar()
self.policy: Literal["jar", "securitySchemes"] = policy
self.schemes: dict[str, str] = dict()
Expand Down
23 changes: 15 additions & 8 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,11 @@ 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.

.. currentmodule:: aiopenapi3.extra
.. autoclass:: Reduce
:members: __init__
.. autoclass:: Cull

.. code:: python

api = OpenAPI.load_sync(
Expand All @@ -392,20 +397,20 @@ Code below will eleminate all schemas not required to serve the operations ident
],
)

.. currentmodule:: aiopenapi3.extra
.. autoclass:: Reduce
:members: __init__
.. autoclass:: Cull


.. inheritance-diagram:: aiopenapi3.plugin.Init aiopenapi3.plugin.Document aiopenapi3.extra.Cull aiopenapi3.extra.Reduce
:top-classes: aiopenapi3.plugin.Plugin
:parts: -2


Cookies
-------

This plugin deals with cookies from responses and adds in requests based on a policy.

There are two policies:
* securitySchemes - only cookies whose name is in the securitySchemes are used. To match authentication requirements credentials are set via OpenAPI.authenticate(name=value)
* jar - all cookies are used, basically like a browser would do. Cookies not mentioned in securitySchemes are set besides OpenAPI.authenticate() to allow using them without adjusting the description document.
.. autoclass:: Cookies
:members: __init__

.. code:: python

Expand All @@ -416,4 +421,6 @@ There are two policies:
],
)

.. autoclass:: Cookies
.. inheritance-diagram:: aiopenapi3.plugin.Plugin aiopenapi3.plugin.Init aiopenapi3.plugin.Message aiopenapi3.extra.cookies.Cookies
:top-classes: aiopenapi3.plugin.Plugin
:parts: -2
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ packages = [
"aiopenapi3",
"aiopenapi3.v20",
"aiopenapi3.v30",
"aiopenapi3.v31"
"aiopenapi3.v31",
"aiopenapi3.extra"
]

[tool.setuptools.dynamic]
Expand Down
Loading