cloudflare / chanfana

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

Set default values #91

Open cptchloroplast opened 1 year ago

cptchloroplast commented 1 year ago

I can define default values in the OpenAPI schema but it would be nice for the route to set them automatically.

G4brym commented 1 year ago

Hey @cptchloroplast can you further explain? Currently, if you define a default in an endpoint, that default will be passed to the endpoint in the data object Here is an example of a query parameter with a default value

Query(Number, {
    description: 'Limit the number of objects per search category.',
    default: 3
})