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.
Files changed (48) hide show
  1. {schema_first-0.14.2 → schema_first-0.14.4}/PKG-INFO +1 -1
  2. {schema_first-0.14.2 → schema_first-0.14.4}/pyproject.toml +4 -1
  3. {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/PKG-INFO +1 -1
  4. schema_first-0.14.4/src/schema_first/__init__.py +3 -0
  5. schema_first-0.14.4/src/schema_first/loaders/__init__.py +3 -0
  6. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/loaders/exc.py +1 -1
  7. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/loaders/yaml_loader.py +2 -2
  8. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/__init__.py +3 -3
  9. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/exc.py +1 -1
  10. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/base.py +3 -3
  11. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/contact_object_schema.py +1 -1
  12. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/example_object_schema.py +3 -3
  13. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/specification/__init__.py +3 -1
  14. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/specification/spilli_api.py +15 -14
  15. {schema_first-0.14.2 → schema_first-0.14.4}/tests/test_specification.py +4 -0
  16. schema_first-0.14.2/src/schema_first/__init__.py +0 -3
  17. schema_first-0.14.2/src/schema_first/loaders/__init__.py +0 -3
  18. {schema_first-0.14.2 → schema_first-0.14.4}/README.md +0 -0
  19. {schema_first-0.14.2 → schema_first-0.14.4}/setup.cfg +0 -0
  20. {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/SOURCES.txt +0 -0
  21. {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/dependency_links.txt +0 -0
  22. {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/requires.txt +0 -0
  23. {schema_first-0.14.2 → schema_first-0.14.4}/src/Schema_First.egg-info/top_level.txt +0 -0
  24. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/exceptions.py +0 -0
  25. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/__init__.py +0 -0
  26. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/constants.py +0 -0
  27. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/custom_fields.py +0 -0
  28. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/fields.py +0 -0
  29. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/components_object_schema.py +0 -0
  30. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/external_docs_object_schema.py +0 -0
  31. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/header_object_schema.py +0 -0
  32. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/info_object_schema.py +0 -0
  33. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/license_object_schema.py +0 -0
  34. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/media_type_object_schema.py +0 -0
  35. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/openapi_object_schema.py +0 -0
  36. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/operation_object_schema.py +0 -0
  37. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/parameter_object_schema.py +0 -0
  38. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/path_item_object_schema.py +0 -0
  39. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/reference_object_schema.py +0 -0
  40. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/request_body_object_schema.py +0 -0
  41. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/responses_object_schema.py +0 -0
  42. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/schema_object_schema.py +0 -0
  43. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/security_scheme_object_schema.py +0 -0
  44. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/server_object_schema.py +0 -0
  45. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/server_variable_object_schema.py +0 -0
  46. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/v3_2/tag_object_schema.py +0 -0
  47. {schema_first-0.14.2 → schema_first-0.14.4}/src/schema_first/openapi/schemas/validators.py +0 -0
  48. {schema_first-0.14.2 → schema_first-0.14.4}/tests/test_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Schema-First
3
- Version: 0.14.2
3
+ Version: 0.14.4
4
4
  Summary: OpenAPI specification validator and converter to Marshmallow schemas.
5
5
  Author-email: Konstantin Fadeev <jredkiy@yandex.ru>
6
6
  License-Expression: LGPL-2.1-only
@@ -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.2"
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: Schema-First
3
- Version: 0.14.2
3
+ Version: 0.14.4
4
4
  Summary: OpenAPI specification validator and converter to Marshmallow schemas.
5
5
  Author-email: Konstantin Fadeev <jredkiy@yandex.ru>
6
6
  License-Expression: LGPL-2.1-only
@@ -0,0 +1,3 @@
1
+ from schema_first.specification import Specification
2
+
3
+ __all__ = ['Specification']
@@ -0,0 +1,3 @@
1
+ from schema_first.loaders.yaml_loader import load_from_yaml
2
+
3
+ __all__ = ['load_from_yaml']
@@ -1,4 +1,4 @@
1
- from ..exceptions import SchemaFirstException
1
+ from schema_first.exceptions import SchemaFirstException
2
2
 
3
3
 
4
4
  class YAMLReaderError(SchemaFirstException):
@@ -6,8 +6,8 @@ from typing import Any
6
6
 
7
7
  import yaml
8
8
 
9
- from .exc import ResolverError
10
- from .exc import YAMLReaderError
9
+ from schema_first.loaders.exc import ResolverError
10
+ from schema_first.loaders.exc import YAMLReaderError
11
11
 
12
12
 
13
13
  class YAMLReader:
@@ -3,9 +3,9 @@ from pprint import pformat
3
3
 
4
4
  from marshmallow import ValidationError
5
5
 
6
- from ..loaders.yaml_loader import load_from_yaml
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:
@@ -1,4 +1,4 @@
1
- from ..exceptions import SchemaFirstException
1
+ from schema_first.exceptions import SchemaFirstException
2
2
 
3
3
 
4
4
  class OpenAPIValidationError(SchemaFirstException):
@@ -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.keys())
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}>,"
@@ -1,6 +1,6 @@
1
1
  from marshmallow import fields
2
2
 
3
- from ..base import BaseSchema
3
+ from schema_first.openapi.schemas.base import BaseSchema
4
4
 
5
5
 
6
6
  class ContactObjectSchema(BaseSchema):
@@ -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 ..base import BaseSchema
7
- from ..base import DocStringFields
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.reassembly_spec = ConverterOpenAPIToSpilliAPI(self.openapi.raw_spec).convert()
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 _make_to_spilli_api_format(self) -> None:
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
- if 'parameters' in methods:
56
- common_params = methods.pop('parameters', [])
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
- for _, operation_obj in methods.items():
59
- if 'parameters' in operation_obj:
60
- method_params = common_params + operation_obj.pop('parameters', [])
61
- operation_obj['parameters'] = self._params_list_to_dict(method_params)
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)
@@ -1,3 +0,0 @@
1
- from .specification import Specification
2
-
3
- __all__ = ['Specification']
@@ -1,3 +0,0 @@
1
- from .yaml_loader import load_from_yaml
2
-
3
- __all__ = ['load_from_yaml']
File without changes
File without changes