Schema-First 0.14.2__tar.gz → 0.14.4__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.
- {schema_first-0.14.2 → schema_first-0.14.4}/PKG-INFO +1 -1
- {schema_first-0.14.2 → schema_first-0.14.4}/pyproject.toml +4 -1
- {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/PKG-INFO +1 -1
- schema_first-0.14.4/src/schema_first/__init__.py +3 -0
- schema_first-0.14.4/src/schema_first/loaders/__init__.py +3 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/loaders/exc.py +1 -1
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/loaders/yaml_loader.py +2 -2
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/__init__.py +3 -3
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/exc.py +1 -1
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/base.py +3 -3
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/contact_object_schema.py +1 -1
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/example_object_schema.py +3 -3
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/specification/__init__.py +3 -1
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/specification/spilli_api.py +15 -14
- {schema_first-0.14.2 → schema_first-0.14.4}/tests/test_specification.py +4 -0
- schema_first-0.14.2/src/schema_first/__init__.py +0 -3
- schema_first-0.14.2/src/schema_first/loaders/__init__.py +0 -3
- {schema_first-0.14.2 → schema_first-0.14.4}/README.md +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/setup.cfg +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/SOURCES.txt +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/dependency_links.txt +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/requires.txt +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/top_level.txt +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/exceptions.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/__init__.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/constants.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/custom_fields.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/fields.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/components_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/external_docs_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/header_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/info_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/license_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/media_type_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/openapi_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/operation_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/parameter_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/path_item_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/reference_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/request_body_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/responses_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/schema_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/security_scheme_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/server_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/server_variable_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/tag_object_schema.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/validators.py +0 -0
- {schema_first-0.14.2 → schema_first-0.14.4}/tests/test_validator.py +0 -0
|
@@ -20,7 +20,7 @@ license-files = ["LICENSE.txt"]
|
|
|
20
20
|
name = "Schema-First"
|
|
21
21
|
readme = "README.md"
|
|
22
22
|
requires-python = ">=3.14"
|
|
23
|
-
version = "0.14.
|
|
23
|
+
version = "0.14.4"
|
|
24
24
|
|
|
25
25
|
[project.optional-dependencies]
|
|
26
26
|
dev = [
|
|
@@ -38,6 +38,9 @@ dev = [
|
|
|
38
38
|
changelog = "https://github.com/flask-pro/schema-first/blob/master/CHANGES.md"
|
|
39
39
|
repository = "https://github.com/flask-pro/schema-first"
|
|
40
40
|
|
|
41
|
+
[tool.bandit]
|
|
42
|
+
exclude_dirs = ["tests"]
|
|
43
|
+
|
|
41
44
|
[tool.black]
|
|
42
45
|
extend-exclude = '''
|
|
43
46
|
# A regex preceded with ^/ will apply only to files and directories
|
|
@@ -3,9 +3,9 @@ from pprint import pformat
|
|
|
3
3
|
|
|
4
4
|
from marshmallow import ValidationError
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from .exc import OpenAPIValidationError
|
|
8
|
-
from .schemas.v3_2.openapi_object_schema import OpenAPIObjectSchema
|
|
6
|
+
from schema_first.loaders.yaml_loader import load_from_yaml
|
|
7
|
+
from schema_first.openapi.exc import OpenAPIValidationError
|
|
8
|
+
from schema_first.openapi.schemas.v3_2.openapi_object_schema import OpenAPIObjectSchema
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class OpenAPI:
|
|
@@ -3,8 +3,8 @@ from marshmallow import Schema
|
|
|
3
3
|
from marshmallow import validates_schema
|
|
4
4
|
from marshmallow import ValidationError
|
|
5
5
|
|
|
6
|
-
from .fields import DESCRIPTION_FIELD
|
|
7
|
-
from .fields import SUMMARY_FIELD
|
|
6
|
+
from schema_first.openapi.schemas.fields import DESCRIPTION_FIELD
|
|
7
|
+
from schema_first.openapi.schemas.fields import SUMMARY_FIELD
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class BaseSchema(Schema):
|
|
@@ -15,7 +15,7 @@ class BaseSchema(Schema):
|
|
|
15
15
|
def validate_ref(self, data, **kwargs) -> None:
|
|
16
16
|
if 'ref' in data:
|
|
17
17
|
ALLOWED_FIELDS = {'ref', 'description', 'summary'}
|
|
18
|
-
ALL_FIELDS = set(data
|
|
18
|
+
ALL_FIELDS = set(data)
|
|
19
19
|
if ALL_FIELDS.difference(ALLOWED_FIELDS):
|
|
20
20
|
raise ValidationError(
|
|
21
21
|
f"If there is a <'ref'> field, then only <{ALLOWED_FIELDS}>,"
|
|
@@ -3,9 +3,9 @@ from marshmallow import validate
|
|
|
3
3
|
from marshmallow import validates_schema
|
|
4
4
|
from marshmallow import ValidationError
|
|
5
5
|
|
|
6
|
-
from
|
|
7
|
-
from
|
|
8
|
-
from .schema_object_schema import SchemaObjectSchema
|
|
6
|
+
from schema_first.openapi.schemas.base import BaseSchema
|
|
7
|
+
from schema_first.openapi.schemas.base import DocStringFields
|
|
8
|
+
from schema_first.openapi.schemas.v3_2.schema_object_schema import SchemaObjectSchema
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class ExampleObjectSchema(DocStringFields, BaseSchema):
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
1
2
|
from pathlib import Path
|
|
2
3
|
from typing import Any
|
|
3
4
|
|
|
@@ -157,7 +158,8 @@ class Specification:
|
|
|
157
158
|
def load(self) -> Specification:
|
|
158
159
|
self.openapi.load()
|
|
159
160
|
|
|
160
|
-
self.
|
|
161
|
+
self.spilli_api = ConverterOpenAPIToSpilliAPI(self.openapi.raw_spec).convert()
|
|
162
|
+
self.reassembly_spec = deepcopy(self.spilli_api)
|
|
161
163
|
self._reassembly_of_schemas(self.reassembly_spec)
|
|
162
164
|
|
|
163
165
|
return self
|
|
@@ -11,10 +11,7 @@ class ConverterOpenAPIToSpilliAPI:
|
|
|
11
11
|
def _convert_params_to_schema(
|
|
12
12
|
self, params: list[dict], place: t.Literal['header', 'cookie', 'path', 'query']
|
|
13
13
|
) -> Any | None:
|
|
14
|
-
schema = {
|
|
15
|
-
'type': 'object',
|
|
16
|
-
'additionalProperties': True,
|
|
17
|
-
}
|
|
14
|
+
schema = {'type': 'object', 'additionalProperties': True}
|
|
18
15
|
|
|
19
16
|
required = []
|
|
20
17
|
properties = {}
|
|
@@ -47,18 +44,22 @@ class ConverterOpenAPIToSpilliAPI:
|
|
|
47
44
|
|
|
48
45
|
return params_as_dict
|
|
49
46
|
|
|
50
|
-
def
|
|
51
|
-
self.spilli_api_spec = json.loads(json.dumps(self.open_api_spec))
|
|
52
|
-
|
|
47
|
+
def _convert_method_params(self) -> None:
|
|
53
48
|
for _, methods in self.spilli_api_spec['paths'].items():
|
|
54
|
-
common_params = []
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
common_params = methods.pop('parameters', [])
|
|
50
|
+
|
|
51
|
+
for method, operation_obj in methods.items():
|
|
52
|
+
if method in ('summary', 'description', 'servers'):
|
|
53
|
+
continue
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
operation_obj['parameters'] = self._params_list_to_dict(
|
|
55
|
+
method_params = operation_obj.get('parameters', [])
|
|
56
|
+
all_method_params = common_params + method_params
|
|
57
|
+
if all_method_params:
|
|
58
|
+
operation_obj['parameters'] = self._params_list_to_dict(all_method_params)
|
|
59
|
+
|
|
60
|
+
def _make_to_spilli_api_format(self) -> None:
|
|
61
|
+
self.spilli_api_spec = json.loads(json.dumps(self.open_api_spec))
|
|
62
|
+
self._convert_method_params()
|
|
62
63
|
|
|
63
64
|
def convert(self) -> dict:
|
|
64
65
|
self._make_to_spilli_api_format()
|
|
@@ -21,10 +21,14 @@ def test_specification(request, fx_spec_as_file, fx):
|
|
|
21
21
|
spec = Specification(spec_file)
|
|
22
22
|
|
|
23
23
|
assert spec.openapi
|
|
24
|
+
assert spec.spilli_api is None
|
|
24
25
|
assert spec.reassembly_spec is None
|
|
25
26
|
|
|
26
27
|
spec.load()
|
|
27
28
|
|
|
29
|
+
assert isinstance(spec.spilli_api, dict)
|
|
30
|
+
assert isinstance(spec.reassembly_spec, dict)
|
|
31
|
+
|
|
28
32
|
request_schema = get_schema_from_request(spec.reassembly_spec, '/required-endpoint', '200')
|
|
29
33
|
assert isinstance(request_schema(), Schema)
|
|
30
34
|
assert isinstance(request_schema().fields['message'], fields.String)
|
|
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
|
{schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/custom_fields.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
|