Skip to content

Commit

Permalink
Remove any from router adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
G4brym committed Nov 2, 2024
1 parent 1fe1213 commit 4d1f6e4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chanfana",
"version": "2.0.5",
"version": "2.0.6",
"description": "OpenAPI 3 and 3.1 schema generator and validator for Hono, itty-router and more!",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class HonoOpenAPIHandler extends OpenAPIHandler {
export function fromHono<M>(
router: M,
options?: RouterOptions
): M & OpenAPIRouterType<M> & any {
): M & OpenAPIRouterType<M> {
const openapiRouter = new HonoOpenAPIHandler(router, options)

return new Proxy(router, {
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/ittyRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class IttyRouterOpenAPIHandler extends OpenAPIHandler {
export function fromIttyRouter<M>(
router: M,
options?: RouterOptions
): M & OpenAPIRouterType<M> & any {
): M & OpenAPIRouterType<M> {
const openapiRouter = new IttyRouterOpenAPIHandler(router, options)

return new Proxy(router, {
Expand Down
10 changes: 9 additions & 1 deletion src/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,24 @@ import { type OpenAPIRouteSchema, type RouterOptions } from './types'
import {
OpenApiGeneratorV3,
OpenApiGeneratorV31,
type RouteConfig,
} from '@asteasolutions/zod-to-openapi'
import { OpenAPIRegistryMerger } from './zod/registry'
import { z } from 'zod'
import yaml from 'js-yaml'
import { OpenAPIRoute } from './route'

export type OpenAPIRouterType<M> = {
original: M
options: RouterOptions
registry: OpenAPIRegistryMerger

delete(path: string, endpoint: typeof OpenAPIRoute): M
get(path: string, endpoint: typeof OpenAPIRoute): M
head(path: string, endpoint: typeof OpenAPIRoute): M
patch(path: string, endpoint: typeof OpenAPIRoute): M
post(path: string, endpoint: typeof OpenAPIRoute): M
put(path: string, endpoint: typeof OpenAPIRoute): M
all(path: string, router: M): M
}

export class OpenAPIHandler {
Expand Down

0 comments on commit 4d1f6e4

Please sign in to comment.