From 9a7a3be7a15d3f780267925edca72d04bf9a6b2f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 17 May 2024 20:16:58 +0000 Subject: [PATCH] ci: release package --- .changeset/tasty-roses-walk.md | 52 --------------------------------- CHANGELOG.md | 53 ++++++++++++++++++++++++++++++++++ package-lock.json | 4 +-- package.json | 2 +- 4 files changed, 56 insertions(+), 55 deletions(-) delete mode 100644 .changeset/tasty-roses-walk.md diff --git a/.changeset/tasty-roses-walk.md b/.changeset/tasty-roses-walk.md deleted file mode 100644 index 78e18d5..0000000 --- a/.changeset/tasty-roses-walk.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -"openapi-msw": minor ---- - -Added `response` helper to the resolver-info argument. It provides an granular type-safety when creating HTTP responses. Instead of being able to return any status code, `response` limits status codes, content types, and their response bodies to the combinations defined by the given OpenAPI spec. - -```typescript -/* -Imagine this endpoint specification for the following example: - -/response-example: - get: - summary: Get Resource - operationId: getResource - responses: - 200: - description: Success - content: - application/json: - schema: - $ref: "#/components/schemas/Resource" - text/plain: - schema: - type: string - enum: ["Hello", "Goodbye"] - 204: - description: NoContent - "5XX": - description: Error - content: - text/plain: - schema: - type: string -*/ - -const handler = http.get("/response-example", ({ response }) => { - // Error: Status Code 204 only allows empty responses - const invalidRes = response(204).text("Hello"); - - // Error: Status Code 200 only allows "Hello" as text - const invalidRes = response(200).text("Some other string"); - - // No Error: This combination is part of the defined OpenAPI spec - const validRes = response(204).empty(); - - // No Error: This combination is part of the defined OpenAPI spec - const validRes = response(200).text("Hello"); - - // Using a wildcard requires you to provide a matching status code for the response - const validRes = response("5XX").text("Fatal Error", { status: 503 }); -}); -``` diff --git a/CHANGELOG.md b/CHANGELOG.md index 8524cca..724f38f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,58 @@ # openapi-msw +## 0.5.0 + +### Minor Changes + +- [#41](https://github.com/christoph-fricke/openapi-msw/pull/41) [`fe70d20`](https://github.com/christoph-fricke/openapi-msw/commit/fe70d20494692df764188c35105cbf6be178d687) Thanks [@christoph-fricke](https://github.com/christoph-fricke)! - Added `response` helper to the resolver-info argument. It provides an granular type-safety when creating HTTP responses. Instead of being able to return any status code, `response` limits status codes, content types, and their response bodies to the combinations defined by the given OpenAPI spec. + + ```typescript + /* + Imagine this endpoint specification for the following example: + + /response-example: + get: + summary: Get Resource + operationId: getResource + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/Resource" + text/plain: + schema: + type: string + enum: ["Hello", "Goodbye"] + 204: + description: NoContent + "5XX": + description: Error + content: + text/plain: + schema: + type: string + */ + + const handler = http.get("/response-example", ({ response }) => { + // Error: Status Code 204 only allows empty responses + const invalidRes = response(204).text("Hello"); + + // Error: Status Code 200 only allows "Hello" as text + const invalidRes = response(200).text("Some other string"); + + // No Error: This combination is part of the defined OpenAPI spec + const validRes = response(204).empty(); + + // No Error: This combination is part of the defined OpenAPI spec + const validRes = response(200).text("Hello"); + + // Using a wildcard requires you to provide a matching status code for the response + const validRes = response("5XX").text("Fatal Error", { status: 503 }); + }); + ``` + ## 0.4.0 ### Minor Changes diff --git a/package-lock.json b/package-lock.json index 8a45354..4858e66 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "openapi-msw", - "version": "0.4.0", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "openapi-msw", - "version": "0.4.0", + "version": "0.5.0", "license": "MIT", "dependencies": { "openapi-typescript-helpers": "^0.0.7" diff --git a/package.json b/package.json index 43ae17a..cb952be 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "$schema": "https://json.schemastore.org/package.json", "name": "openapi-msw", "type": "module", - "version": "0.4.0", + "version": "0.5.0", "license": "MIT", "author": "Christoph Fricke ", "description": "Tiny, type-safe wrapper around MSW for type inference from OpenAPI schemas.",