Skip to content

Releases: christoph-fricke/openapi-msw

v0.1.2

31 Oct 15:27
1bdc7f9
Compare
Choose a tag to compare

Patch Changes

  • #17 2931f0c Thanks @christoph-fricke! - Fixed OpenAPI operations with no-content responses cannot return a response. Now they are required to return an empty response, i.e. null as response body.

    const http = createOpenApiHttp<paths>();
    
    // Resolver function is required to return a `StrictResponse<null>` (empty response)
    // if the OpenAPI operation specifies `content?: never` for the response.
    const noContent = http.delete("/resource", ({ params }) => {
      return HttpResponse.json(null, { status: 204 });
    });

v0.1.1

24 Oct 21:02
ecce28f
Compare
Choose a tag to compare

Patch Changes

  • #12 96ce15c Thanks @christoph-fricke! - Add legacy entrypoint definitions (types, module) for tools and bundlers that do not understand package.json#exports fields.

v0.1.0

23 Oct 18:45
2a6cbe8
Compare
Choose a tag to compare

Minor Changes

  • #9 6364870 Thanks @christoph-fricke! - Added installation and complete usage guide to the documentation.

  • #5 d15a0c2 Thanks @christoph-fricke! - Added createOpenApiHttp(...) to create a thin, type-safe wrapper around MSW's http that uses openapi-ts paths:

    import type { paths } from "./openapi-ts-definitions";
    
    const http = createOpenApiHttp<paths>();
    
    // Define handlers with fully typed paths, path params, and request/response bodies
    const handler = http.get("/pets/{id}", () => {
      /* ... */
    });
    
    // Fallback to default http implementation
    const catchAll = http.untyped.all("*", () => {
      /* ... */
    });