-
Notifications
You must be signed in to change notification settings - Fork 6
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
Question: how to support multiple content-types for the same response? #39
Comments
We don't support multiple content-types yet, but we'll work on it in the near future. I'm thinking of working with the following format, what do you think? export type UserApiSpec = Tspec.DefineApiSpec<{
tags: ["Users"];
paths: {
"/api/users": {
get: {
summary: "Get all users";
responses: {
/** @mediaType ["application/json", "text/xml"] */
200: Users[];
};
};
};
};
}>; |
Glad that you find it useful and will consider adding the feature. export type UserApiSpec = Tspec.DefineApiSpec<{
tags: ["Users"];
paths: {
"/api/users": {
get: {
summary: "Get all users";
responses: {
200: {
"application/json": Users[],
"application/xml": UsersXML[],
"text/plain": string,
}
};
};
};
};
}>; Obviously this example should be reworked to use annotations instead. |
any updates on this? @hyeonss0417 we'd appreciate update on multipart/form-data |
@yeonjoon-ridi export type FileApiSpec = Tspec.DefineApiSpec<{
paths: {
'/files/upload': {
post: {
summary: 'Upload File',
/** @mediaType multipart/form-data */
body: {
file: Tspec.BinaryString;
},
responses: { 200: { fileName: string } },
},
},
},
}>; Or do you want to create schemas with multiple response formats within the same status code, as discussed above? |
Hey,
Is it possible to describe a response with multiple content-types using tspec?
Example from: https://swagger.io/docs/specification/describing-responses/
It seems that I would add the mediatype as js-doc to the reponse like in this example: https://ts-spec.github.io/tspec/guide/file-upload-download#file-download
But that just takes the last value:
The text was updated successfully, but these errors were encountered: