My project uses ts-rs to take rust objects, and generate typescript types, to be used for an API client.
While the types are nice to have, I'd also like to be able to use tsoa to build an OpenAPI spec.
All was going well until I tried to use my form in a Get :
/**
* List all the media for your user
*
* `HTTP.GET /account/list_media`
*/
@Get("/account/list_media")
listMedia(
@Queries() form: ListMedia = {},
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ListMedia, ListMediaResponse>(
HttpType.Get,
"/account/list_media",
form,
options,
);
}
And got this error:
GenerateMetadataError: @Queries('form') only support 'refObject' or 'nestedObjectLiteral' types. If you want only one query parameter, please use the '@Query' decorator.
Turns out, tsoa only supports interfaces, and not types, even though they are trivially the same:
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
// Doesn't work
export type ListMedia = { page?: number; limit?: number };
// Works
export interface ListMedia {
page?: number;
limit?: number;
}
The strangest part about this, is that the return types (which are also all type), and @Body() seem to work perfectly fine. Only the Queries() doesn't work.
My project uses ts-rs to take rust objects, and generate typescript types, to be used for an API client.
While the types are nice to have, I'd also like to be able to use
tsoato build an OpenAPI spec.All was going well until I tried to use my form in a
Get:And got this error:
GenerateMetadataError: @Queries('form') only support 'refObject' or 'nestedObjectLiteral' types. If you want only one query parameter, please use the '@Query' decorator.Turns out,
tsoaonly supports interfaces, and not types, even though they are trivially the same:The strangest part about this, is that the return types (which are also all
type), and@Body()seem to work perfectly fine. Only theQueries()doesn't work.