这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

The reported issue describes date transformers not being generated for inline array object schemas. Investigation confirms this issue exists in legacy/fetch but not in @hey-api/client-fetch.

Verification

Tested with the OpenAPI spec from the issue containing three scenarios:

// Scenario 1: Single date field - ✅ works
DateResponse { date: Date }

// Scenario 2: Array with $ref - ✅ works  
ArrayOfDateResponses { items: Array<DateResponse> }

// Scenario 3: Inline array object - ✅ works with @hey-api/client-fetch
ArrayOfDateResponsesInline { items: Array<{ date: Date }> }

With @hey-api/client-fetch, all three scenarios generate correct transformers:

const arrayOfDateResponsesInlineSchemaResponseTransformer = (data: any) => {
    data.items = data.items.map((item: any) => {
        item.date = new Date(item.date);
        return item;
    });
    return data;
};

With legacy/fetch, scenario 3 fails - no transformer is generated despite types being Date.

Recommendation

Users experiencing this issue should migrate from legacy/fetch to @hey-api/client-fetch plugin, where date transformers work correctly for all schema patterns including inline array objects.

Original prompt

This section details on the original issue you should resolve

<issue_title>Date transformer not generated for dates in direct array object schema</issue_title>
<issue_description>### Description

If a component $ref has an array of items with an inline object schema that has date string fields (rather than the items schema being a $ref to another component) no date transformer gets generated.

The types still get produced as Date for this field, so this yields invalid types for the client.

Reproducible example or configuration

@hey-api/openapi-ts: 0.78.3

config

{
  input: 'swagger.json',
  output: 'src/client',
  plugins: ['legacy/fetch',
    {
      name: '@hey-api/schemas',
      type: 'json'
    },
    {
      name: '@hey-api/sdk',
      transformer: true,
      asClass: true,
    },
    {
      name: '@hey-api/typescript',
      exportInlineEnums: false,
      enums: false
    },
    {
      name: '@hey-api/transformers',
      dates: true
    },
  ]
}

OpenAPI specification (optional)

{
  "openapi": "3.0.0",
  "paths": {
    "/api/hello/date": {
      "get": {
        "operationId": "HelloControllerDate",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DateResponse"
                }
              }
            }
          }
        },
        "summary": "Return a date",
        "tags": [
          "hello"
        ]
      }
    },
    "/api/hello/array-of-dates": {
      "get": {
        "operationId": "HelloControllerArray Of Dates",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArrayOfDateResponses"
                }
              }
            }
          }
        },
        "summary": "Return an array of dates",
        "tags": [
          "hello"
        ]
      }
    },
    "/api/hello/array-of-dates-inline": {
      "get": {
        "operationId": "HelloControllerArray Of Dates Inline",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArrayOfDateResponsesInline"
                }
              }
            }
          }
        },
        "summary": "Return an array of dates",
        "tags": [
          "hello"
        ]
      }
    }
  },
  "info": {
    "title": "basic-app",
    "description": "example project",
    "version": "1.0",
    "contact": {}
  },
  "tags": [],
  "servers": [],
  "components": {
    "schemas": {
      "DateResponse": {
        "type": "object",
        "properties": {
          "date": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "date"
        ]
      },
      "ArrayOfDateResponses": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DateResponse"
            }
          }
        },
        "required": [
          "items"
        ]
      },
      "ArrayOfDateResponsesInline": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "format": "date-time",
                  "type": "string"
                }
              },
              "required": [
                "date"
              ]
            }
          }
        },
        "required": [
          "items"
        ]
      }
    }
  }
}

System information (optional)

No response</issue_description>

<agent_instructions>Check if this is an issue for @hey-api/client-fetch instead of legacy/fetch and fix if yes. Otherwise, do nothing</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

⚠️ No Changeset found

Latest commit: e62f9d2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
hey-api-docs Ready Ready Preview Comment Oct 31, 2025 0:31am

Copilot AI changed the title [WIP] Fix date transformer not generated for direct array object schema No fix needed - date transformers work correctly with @hey-api/client-fetch Oct 31, 2025
Copilot AI requested a review from mrlubos October 31, 2025 12:40
Copilot finished work on behalf of mrlubos October 31, 2025 12:40
@mrlubos mrlubos closed this Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date transformer not generated for dates in direct array object schema (legacy/fetch)

2 participants