Skip to content

Feature: add full response typing for status code, data and headers. #272

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

Merged
merged 1 commit into from
Jul 14, 2021

Conversation

rustyconover
Copy link
Contributor

This commit adds additional type information to the route's response
object that allows types to be created that express the combination
of status code, data and headers for each response.

This type information can be used to "narrow" a response type based on
an HTTP status code. This narrowing is useful since it can prevent type
mismatches where a status code is presumed to have one type but in actuality
it returns another.

Additionally, response headers are now associated with data types and status
codes rather than being free form.

A caveat right now is that only there are no response codes like 3XX or
5XX, every code must be explicitly listed.

This commit adds additional type information to the route's response
object that allows types to be created that express the combination
of status code, data and headers for each response.

This type information can be used to "narrow" a response type based on
an HTTP status code. This narrowing is useful since it can prevent type
mismatches where a status code is presumed to have one type but in actuality
it returns another.

Additionally, response headers are now associated with data types and status
codes rather than being free form.

A caveat right now is that only there are no response codes like 3XX or
5XX, every code must be explicitly listed.
@js2me js2me changed the base branch from master to next July 14, 2021 10:04
@js2me js2me merged commit 0618ff2 into acacode:next Jul 14, 2021
@js2me js2me mentioned this pull request Jul 14, 2021
js2me added a commit that referenced this pull request Jul 14, 2021
* added --unwrap-response-data to unwrap the data item from the response (#268)

* added --unwrap-response-data to unwrap the data item from the response

* add axios --unwrap-response-data

Co-authored-by: Christian Zangl <[email protected]>

* fix: formdata in axios template (#277)

Co-authored-by: Tiago Kaneta <[email protected]>

* Feature: add full response typing for status code, data and headers. (#272)

This commit adds additional type information to the route's response
object that allows types to be created that express the combination
of status code, data and headers for each response.

This type information can be used to "narrow" a response type based on
an HTTP status code. This narrowing is useful since it can prevent type
mismatches where a status code is presumed to have one type but in actuality
it returns another.

Additionally, response headers are now associated with data types and status
codes rather than being free form.

A caveat right now is that only there are no response codes like 3XX or
5XX, every code must be explicitly listed.

* bump: up version to 9.2.0

Co-authored-by: Christian Zangl <[email protected]>
Co-authored-by: Christian Zangl <[email protected]>
Co-authored-by: Tiago Surjus Kaneta <[email protected]>
Co-authored-by: Tiago Kaneta <[email protected]>
Co-authored-by: Rusty Conover <[email protected]>
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.

2 participants