Multiple errors for one status code #7543
-
We are expecting multiple error types for a single status code. responses:
'400':
description: Bad request
content:
application/json:
schema:
oneOf:
- $ref: '#/components/responses/InvalidFormat'
- $ref: '#/components/responses/DuplicatedTitle'
- $ref: '#/components/responses/MethodArgumentNotValid'
examples:
InvalidFormat:
value:
status: 400
message: XXXXXXX
DuplicatedTitle:
value:
status: 400
message: XXXXXXXX
MethodArgumentNotValid:
value:
status: 400
message: XXXXXXX |
Beta Was this translation helpful? Give feedback.
Answered by
timotheeguerin
Jun 5, 2025
Replies: 1 comment 2 replies
-
You can do this import "@typespec/http";
using Http;
op bad(): Error1 | Error2 | Error3;
@error
model Error {
@statusCode _: 400;
}
model Error1 is Error {
error1: string;
}
model Error2 is Error {
error1: string;
}
model Error3 is Error {
error1: string;
}
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you can but seems like we have a bug where it doesn't show up when you have those multiple response
playground