Skip to content

# : Incorrect TypeScript definitions for Browser Rendering JSON endpoint response_format #2647

@alexander-zuev

Description

@alexander-zuev

Confirm this is a Typescript library issue and not an underlying Cloudflare API issue

  • This is an issue with the Typescript library

Describe the bug

Summary

The TypeScript definitions for JsonCreateParams.ResponseFormat in the Browser Rendering API are incorrect. The interface defines schema but the actual API expects json_schema, causing runtime errors when following the TypeScript types.

Environment

  • SDK Version: [email protected]
  • API Endpoint: /accounts/{account_id}/browser-rendering/json
  • TypeScript Version: 5.8.3

Expected Behavior

The TypeScript interface should match the actual API contract. According to the Cloudflare docs, the API expects:

json { "response_format": { "type": "json_schema", "json_schema": { ... } } }

Actual Behavior

The TypeScript interface incorrectly defines:

typescript export interface ResponseFormat { type: string; schema?: Record<string, unknown>; // Should be json_schema }
Image Image

Steps to Reproduce

  1. Use the Browser Rendering JSON endpoint with response_format.schema
  2. Follow the TypeScript definitions
  3. Receive 422 error: "Cannot read properties of undefined (reading 'hasOwnProperty')"

Working Code (with workaround)

typescript response_format: { type: 'json_schema', json_schema: mySchema, // Works, but requires casting to any } as any

Failing Code (following TypeScript types)

typescript response_format: { type: 'json_schema', schema: mySchema, // Fails at runtime despite TypeScript approval }

Fix Required

Update the TypeScript interface to match the API:

typescript export interface ResponseFormat { type: string; json_schema?: Record<string, unknown>; // Correct property name }


### To Reproduce

Provided above

### Code snippets

```Typescript
Provided above

OS

macOS

Runtime version

Typescript 5.8.3

Library version

v4.3.0

P.S. Issue description generated by LLM on request from Alexander

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions