From 10c2129d905893b46b2424fd524b5eea874d3e7e Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Tue, 26 Nov 2024 17:03:51 -0800 Subject: [PATCH] eng: fix forward type reference in Pydantic schemas BNCH-112697 --- .../schema/openapi_schema_pydantic/header.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openapi_python_client/schema/openapi_schema_pydantic/header.py b/openapi_python_client/schema/openapi_schema_pydantic/header.py index 3223c199b..2d2471ea9 100644 --- a/openapi_python_client/schema/openapi_schema_pydantic/header.py +++ b/openapi_python_client/schema/openapi_schema_pydantic/header.py @@ -29,3 +29,10 @@ class Header(Parameter): ] }, ) + + +# Calling model_rebuild() here helps Pydantic to resolve the forward references that were used +# in defining Parameter and Encoding. Without this call, any subtle change to the loading order +# of schema submodules could result in an error like "Parameter is not fully defined". +# See: https://docs.pydantic.dev/latest/concepts/models/#rebuilding-model-schema +Parameter.model_rebuild()