cloudflare / chanfana

OpenAPI 3 and 3.1 schema generator and validator for Hono, itty-router and more!
https://chanfana.pages.dev
MIT License
342 stars 43 forks source link

How do I specify the server URL in openapi.json? #120

Open tddschn opened 10 months ago

tddschn commented 10 months ago

https://cloudflare.github.io/itty-router-openapi/user-guide/router-options/

I thought OpenAPIRouter supports specifying the server URL so that the generated openapi.json will have the server URL info, but I can't find the option in the doc linked above. Is this feature supported?

G4brym commented 10 months ago

Hey @tddschn you can pass all supported openapi properties inside the schema property of the router, here's an example for defining servers:

const router = OpenAPIRouter({
  schema: {
    servers: [{
      url: 'https://api.example.com/v1',
      description: 'example',
    }],
  },
})