Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: release package #47

Merged
merged 1 commit into from
May 18, 2024
Merged

ci: release package #47

merged 1 commit into from
May 18, 2024

Conversation

github-actions[bot]
Copy link
Contributor

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

openapi-msw@0.5.0

Minor Changes

  • #41 fe70d20 Thanks @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.

    /*
    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 });
    });

@christoph-fricke christoph-fricke merged commit b7cd97b into main May 18, 2024
@christoph-fricke christoph-fricke deleted the changeset-release/main branch May 18, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant