diff --git a/app.py b/app.py index d351dd0..a76eed7 100644 --- a/app.py +++ b/app.py @@ -524,9 +524,9 @@ def download_database_view(request): download_filename = sanitize_filename_for_http_header(f"user_{user.id}.db") response = Response(body=data, content_type="application/octet-stream") - response.headers[ - "Content-Disposition" - ] = f'attachment; filename="{download_filename}"' + response.headers["Content-Disposition"] = ( + f'attachment; filename="{download_filename}"' + ) return response @@ -1005,7 +1005,19 @@ def main(global_config=None, **settings): config.add_jinja2_renderer(".j2") config.add_jinja2_search_path("templates", name=".j2") - # The Jinja2 filters are added via the event subscriber above + # Add settings for pyramid_openapi3 + config.add_settings( + { + "pyramid_openapi3.spec": os.path.join(APP_DIR, "openapi.yaml"), + "pyramid_openapi3.enable_request_validation": True, + "pyramid_openapi3.enable_response_validation": False, + "pyramid_openapi3.route": "/openapi.yaml", + "pyramid_openapi3.ui_route": "/docs/", + } + ) + + # Include pyramid_openapi3 + config.include("pyramid_openapi3") # Set up SQLAlchemy engine = create_engine( diff --git a/openapi.yaml b/openapi.yaml new file mode 100644 index 0000000..367c5e5 --- /dev/null +++ b/openapi.yaml @@ -0,0 +1,53 @@ +openapi: 3.0.0 +info: + title: PyraFiles API + version: '1.0' +paths: + /auth/login: + post: + summary: User login + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + email: + type: string + responses: + '302': + description: Redirect to verification page + /auth/verify: + post: + summary: Verify user code + requestBody: + required: true + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + code: + type: string + responses: + '302': + description: Redirect to home page + /media/upload: + post: + summary: Upload media file + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + properties: + media_file: + type: string + format: binary + title: + type: string + responses: + '302': + description: Redirect to media details page diff --git a/requirements.txt b/requirements.txt index bd0af6c..bad1dc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,5 @@ zope.sqlalchemy bcrypt sqlalchemy werkzeug + +pyramid_openapi3