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): avoid unnecessary zValidator imports #1814

Conversation

soartec-lab
Copy link
Member

@soartec-lab soartec-lab commented Jan 13, 2025

Status

READY

Description

verbOption.body always exists even if the request body does not exist, because it contains the following object:

verbOption.body {
  originalSchema: undefined,
  definition: '',
  implementation: '',
  imports: [],
  schemas: [],
  isOptional: false,
  formData: '',
  formUrlEncoded: '',
  contentType: ''
}

Therefore, when checking whether the request body exists, true is always returned, which is not the intended result.
As a result, this resulted in an unnecessary zValidator being imported, which caused the following warning:

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

The intended behavior is achieved by checking whether verbOption.body.definition exists.

Related PRs

None

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

export default defineConfig({
  petstoreSplitHandlers: {
    input: '../specifications/petstore.yaml',
    output: {
      target: '../generated/hono/petstore-split-handlers/endpoints.ts',
      schemas: '../generated/hono/petstore-split-handlers/handlers/schemas',
      mode: 'split',
      client: 'hono',
      override: {
        hono: {
          handlers: '../generated/hono/petstore-split-handlers/handlers',
        },
      },
    },
  },
}

@soartec-lab soartec-lab added bug Something isn't working hono Hono related issue labels Jan 13, 2025
@soartec-lab soartec-lab force-pushed the fix/hono/avoid-unnecessary-import-zvalidator branch from a9a1c83 to ac263f6 Compare January 15, 2025 10:28
@soartec-lab soartec-lab marked this pull request as ready for review January 15, 2025 10:29
@soartec-lab soartec-lab requested a review from anymaniax January 15, 2025 10:29
@soartec-lab soartec-lab merged commit 39a763a into orval-labs:master Jan 16, 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