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

Add SuccessResponseJSON, ErrorResponseJSON helpers #1456

Merged
merged 1 commit into from
Nov 23, 2023
Merged

Conversation

drwpow
Copy link
Contributor

@drwpow drwpow commented Nov 23, 2023

Changes

Adds SuccessResponseJSON and ErrorResponseJSON helpers for easier usage. Before/after:

- type Response =
-   | SuccessResponse<FilterKeys<ResponseObjectMap<paths["/my/endpoint"]["get"]>, "application/json">>
-   | ErrorResponse<FilterKeys<ResponseObjectMap<paths["/my/endpoint"]["get"]>, "application/json">>;
+ type Response =
+   | SuccessResponseJSON<paths["/my/endpoint"]["get"]>
+   | ErrorResponseJSON<paths["/my/endpoint"]["get"]>;

Note this won’t be used in openapi-fetch for ✨ reasons ✨. But is a useful utility.

Note—will probably keep Success* and Error* separated for the forseeable future because they’re trivial to combine in a union, and you frequently will want to have these in different codepaths anyway.

How to Review

N/A

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

Copy link

changeset-bot bot commented Nov 23, 2023

🦋 Changeset detected

Latest commit: 3eb4c76

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
openapi-typescript-helpers Patch
openapi-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@drwpow drwpow merged commit 5be2082 into main Nov 23, 2023
9 checks passed
@drwpow drwpow deleted the addl-type-helpers branch November 23, 2023 18:18
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