From f79b551d9bdd717c32af3772148b0840b375eeec Mon Sep 17 00:00:00 2001 From: Dym Date: Thu, 9 Oct 2025 01:06:13 +0300 Subject: [PATCH] fix(sites): Correct response parsing for sites.list() The `sites.list()` method incorrectly parses the API response, leading to a `ValidationError`. The `/v2/sites` endpoint returns a JSON object with a `sites` key containing a list of site objects: `{ "sites": [...] }`. The current implementation attempts to parse this top-level object as a single `Site` model, which fails because required fields like `id` are missing at that level. This commit corrects the behavior by: 1. Updating the return type hint to `List[Site]`. 2. Modifying the parsing logic to first extract the list from the `sites` key before passing it to `pydantic.parse_obj_as`. This ensures the method correctly returns a list of `Site` objects as expected. --- src/webflow/resources/sites/client.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/webflow/resources/sites/client.py b/src/webflow/resources/sites/client.py index c2a4468..845898f 100644 --- a/src/webflow/resources/sites/client.py +++ b/src/webflow/resources/sites/client.py @@ -1,6 +1,7 @@ # This file was auto-generated by Fern from our API Definition. import typing +from typing import List from ...core.client_wrapper import SyncClientWrapper from .resources.redirects.client import RedirectsClient from .resources.plans.client import PlansClient @@ -104,11 +105,13 @@ def create( ) try: if 200 <= _response.status_code < 300: + response_json = _response.json() + sites_list = response_json.get("sites", []) return typing.cast( - Site, + List[Site], parse_obj_as( - type_=Site, # type: ignore - object_=_response.json(), + type_=List[Site], # type: ignore + object_=sites_list, ), ) if _response.status_code == 400: @@ -176,7 +179,7 @@ def create( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> Sites: + def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> List[Site]: """ List of all sites the provided access token is able to access.