[#zimic] Added strict http status codes. Now, Zimic validates status codes against the RFC 9110 spec.
[#zimic] Added support to non-numeric OpenAPI status codes, such as 2xx, 3XX, and default. Now, they are interpreted as defined in the spec: their responses are applied for all status code not declared.
export type MyServiceSchema = HttpSchema.Paths<{
'/users-with-non-numeric-status-codes': {
POST: {
response: MergeHttpResponsesByStatusCode<
[
{
100: {};
201: MyServiceComponents['responses']['userCreated'];
400: MyServiceComponents['responses']['validationError'];
404: MyServiceComponents['responses']['notFoundError'];
503: {};
},
{ [StatusCode in HttpStatusCode.Information]: {} },
{ [StatusCode in HttpStatusCode.Success]: {} },
{ [StatusCode in HttpStatusCode.ClientError]: MyServiceComponents['responses']['clientError'] },
{ [StatusCode in HttpStatusCode.ServerError]: MyServiceComponents['responses']['serverError'] },
{ [StatusCode in HttpStatusCode]: MyServiceComponents['responses']['error'] },
]
>;
};
};
}
MergeHttpResponsesByStatusCode takes a tuple of responses by status code types and returns a merged type, where the first declared status code is considered, ignoring the same codes appearing in later types. An alternative mental model is that the types are iterated from end to start of the tuple and override the result type with their status codes.
Features
2xx
,3XX
, anddefault
. Now, they are interpreted as defined in the spec: their responses are applied for all status code not declared.As an example:
is generated as:
MergeHttpResponsesByStatusCode
takes a tuple of responses by status code types and returns a merged type, where the first declared status code is considered, ignoring the same codes appearing in later types. An alternative mental model is that the types are iterated from end to start of the tuple and override the result type with their status codes.Closes #272.