cadwyn 5.3.0__py3-none-any.whl → 5.3.2__py3-none-any.whl

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.

Potentially problematic release.


This version of cadwyn might be problematic. Click here for more details.

@@ -102,6 +102,14 @@ PYDANTIC_DECORATOR_TYPE_TO_DECORATOR_MAP = {
102
102
  ComputedFieldInfo: pydantic.computed_field,
103
103
  }
104
104
  _PYDANTIC_ALL_EXPORTED_NAMES = set(pydantic.__all__)
105
+ _DEFAULT_PYDANTIC_CLASSES = (BaseModel, RootModel)
106
+
107
+ try:
108
+ from pydantic_settings import BaseSettings
109
+
110
+ _DEFAULT_PYDANTIC_CLASSES = (*_DEFAULT_PYDANTIC_CLASSES, BaseSettings)
111
+ except ImportError: # pragma: no cover
112
+ pass
105
113
 
106
114
 
107
115
  VALIDATOR_CONFIG_KEY = "__validators__"
@@ -757,7 +765,7 @@ class SchemaGenerator:
757
765
  if (
758
766
  not isinstance(model, type)
759
767
  or not lenient_issubclass(model, (BaseModel, Enum))
760
- or model in (BaseModel, RootModel)
768
+ or model in _DEFAULT_PYDANTIC_CLASSES
761
769
  ):
762
770
  return model
763
771
  model = _unwrap_model(model)
@@ -528,6 +528,8 @@ class VersionBundle:
528
528
  status_code=raised_exception.status_code,
529
529
  headers=raised_exception.headers,
530
530
  )
531
+ if (raised_exception.headers or {}).get("content-length") is None: # pragma: no branch
532
+ del response_or_response_body.headers["content-length"]
531
533
  api_version = self.api_version_var.get()
532
534
  if api_version is None:
533
535
  return response_or_response_body
@@ -579,6 +581,7 @@ class VersionBundle:
579
581
  head_route.response_model,
580
582
  head_route,
581
583
  )
584
+
582
585
  if isinstance(response_or_response_body, FastapiResponse):
583
586
  # a webserver (uvicorn for instance) calculates the body at the endpoint level.
584
587
  # if an endpoint returns no "body", its content-length will be set to 0
@@ -605,9 +608,10 @@ class VersionBundle:
605
608
  indent=None,
606
609
  separators=(",", ":"),
607
610
  ).encode("utf-8")
608
- # It makes sense to re-calculate content length because the previously calculated one
609
- # might slightly differ. If it differs -- uvicorn will break.
610
- response_info.headers["content-length"] = str(len(response_info._response.body))
611
+ if response_info.headers.get("content-length") is not None:
612
+ # It makes sense to re-calculate content length because the previously calculated one
613
+ # might slightly differ. If it differs -- uvicorn will break.
614
+ response_info.headers["content-length"] = str(len(response_info._response.body))
611
615
 
612
616
  if raised_exception is not None and response_info.status_code >= 400:
613
617
  if isinstance(response_info.body, dict) and "detail" in response_info.body:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cadwyn
3
- Version: 5.3.0
3
+ Version: 5.3.2
4
4
  Summary: Production-ready community-driven modern Stripe-like API versioning in FastAPI
5
5
  Project-URL: Source code, https://github.com/zmievsa/cadwyn
6
6
  Project-URL: Documentation, https://docs.cadwyn.dev
@@ -71,7 +71,7 @@ Production-ready community-driven modern [Stripe-like](https://stripe.com/blog/a
71
71
 
72
72
  ## Who is this for?
73
73
 
74
- Cadwyn allows you to support a single version of your code while auto-generating the schemas and routes for older versions. You keep API versioning encapsulated in small and independent "version change" modules while your business logic stays simple and knows nothing about versioning.
74
+ Cadwyn allows you to maintain the implementation just for your newest API version and get all the older versions generated automatically. You keep API versioning encapsulated in small and independent "version change" modules while your business logic stays simple and knows nothing about versioning.
75
75
 
76
76
  Its [approach](https://docs.cadwyn.dev/theory/how_we_got_here/#ii-migration-based-response-building) will be useful if you want to:
77
77
 
@@ -12,7 +12,7 @@ cadwyn/middleware.py,sha256=4Ziq1ysnc8j5KmeZpsr9VJKllEFC8uYwXnG01I2FPR4,4853
12
12
  cadwyn/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  cadwyn/route_generation.py,sha256=RTZYfml03oKaNm_-SJX8N6PnafFXdsPpN0qEapHSzTw,27181
14
14
  cadwyn/routing.py,sha256=Ii6Qbgm9lGks1IAk-kDuIu_dX3FXsA77KSfGOFmLbgc,7604
15
- cadwyn/schema_generation.py,sha256=76T5MgfJHoQNfr_GdN5VVIUbGgA-KCV666r94jGSp0I,46830
15
+ cadwyn/schema_generation.py,sha256=ClAtq8Tnypj5g94rlRRcb2-GiZ8KJl0kj0FJtJantMI,47062
16
16
  cadwyn/_internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  cadwyn/_internal/context_vars.py,sha256=VcM8eAoSlvrIMFQhjZmjflV5o1yrPSEZZGkwOK4OSf4,378
18
18
  cadwyn/static/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -23,9 +23,9 @@ cadwyn/structure/data.py,sha256=NWURVnP_84VI2ugp9ppo0Ofyve3pVYjymF9K82Jh-SA,7791
23
23
  cadwyn/structure/endpoints.py,sha256=zUgzglNhBPnmWdJ03A8pFT4zPs_lj8nQ7c7Uo2d-ejU,6246
24
24
  cadwyn/structure/enums.py,sha256=4FCc9aniLE3VuWAVIacrNP_FWxTIUm9JkeeHA_zZdwQ,1254
25
25
  cadwyn/structure/schemas.py,sha256=O9yNw1OB0Qz-PvNB0FYlQm34gQsjyG2l9gg9x-RnJIY,10781
26
- cadwyn/structure/versions.py,sha256=FNHhgqCVe9Q5TO5ZMOSJgR846mli4ubGLvNDUERyPYs,34447
27
- cadwyn-5.3.0.dist-info/METADATA,sha256=yiKkJUKdxCbsDG0c0TDFH8KgtK6OvTvoh9cnGcw6frw,4529
28
- cadwyn-5.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
- cadwyn-5.3.0.dist-info/entry_points.txt,sha256=mGX8wl-Xfhpr5M93SUmkykaqinUaYAvW9rtDSX54gx0,47
30
- cadwyn-5.3.0.dist-info/licenses/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
31
- cadwyn-5.3.0.dist-info/RECORD,,
26
+ cadwyn/structure/versions.py,sha256=yOZ-x24Rb0itcZvQBe-92x9BiCLZK4cMqo0iX0DVN2k,34708
27
+ cadwyn-5.3.2.dist-info/METADATA,sha256=jZBEl2lneTuyyJAZmtGSPXyKJv2LZtoDiPDecalEJf8,4543
28
+ cadwyn-5.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ cadwyn-5.3.2.dist-info/entry_points.txt,sha256=mGX8wl-Xfhpr5M93SUmkykaqinUaYAvW9rtDSX54gx0,47
30
+ cadwyn-5.3.2.dist-info/licenses/LICENSE,sha256=KeCWewiDQYpmSnzF-p_0YpoWiyDcUPaCuG8OWQs4ig4,1072
31
+ cadwyn-5.3.2.dist-info/RECORD,,
File without changes