Compare commits

...

13 Commits

Author SHA1 Message Date
Georg K
40dfded213 fix: use tags 2022-03-30 20:07:54 +03:00
Georg K
0e991070a5 fix: use tags 2022-03-30 20:05:56 +03:00
Georg K
bf34914a8a fix: use tags 2022-03-30 20:02:53 +03:00
Georg K
4aee715e48 fix:use tags 2022-03-30 19:57:43 +03:00
Georg K
c649905e69 fix:use fixed branch 2022-03-30 19:55:32 +03:00
Georg K
4015c60cfa fix: package version 2.12.1 2022-03-30 19:51:35 +03:00
Georg K
a1dcc544cf fix: package version 2022-03-30 19:48:03 +03:00
Georg K
f278629217 fix: pypi_url parameter 2022-03-30 19:42:32 +03:00
Georg K
4e8fb95c52 feat: add .gitlab-ci.yml 2022-03-30 18:48:10 +03:00
Georg K
27c0d76e16 Merge branch 'main' into fixed
# Conflicts:
#	aiohttp_pydantic/oas/__init__.py
#	aiohttp_pydantic/view.py
2022-03-30 17:30:15 +03:00
jar3b
16ba8caa5b fix: reapply raise_validation_errors parameter to setup() 2020-12-03 21:07:50 +03:00
jar3b
53357214a8 feat: add raise_validation_errors parameter to setup()
To control how pydantic.ValidationError will be handled, own handler (return json) or raise exception to allow intercept in aiohttp middleware
2020-12-03 21:06:10 +03:00
jar3b
cdcd526fb4 fix: detect x-forwarded-proto if deployed behind proxy
For static files handling, was set up in "oas_ui()"
2020-12-03 21:05:08 +03:00
6 changed files with 26 additions and 5 deletions

11
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,11 @@
stages:
- package
publish-pypi:
stage: package
image: python:3.8
script:
- pip install -U setuptools wheel pip; pip install invoke
- invoke upload --pypi-user ${PYPI_REPO_USER} --pypi-password ${PYPI_REPO_PASSWORD} --pypi-url ${PYPI_REPO_URL}
only:
- tags

View File

@ -1,5 +1,5 @@
from .view import PydanticView
__version__ = "1.12.1"
__version__ = "1.12.1-fixed3"
__all__ = ("PydanticView", "__version__")

View File

@ -15,10 +15,13 @@ def setup(
enable: bool = True,
version_spec: Optional[str] = None,
title_spec: Optional[str] = None,
raise_validation_errors: bool = False,
):
if enable:
oas_app = web.Application()
oas_app["apps to expose"] = tuple(apps_to_expose) or (app,)
for a in oas_app["apps to expose"]:
a['raise_validation_errors'] = raise_validation_errors
oas_app["index template"] = jinja2.Template(
resources.read_text("aiohttp_pydantic.oas", "index.j2")
)

View File

@ -185,6 +185,8 @@ async def oas_ui(request):
static_url = request.app.router["static"].url_for(filename="")
spec_url = request.app.router["spec"].url_for()
if request.scheme != request.headers.get('x-forwarded-proto', request.scheme):
request = request.clone(scheme=request.headers['x-forwarded-proto'])
host = request.url.origin()
return Response(

View File

@ -127,6 +127,9 @@ def inject_params(
else:
injector.inject(self.request, args, kwargs)
except ValidationError as error:
if self.request.app['raise_validation_errors']:
raise
else:
return await self.on_validation_error(error, injector.context)
return await handler(self, *args, **kwargs)

View File

@ -136,6 +136,7 @@ def prepare_ci_env(c):
title("Installing wheel", "=")
package_version = read_configuration("./setup.cfg")["metadata"]["version"]
print([x for x in Path("dist").glob('*')])
dist = next(Path("dist").glob(f"aiohttp_pydantic-{package_version}-*.whl"))
c.run(f"dist_venv/bin/python -m pip install {dist}")
@ -156,7 +157,7 @@ def prepare_upload(c):
@task(tag_eq_version, prepare_upload)
def upload(c, pypi_user=None, pypi_password=None):
def upload(c, pypi_user=None, pypi_password=None, pypi_url=None):
"""
Upload on pypi
"""
@ -165,8 +166,9 @@ def upload(c, pypi_user=None, pypi_password=None):
if pypi_user is not None and pypi_password is not None:
c.run(
f"dist_venv/bin/twine upload --non-interactive"
f" -u {pypi_user} -p {pypi_password} {dist}",
f" -u {pypi_user} -p {pypi_password} {dist}"
f" --repository-url {pypi_url}",
hide=True,
)
else:
c.run(f"dist_venv/bin/twine upload --repository aiohttp-pydantic {dist}")
c.run(f"dist_venv/bin/twine upload --repository-url {pypi_url} --repository aiohttp-pydantic {dist}")