From d059143f84a1ffbd73005e03fb9228806b88714e Mon Sep 17 00:00:00 2001 From: Santiago Medina Rolong Date: Thu, 12 Mar 2026 20:34:31 -0700 Subject: [PATCH] fix: skip importing response types for binary endpoints Operations that return application/octet-stream (binary data) don't have response model classes generated in models.j2, since those templates only generate models for application/json responses. However, the client_class.j2 templates were importing response types for ALL operations with 200/201 responses, causing import errors like: Module '"./models.js"' has no exported member 'MediaDownloadResponse' This fix adds a check in both TypeScript and Python client_class.j2 templates to only import response types for operations that actually return JSON content, matching the behavior of the models templates. Binary response operations (like chatMediaDownload) correctly use ArrayBuffer (TypeScript) or bytes (Python) as return types and don't need imported response model types. --- xdk-gen/templates/python/client_class.j2 | 8 +++++--- xdk-gen/templates/typescript/client_class.j2 | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/xdk-gen/templates/python/client_class.j2 b/xdk-gen/templates/python/client_class.j2 index d8cf1f8c..758a0fa2 100644 --- a/xdk-gen/templates/python/client_class.j2 +++ b/xdk-gen/templates/python/client_class.j2 @@ -25,10 +25,12 @@ from .models import ( {% for operation in operations %} {% if operation.request_body %} {{ operation.class_name }}Request, - {% if operation.responses and "200" in operation.responses or operation.responses and "201" in operation.responses %} - {{ operation.class_name }}Response, {% endif %} - {% elif operation.responses and "200" in operation.responses or operation.responses and "201" in operation.responses %} + {# Only import response types for operations that return JSON (not binary) #} + {% set response_200 = operation.responses["200"] if operation.responses and "200" in operation.responses else none %} + {% set response_201 = operation.responses["201"] if operation.responses and "201" in operation.responses else none %} + {% set has_json_response = (response_200 and response_200.content and "application/json" in response_200.content) or (response_201 and response_201.content and "application/json" in response_201.content) %} + {% if has_json_response %} {{ operation.class_name }}Response, {% endif %} {% endfor %} diff --git a/xdk-gen/templates/typescript/client_class.j2 b/xdk-gen/templates/typescript/client_class.j2 index 655d8a39..14492f11 100644 --- a/xdk-gen/templates/typescript/client_class.j2 +++ b/xdk-gen/templates/typescript/client_class.j2 @@ -16,10 +16,12 @@ import { {% for operation in operations -%} {% if operation.request_body -%} {{ operation.class_name }}Request, -{% if operation.responses and "200" in operation.responses or operation.responses and "201" in operation.responses -%} - {{ operation.class_name }}Response, {% endif -%} -{% elif operation.responses and "200" in operation.responses or operation.responses and "201" in operation.responses -%} +{# Only import response types for operations that return JSON (not binary) #} +{% set response_200 = operation.responses["200"] if operation.responses and "200" in operation.responses else none -%} +{% set response_201 = operation.responses["201"] if operation.responses and "201" in operation.responses else none -%} +{% set has_json_response = (response_200 and response_200.content and "application/json" in response_200.content) or (response_201 and response_201.content and "application/json" in response_201.content) -%} +{% if has_json_response -%} {{ operation.class_name }}Response, {% endif -%} {% endfor -%}