cloudflare / chanfana

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

Fix sending empty query parameters being parsed as empty strings instead of null #104

Closed G4brym closed 8 months ago

G4brym commented 8 months ago

Previous to this pr, if you defined as query parameter as string and required like this:

export class ToDoList extends OpenAPIRoute {
  static schema = {
    parameters: {
      my_field: Query(String),
    }
  }
} 

And sent a request with this query string ?my_field= it would pass the required validation as it was parsed as an empty string, but now it will trigger the right error saying Expected string, received null

github-actions[bot] commented 8 months ago

🧪 A prerelease is available for testing 🧪

You can install this latest build in your project with:

npm install --save https://prerelease-registry.devprod.cloudflare.dev/itty-router-openapi/runs/6942714810/npm-package-itty-router-openapi-104

Or you can immediately run this with npx:

npx https://prerelease-registry.devprod.cloudflare.dev/itty-router-openapi/runs/6942714810/npm-package-itty-router-openapi-104