microsoft / microsoft/typespec

Additional built-in response type: 422 Unprocessable Content

Open
#6,615 0 comments 0 reactions 0 assignees View on GitHub
feature lib:http triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

### Clear and concise description of the problem

There are handful of built-in http status code data types: https://typespec.io/docs/libraries/http/reference/data-types/

Currently supports the main ones, 200 (OkResponse), 201 (CreatedResponse), 204 (NoContentResponse), 400 (BadRequestResponse), 401 (UnauthorizedResponse), 403 (ForbiddenResponse), 404 (NotFoundResponse), among a couple others.

I would like to recommend adding a 422 Unprocessable Content: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/422

This is helpful when the request was authorized and valid syntax, but something in the request was missing. I can manually add this in my spec of course, but it would be nice to have this built in, since it seems like a common one that belongs among the others.

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Read the [docs](https://typespec.io/docs/).
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.