alpha-python 0.7.6__tar.gz → 0.7.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {alpha_python-0.7.6 → alpha_python-0.7.8}/PKG-INFO +1 -1
- {alpha_python-0.7.6 → alpha_python-0.7.8}/pyproject.toml +1 -1
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/permission.py +2 -2
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/field_iterator.py +3 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/request_factory.py +6 -2
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/__main__.mustache +31 -10
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/container.py +1 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/models.py +69 -3
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/service.py +34 -50
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha_python.egg-info/PKG-INFO +1 -1
- {alpha_python-0.7.6 → alpha_python-0.7.8}/LICENSE +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/README.md +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/setup.cfg +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/adapters/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/adapters/rest_api_unit_of_work.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/adapters/sqla_unit_of_work.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/cli.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/containers/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/containers/container.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/base_model.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/group.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/life_cycle_base.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/role.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/domain/models/user.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/encoder.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/exceptions.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/_type_conversion_matrix.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/_type_mapping.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/class_factories.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/default_field_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/jwt_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/logging_handler_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/model_class_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/models/factory_classes.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/password_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/response_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/factories/type_factories.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/api_generate_handler.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/api_run_handler.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/base_handler.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/gen-code.sh +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/models/argument.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/models/command.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/models/section.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/models/subparser.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/run-api.sh +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/Dockerfile.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/README.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/__init__model.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/__init__test.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/base_model.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/controller.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/controller_test.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/dockerignore.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/encoder.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/git_push.sh.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/gitignore.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/model.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/openapi.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/param_type.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/requirements.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/security_controller_.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/setup.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/test-requirements.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/tox.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/travis.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/typing_utils.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/util.mustache +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/connectors/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/connectors/ldap_connector.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/connectors/oidc_connector.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/connectors/sql_alchemy.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/databases/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/databases/sql_alchemy.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/models/filter_operators.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/models/json_patch.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/models/order_by.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/models/query_clause.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/infra/models/search_filter.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/api_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/attrs_instance.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/dataclass_instance.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/factories.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/handler.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/http_client.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/openapi_model.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/patchable.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/providers.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/pydantic_instance.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/refresh_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/sql_database.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/sql_mapper.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/sql_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/token_factory.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/unit_of_work.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/interfaces/updatable.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/mixins/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/mixins/group_lifecycle.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/mixins/jwt_provider.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/mixins/user_lifecycle.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/api_key_provider.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/database_provider.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/ldap_provider.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/models/credentials.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/models/identity.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/models/token.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/providers/oidc_provider.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/py.typed +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/models/repository_model.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/cache_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/database_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/file_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/memory_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/rest_api_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/sql_alchemy_repository.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/services/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/services/authentication_service.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/services/models/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/services/models/cookie.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/services/user_lifecycle_management.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/_http_codes.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/cookie.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/is_attrs.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/is_pydantic.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/logging_configurator.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/logging_level_checker.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/__init__.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/exceptions.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/orm.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/openapi_test/response.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/request_headers.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/response_object.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/secret_generator.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/verify_identity.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/utils/version_checker.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha_python.egg-info/SOURCES.txt +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha_python.egg-info/dependency_links.txt +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha_python.egg-info/entry_points.txt +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha_python.egg-info/requires.txt +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha_python.egg-info/top_level.txt +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/tests/test_cli.py +0 -0
- {alpha_python-0.7.6 → alpha_python-0.7.8}/tests/test_encoder.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: alpha-python
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.8
|
|
4
4
|
Summary: Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
|
|
5
5
|
Author-email: Bart Reijling <bart@reijling.eu>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "alpha-python"
|
|
3
|
-
version = "0.7.
|
|
3
|
+
version = "0.7.8"
|
|
4
4
|
description = "Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -25,7 +25,7 @@ class Permission(LifeCycleBase, BaseDomainModel):
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
id: UUID | int | str | None = None
|
|
28
|
-
name: str
|
|
28
|
+
name: str | None = None
|
|
29
29
|
description: str = ""
|
|
30
30
|
|
|
31
31
|
def __str__(self) -> str:
|
|
@@ -35,7 +35,7 @@ class Permission(LifeCycleBase, BaseDomainModel):
|
|
|
35
35
|
-------
|
|
36
36
|
self.name value
|
|
37
37
|
"""
|
|
38
|
-
return self.name
|
|
38
|
+
return self.name or ""
|
|
39
39
|
|
|
40
40
|
def __repr__(self) -> str:
|
|
41
41
|
"""Return the official string representation of the object.
|
|
@@ -131,6 +131,8 @@ class Field:
|
|
|
131
131
|
|
|
132
132
|
Parameters
|
|
133
133
|
----------
|
|
134
|
+
key
|
|
135
|
+
Name of the pydantic field
|
|
134
136
|
obj
|
|
135
137
|
pydantic Field
|
|
136
138
|
|
|
@@ -140,6 +142,7 @@ class Field:
|
|
|
140
142
|
Field object
|
|
141
143
|
"""
|
|
142
144
|
init = getattr(obj, "init", True)
|
|
145
|
+
init = init if init is not None else True
|
|
143
146
|
type = getattr(obj, "annotation", None)
|
|
144
147
|
default = getattr(obj, "default", MISSING)
|
|
145
148
|
|
|
@@ -160,7 +160,9 @@ class RequestFactory:
|
|
|
160
160
|
for item in value
|
|
161
161
|
]
|
|
162
162
|
|
|
163
|
-
if isinstance(
|
|
163
|
+
if isinstance(
|
|
164
|
+
cls, (DataclassInstance | AttrsInstance | PydanticInstance)
|
|
165
|
+
):
|
|
164
166
|
return self._to_dataclass(value=value, cls=cls)
|
|
165
167
|
|
|
166
168
|
if isinstance(cls, type(Enum)):
|
|
@@ -181,7 +183,9 @@ class RequestFactory:
|
|
|
181
183
|
return value
|
|
182
184
|
|
|
183
185
|
def _to_dataclass(
|
|
184
|
-
self,
|
|
186
|
+
self,
|
|
187
|
+
value: OpenAPIModel | Any,
|
|
188
|
+
cls: DataclassInstance | AttrsInstance | PydanticInstance,
|
|
185
189
|
) -> (
|
|
186
190
|
DataclassInstance
|
|
187
191
|
| AttrsInstance
|
|
@@ -36,9 +36,6 @@ if os.getenv('FLASK_ENV') != 'production':
|
|
|
36
36
|
|
|
37
37
|
app = connexion.App(__name__, specification_dir='./openapi/')
|
|
38
38
|
app.app.json_encoder = JSONEncoder
|
|
39
|
-
app.add_api('openapi.yaml',
|
|
40
|
-
arguments={'title': '{{appName}}'},
|
|
41
|
-
pythonic_params=True)
|
|
42
39
|
|
|
43
40
|
compress = Compress()
|
|
44
41
|
compress.init_app(app.app)
|
|
@@ -57,19 +54,37 @@ LoggingConfigurator(
|
|
|
57
54
|
)
|
|
58
55
|
{{/disableLoggingConfigurator}}
|
|
59
56
|
{{#featureCORS}}
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
origins = container.config.cors.origins()
|
|
58
|
+
supports_credentials = container.config.cors.supports_credentials()
|
|
59
|
+
|
|
60
|
+
if origins is None:
|
|
62
61
|
logging.info(
|
|
63
62
|
"CORS origins not configured, defaulting to allow all origins"
|
|
64
63
|
)
|
|
65
|
-
|
|
66
|
-
logging.info(f"Enabling CORS for origins: {
|
|
67
|
-
CORS(
|
|
64
|
+
origins = ["*"]
|
|
65
|
+
logging.info(f"Enabling CORS for origins: {origins}")
|
|
66
|
+
CORS(
|
|
67
|
+
app.app,
|
|
68
|
+
origins=origins,
|
|
69
|
+
supports_credentials=supports_credentials or False,
|
|
70
|
+
resources=container.config.cors.resources() or r"/*",
|
|
71
|
+
methods=container.config.cors.methods() or ["GET", "HEAD", "POST", "OPTIONS", "PUT", "PATCH", "DELETE"],
|
|
72
|
+
allow_headers=container.config.cors.allow_headers() or "*",
|
|
73
|
+
expose_headers=container.config.cors.expose_headers(),
|
|
74
|
+
max_age=container.config.cors.max_age(),
|
|
75
|
+
vary_header=container.config.cors.vary_header() or True,
|
|
76
|
+
send_wildcard=container.config.cors.send_wildcard() or False,
|
|
77
|
+
)
|
|
68
78
|
{{/featureCORS}}
|
|
69
|
-
|
|
70
|
-
app.container = container
|
|
71
79
|
{{/initContainerFunction}}
|
|
72
80
|
|
|
81
|
+
app.add_api(
|
|
82
|
+
'openapi.yaml',
|
|
83
|
+
arguments={'title': '{{appName}}'},
|
|
84
|
+
pythonic_params=True
|
|
85
|
+
)
|
|
86
|
+
{{#initContainerFunction}}app.container = container{{/initContainerFunction}}
|
|
87
|
+
|
|
73
88
|
|
|
74
89
|
@app.app.after_request
|
|
75
90
|
def add_headers(response: Response):
|
|
@@ -93,6 +108,12 @@ def add_headers(response: Response):
|
|
|
93
108
|
):
|
|
94
109
|
continue
|
|
95
110
|
response.headers[header] = value
|
|
111
|
+
{{#featureCORS}}
|
|
112
|
+
request_origin = request.headers.get("Origin", None)
|
|
113
|
+
if supports_credentials and request_origin:
|
|
114
|
+
response.headers["Access-Control-Allow-Origin"] = request_origin
|
|
115
|
+
response.headers["Access-Control-Allow-Credentials"] = "true"
|
|
116
|
+
{{/featureCORS}}
|
|
96
117
|
return response
|
|
97
118
|
|
|
98
119
|
logging.info(f'Started {{servicePackage}} API on \'{socket.gethostname()}\'')
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
from
|
|
2
|
-
from
|
|
3
|
-
from typing import Any, Literal, Self, Sequence
|
|
1
|
+
from datetime import datetime, timedelta, timezone, date
|
|
2
|
+
from typing import Any, Literal, Self, Sequence, Optional, Type, TypeVar
|
|
4
3
|
from uuid import UUID
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from attrs import define
|
|
6
|
+
from pydantic import BaseModel
|
|
7
|
+
from enum import Enum, auto
|
|
5
8
|
|
|
6
9
|
from alpha.domain.models.base_model import BaseDomainModel
|
|
7
10
|
from alpha.providers.models.identity import Identity
|
|
@@ -119,3 +122,66 @@ class TestToken(BaseDomainModel):
|
|
|
119
122
|
obj["expires_at"] = self.expires_at.isoformat()
|
|
120
123
|
|
|
121
124
|
return obj
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
P = TypeVar("P", bound="Pet")
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class PetType(Enum):
|
|
131
|
+
NONE = 0
|
|
132
|
+
DOG = auto()
|
|
133
|
+
CAT = auto()
|
|
134
|
+
RABBIT = auto()
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@dataclass
|
|
138
|
+
class Pet:
|
|
139
|
+
name: str
|
|
140
|
+
pet_type: PetType
|
|
141
|
+
date_of_birth: date
|
|
142
|
+
weight: Optional[float] = None
|
|
143
|
+
good_boy: Optional[bool] = None
|
|
144
|
+
id: int = field(default=1)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def age(self) -> int:
|
|
148
|
+
delta = date(2022, 2, 2) - self.date_of_birth
|
|
149
|
+
return delta.days // 365
|
|
150
|
+
|
|
151
|
+
def to_dict(self) -> dict[str, Any]:
|
|
152
|
+
return {
|
|
153
|
+
"id": 1,
|
|
154
|
+
"name": self.name,
|
|
155
|
+
"pet_type": self.pet_type.name,
|
|
156
|
+
"age": self.age,
|
|
157
|
+
"weight": self.weight,
|
|
158
|
+
"good_boy": self.good_boy,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@classmethod
|
|
162
|
+
def factory(cls: Type[P], **kwargs) -> P:
|
|
163
|
+
return cls(
|
|
164
|
+
name=kwargs["name"],
|
|
165
|
+
pet_type=PetType[kwargs["pet_type"]],
|
|
166
|
+
date_of_birth=kwargs["date_of_birth"],
|
|
167
|
+
good_boy=kwargs["good_boy"],
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@define
|
|
172
|
+
class AttrsPet:
|
|
173
|
+
name: str
|
|
174
|
+
pet_type: PetType
|
|
175
|
+
date_of_birth: date
|
|
176
|
+
weight: Optional[float] = None
|
|
177
|
+
good_boy: Optional[bool] = None
|
|
178
|
+
id: int = 1
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
class PydanticPet(BaseModel):
|
|
182
|
+
name: str
|
|
183
|
+
pet_type: PetType
|
|
184
|
+
date_of_birth: date
|
|
185
|
+
weight: Optional[float] = None
|
|
186
|
+
good_boy: Optional[bool] = None
|
|
187
|
+
id: int = 1
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
from copy import deepcopy
|
|
2
2
|
import datetime
|
|
3
|
-
from
|
|
4
|
-
from enum import Enum, auto
|
|
5
|
-
from typing import Any, Optional, Type, TypeVar
|
|
6
|
-
|
|
3
|
+
from typing import Any
|
|
7
4
|
import dateutil
|
|
8
5
|
from werkzeug.datastructures import FileStorage
|
|
9
6
|
|
|
@@ -23,52 +20,10 @@ from alpha.exceptions import (
|
|
|
23
20
|
UnauthorizedException,
|
|
24
21
|
UnprocessableContentException,
|
|
25
22
|
)
|
|
23
|
+
from alpha.utils.openapi_test.models import AttrsPet, Pet, PetType, PydanticPet
|
|
26
24
|
|
|
27
25
|
from . import exceptions
|
|
28
26
|
|
|
29
|
-
P = TypeVar("P", bound="Pet")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class PetType(Enum):
|
|
33
|
-
NONE = 0
|
|
34
|
-
DOG = auto()
|
|
35
|
-
CAT = auto()
|
|
36
|
-
RABBIT = auto()
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
@dataclass
|
|
40
|
-
class Pet:
|
|
41
|
-
name: str
|
|
42
|
-
pet_type: PetType
|
|
43
|
-
date_of_birth: datetime.date
|
|
44
|
-
weight: Optional[float] = None
|
|
45
|
-
good_boy: Optional[bool] = None
|
|
46
|
-
id: int = field(default=1)
|
|
47
|
-
|
|
48
|
-
@property
|
|
49
|
-
def age(self) -> int:
|
|
50
|
-
delta = datetime.date(2022, 2, 2) - self.date_of_birth
|
|
51
|
-
return delta.days // 365
|
|
52
|
-
|
|
53
|
-
def to_dict(self) -> dict[str, Any]:
|
|
54
|
-
return {
|
|
55
|
-
"id": 1,
|
|
56
|
-
"name": self.name,
|
|
57
|
-
"pet_type": self.pet_type.name,
|
|
58
|
-
"age": self.age,
|
|
59
|
-
"weight": self.weight,
|
|
60
|
-
"good_boy": self.good_boy,
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@classmethod
|
|
64
|
-
def factory(cls: Type[P], **kwargs) -> P:
|
|
65
|
-
return cls(
|
|
66
|
-
name=kwargs["name"],
|
|
67
|
-
pet_type=PetType[kwargs["pet_type"]],
|
|
68
|
-
date_of_birth=kwargs["date_of_birth"],
|
|
69
|
-
good_boy=kwargs["good_boy"],
|
|
70
|
-
)
|
|
71
|
-
|
|
72
27
|
|
|
73
28
|
class TestService:
|
|
74
29
|
@staticmethod
|
|
@@ -103,15 +58,44 @@ class TestService:
|
|
|
103
58
|
"The object is not an instance of Pet"
|
|
104
59
|
)
|
|
105
60
|
|
|
61
|
+
def check_attrs_class(self, pet: AttrsPet) -> AttrsPet:
|
|
62
|
+
if isinstance(pet, AttrsPet):
|
|
63
|
+
return pet
|
|
64
|
+
raise exceptions.InvalidInstance(
|
|
65
|
+
"The object is not an instance of AttrsPet; received type: "
|
|
66
|
+
f"{type(pet)}"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def check_pydantic_class(self, pet: PydanticPet) -> PydanticPet:
|
|
70
|
+
if isinstance(pet, PydanticPet):
|
|
71
|
+
return pet
|
|
72
|
+
raise exceptions.InvalidInstance(
|
|
73
|
+
"The object is not an instance of PydanticPet; received type: "
|
|
74
|
+
f"{type(pet)}"
|
|
75
|
+
)
|
|
76
|
+
|
|
106
77
|
def check_dataclass_return_list(self, pet: Pet) -> list[Pet]:
|
|
107
78
|
if isinstance(pet, Pet):
|
|
108
79
|
pet2 = deepcopy(pet)
|
|
109
80
|
pet2.id = 2
|
|
110
81
|
pet2.name = "Dug"
|
|
111
82
|
return [pet, pet2]
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
83
|
+
|
|
84
|
+
def check_attrs_class_return_list(self, pet: AttrsPet) -> list[AttrsPet]:
|
|
85
|
+
if isinstance(pet, AttrsPet):
|
|
86
|
+
pet2 = deepcopy(pet)
|
|
87
|
+
pet2.id = 2
|
|
88
|
+
pet2.name = "Dug"
|
|
89
|
+
return [pet, pet2]
|
|
90
|
+
|
|
91
|
+
def check_pydantic_class_return_list(
|
|
92
|
+
self, pet: PydanticPet
|
|
93
|
+
) -> list[PydanticPet]:
|
|
94
|
+
if isinstance(pet, PydanticPet):
|
|
95
|
+
pet2 = deepcopy(pet)
|
|
96
|
+
pet2.id = 2
|
|
97
|
+
pet2.name = "Dug"
|
|
98
|
+
return [pet, pet2]
|
|
115
99
|
|
|
116
100
|
def handle4xx(self, pet: Pet) -> Any:
|
|
117
101
|
if pet.weight and pet.weight < 0:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: alpha-python
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.8
|
|
4
4
|
Summary: Alpha is intended to be the first dependency you need to add to your Python application. It is a Python library which contains standard building blocks that can be used in applications that are used as APIs and/or make use of database interaction.
|
|
5
5
|
Author-email: Bart Reijling <bart@reijling.eu>
|
|
6
6
|
License-Expression: MIT
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/README.mustache
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/encoder.mustache
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/model.mustache
RENAMED
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/openapi.mustache
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/setup.mustache
RENAMED
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/tox.mustache
RENAMED
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/travis.mustache
RENAMED
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/handlers/templates/python-flask/util.mustache
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/cache_repository.py
RENAMED
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/database_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
{alpha_python-0.7.6 → alpha_python-0.7.8}/src/alpha/repositories/refresh/memory_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|