Skip to content

v1.2.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 13 Mar 20:31
edce114

Minor Changes

  • #78 482c028 Thanks @christoph-fricke! - Added utility types for creating type-safe functionality around OpenAPI-MSW. Special thanks to @DrewHoo for suggesting and inspiring this change.

    import {
      createOpenApiHttp,
      type PathsFor,
      type RequestBodyFor,
      type ResponseBodyFor,
    } from "openapi-msw";
    
    const http = createOpenApiHttp<paths>();
    
    // A union of all possible GET paths.
    type Paths = PathsFor<typeof http.get>;
    
    // The request body for POST /tasks.
    type RequestBody = RequestBodyFor<typeof http.post, "/tasks">;
    
    // The response body for GET /tasks.
    type ResponseBody = ResponseBodyFor<typeof http.get, "/tasks">;