Skip to content

Releases: cloudflare/chanfana

v2.3.0

14 Nov 18:41
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.2.0...v2.3.0

v2.2.0

11 Nov 18:03
Compare
Choose a tag to compare

What's Changed

Maintenance Changed

  • Migrate to biomejs for lint and format by @G4brym in #186
  • Migrate to vitest and update dependencies by @G4brym in #190

Full Changelog: v2.1.0...v2.2.0

v2.1.0

02 Nov 17:09
Compare
Choose a tag to compare

What's Changed

  • Fix #183 by removing any from router adapters

Full Changelog: v2.0.5...v2.1.0

v2.0.5

23 Oct 11:46
Compare
Choose a tag to compare

What's Changed

Full Changelog: v2.0.4...v2.0.5

v2.0.4

23 Aug 15:07
ec3f4c6
Compare
Choose a tag to compare

What's Changed

  • Change type to allow docs_url, redoc_url and openapi_url to be null by @marceloverdijk in #171

Full Changelog: v2.0.3...v2.0.4

v2.0.3

23 Aug 09:02
3e4fbe6
Compare
Choose a tag to compare

What's Changed

  • use jsdelivr to replace unpkg and add SRI for resources by @rwv in #163
  • Bump swagger ui and redocs ui versions by @G4brym in #170

Full Changelog: v2.0.2...v2.0.3

v2.0.2

27 Jun 16:17
Compare
Choose a tag to compare

Library Revamp

  • Rename library from itty-router-openapi to chanfana
  • Refactor everything to separate routing from openapi logic
  • Added support for Hono

Breaking Changes:

  • removed OpenAPIRouter() method
  • removed aiPlugin option
  • removed skipValidation option (see new validation method bellow)
  • itty-router is no longer a dependency and users must manually add it to their project
  • validated data is no longer send in the last argument of the handler function (see new validation method bellow)
  • Endpoint's schema is no longer a static variable
  • Endpoint's schema.parameters was renamed to schema.request to follow zod-to-openapi structure
  • Endpoint Path parameters are now called params to match the validated Data object name
  • Endpoint's schema.requestBody was renamed to schema.request.body to follow zod-to-openapi structure
  • Validation no longer occurs before the endpoint's handle function is called, developers must manually call the getValidatedData to execute the data validation step
    • Tip: you can wrap this function call with try {} catch (e) {} to handle input errors, otherwise this library will return the errors in a Json response with http 400

Additions:

  • new await this.getValidatedData<typeof this.schema>() method to retrieve all validated data, when sending <typeof this.schema> in the generic the returned value will have full typescript inference based on the schema
  • automatically coerce all headers, query and params inputs based on specified zod type
  • new fromIttyRouter() instantiate method
  • new fromHono() instantiate method

Migration Guide: https://chanfana.pages.dev/user-guide/migrating-from-itty-router-openapi/
Full Changelog: v1.1.1...v2.0.2

v1.1.1

16 Apr 14:13
5cd88e4
Compare
Choose a tag to compare

What's Changed

  • Bump @asteasolutions/zod-to-openapi to version 6.4.0 by @G4brym in #146

Full Changelog: v1.1.0...v1.1.1

v1.1.0

21 Mar 13:25
Compare
Choose a tag to compare

What's Changed

  • feat: type inference support for data argument by @iann838 in #130

Now you can get full type hint and type check on the data argument of every endpoint, learn more here!

export class TaskFetch extends OpenAPIRoute {
  static schema = {
    parameters: {
      taskSlug: Path(Str, {
        description: 'Task slug',
      }),
    },
  }

  async handle(request: Request, env: any, context: any, data: DataOf<typeof TaskFetch.schema>) {
    // full type hint for query, path, header, and request body parameters!
    data.params.taskSlug
    
    // ...
  }
}

Full Changelog: v1.0.14...v1.1.0

v1.0.14

14 Mar 12:35
2d9d2bf
Compare
Choose a tag to compare

What's Changed

  • Fix property content type wrongfully appearing in response schema by @G4brym in #137

Full Changelog: v1.0.13...v1.0.14