If you're looking to define your API in TypeScript and generate a Swagger/OpenAPI documentation, check out https://github.com/airtasker/spot
This tool not only creates REST API documentation but also allows you to set up a mock server with randomized data that aligns with the API definition (for client testing) as well as a data model validator (for server testing).
Here's an example from the project README:
import { api, endpoint, request, response, body } from "@airtasker/spot";
@api({
name: "My API"
})
class Api {}
@endpoint({
method: "POST",
path: "/users"
})
class CreateUser {
@request
request(@body body: CreateUserRequest) {}
@response({ status: 201 })
response(@body body: CreateUserResponse) {}
}
interface CreateUserRequest {
firstName: string;
lastName: string;
}
interface CreateUserResponse {
firstName: string;
lastName: string;
role: string;
}