Skip to content

Commit

Permalink
ci: release package
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed May 17, 2024
1 parent 985a799 commit afc5162
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 55 deletions.
52 changes: 0 additions & 52 deletions .changeset/tasty-roses-walk.md

This file was deleted.

53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <christoph@frickeonline.de>",
"description": "Tiny, type-safe wrapper around MSW for type inference from OpenAPI schemas.",
Expand Down

0 comments on commit afc5162

Please sign in to comment.