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

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

OpenAPI parameters with format: time were generating v.time() which doesn't exist in Valibot, causing runtime errors.

Changes

  • Fixed format mapping: Separated time case in string.ts to explicitly map to identifiers.actions.isoTimeSecond
  • Added test coverage: New spec and snapshot validating correct generation

Before/After

// Before (broken)
v.pipe(v.string(), v.time())  // v.time() doesn't exist

// After (correct)
v.pipe(v.string(), v.isoTimeSecond())  // v.isoTimeSecond() validates ISO 8601 time strings with seconds

The isoTimeSecond identifier already existed in constants but wasn't being used for the time format case. This validator is the appropriate choice for OpenAPI's format: time which represents values like 20:20:39+00:00.

Original prompt

This section details on the original issue you should resolve

<issue_title>Valibot types generate v.time instead of v.isoTime</issue_title>
<issue_description>### Description

When generating Valibot schemas, parameters with format: time are mapped to v.time() which does not exist.

It should rather map to v.isoTime() or v.isoTimeSecond(), which I'd suggest was originally meant.

Reproducible example or configuration

import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
  input: 'src/application/api/OUR_SCHEMA.yaml',
  output: 'src/application/api/generated',
  plugins: [
    '@hey-api/client-fetch',
    '@hey-api/transformers',
    'valibot',
    '@tanstack/react-query',
    {
      name: '@hey-api/sdk',
      transformer: true,
      responseStyle: 'data',
    },
    {
      name: '@hey-api/transformers',
      dates: true,
    },
    {
      name: '@hey-api/client-fetch',
      runtimeConfigPath: 'src/application/api/runtimeConfig.ts',
    },
  ],
});

OpenAPI specification (optional)

openapi: 3.0.3
info:
  title: Simple API with Time Query Parameter
  version: 1.0.0
paths:
  /search:
    get:
      summary: Search with time parameter
      parameters:
        - name: start_time
          in: query
          description: Start time in HH:MM:SS format
          schema:
            type: string
            format: time
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: string
                    example: "Search completed"

System information (optional)

No response</issue_description>

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


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@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 30, 2025

🦋 Changeset detected

Latest commit: 0db5a43

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel
Copy link

vercel bot commented Oct 30, 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 30, 2025 3:57pm

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Valibot types to map to v.isoTime instead of v.time Fix Valibot time format to generate v.isoTime() instead of v.time() Oct 30, 2025
Copilot AI requested a review from mrlubos October 30, 2025 15:21
Copilot finished work on behalf of mrlubos October 30, 2025 15:21
@mrlubos
Copy link
Member

mrlubos commented Oct 30, 2025

@copilot format: 'time' represents values such as 20:20:39+00:00, and I think Valibot's .isoTimeSecond() is a better fit for this format.

Per feedback from @mrlubos, format: 'time' represents values like 20:20:39+00:00,
and Valibot's isoTimeSecond() is a better fit than isoTime().

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot format: 'time' represents values such as 20:20:39+00:00, and I think Valibot's .isoTimeSecond() is a better fit for this format.

Changed to use v.isoTimeSecond() in commit 2a0a2fd. The generated code now correctly produces:

v.pipe(v.string(), v.isoTimeSecond())

This validates time values like 20:20:39+00:00 as specified in the OpenAPI time format.

Copilot AI changed the title Fix Valibot time format to generate v.isoTime() instead of v.time() Fix Valibot time format to generate v.isoTimeSecond() instead of v.time() Oct 30, 2025
Copilot finished work on behalf of mrlubos October 30, 2025 15:44
@mrlubos mrlubos marked this pull request as ready for review October 30, 2025 15:56
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 30, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 30, 2025
@dosubot dosubot bot added bug 🔥 Something isn't working javascript Pull requests that update Javascript code labels Oct 30, 2025
@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 30.00%. Comparing base (c6de684) to head (0db5a43).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
.../openapi-ts/src/plugins/valibot/v1/toAst/string.ts 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2889      +/-   ##
==========================================
- Coverage   30.01%   30.00%   -0.01%     
==========================================
  Files         488      488              
  Lines       40423    40432       +9     
  Branches     2427     2427              
==========================================
  Hits        12131    12131              
- Misses      28258    28267       +9     
  Partials       34       34              
Flag Coverage Δ
unittests 30.00% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 30, 2025

Open in StackBlitz

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/codegen-core@2889
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@2889
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@2889
npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@2889

commit: 0db5a43

@mrlubos mrlubos merged commit 128eb18 into main Oct 30, 2025
15 of 17 checks passed
@mrlubos mrlubos deleted the copilot/fix-valibot-time-format branch October 30, 2025 16:19
@hey-api hey-api bot mentioned this pull request Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Something isn't working javascript Pull requests that update Javascript code lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Valibot types generate v.time instead of v.isoTime

2 participants