Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(hono): remove unnecessary zod file and import #1896

Merged

Conversation

soartec-lab
Copy link
Member

@soartec-lab soartec-lab commented Feb 12, 2025

Status

READY

Description

When using the hono client, the schema may not exist for both responses and requests, as shown below:

paths:
  /health:
    get:
      summary: health check
      operationId: healthCheck
      tags:
        - health
      responses:
        '200':
          description: A paged array of pets
          content:
            text/plain:
              schema:
                type: string

This will generate an empty zod file.
That caused an error and defined an unnecessary import.

/**
 * Generated by orval v7.5.0 🍺
 * Do not edit manually.
 * Swagger Petstore
 * OpenAPI spec version: 1.0.0
 */
import { z as zod } from 'zod';

error TS6133: 'zod' is declared but its value is never read.

import { createFactory } from 'hono/factory';
import { HealthCheckContext } from './health.context';
import {  } from './health.zod';

const factory = createFactory();
export const healthCheckHandlers = factory.createHandlers(
async (c: HealthCheckContext) => {

  },
);
/**
 * Generated by orval v7.5.0 🍺
 * Do not edit manually.
 * Swagger Petstore
 * OpenAPI spec version: 1.0.0
 */
import type { Context, Env } from 'hono';

import {  } from '.././schemas';

export type HealthCheckContext<E extends Env = any> = Context<E, '/health'>

I modified it so that if the zod schema is not needed, it does not create the file and also does not perform unnecessary imports.

Related PRs

List related PRs against other branches:

branch PR
other_pr_production link
other_pr_master link

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

You can check by below definition.

paths:
  /health:
    get:
      summary: health check
      operationId: healthCheck
      tags:
        - health
      responses:
        '200':
          description: A paged array of pets
          content:
            text/plain:
              schema:
                type: string

@soartec-lab soartec-lab added bug Something isn't working hono Hono related issue labels Feb 12, 2025
@melloware melloware merged commit 53b6e8c into orval-labs:master Feb 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hono Hono related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants