ardatan / feTS

🗹 TypeScript HTTP Framework focusing on e2e type-safety, easy setup, performance & great developer experience

Home Page:https://the-guild.dev/openapi/fets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docs: incorrect configuration in Next.js example

m-abdelwahab opened this issue · comments

The following Next.js code example https://the-guild.dev/openapi/fets/server/integrations/nextjs#usage works but TypeScript complains

import { createRouter, Response } from 'fets'
 
export default createRouter({
  swaggerUiEndpoint: '/api/docs',
  oasEndpoint: '/api/openapi.json'
}).route({
  method: 'GET',
  path: '/api/greetings',
  schemas: {
    responses: {
      200: {
        type: 'object',
        properties: {
          message: {
            type: 'string'
          }
        },
        required: ['message'],
        additionalProperties: false
      }
    }
  } as const,
  handler: () => Response.json({ message: 'Hello World!' })
})
Code-002895

Updating it to this fixes the type error

import { createRouter, Response } from 'fets'

export default createRouter({
+  swaggerUI: {
+    endpoint: '/api/docs'
+  },
+  openAPI: {
+   endpoint: '/api/openapi.json'
+  }
}).route({
  method: 'GET',
  path: '/api/greetings',
  schemas: {
    responses: {
      200: {
        type: 'object',
        properties: {
          message: {
            type: 'string'
          }
        },
        required: ['message'],
        additionalProperties: false
      }
    }
  } as const,
  handler: () => Response.json({ message: 'Hello World!' })
})

Thanks for the PR! It's merged now!