OpenAPI is a tool for documenting REST API endpoints, but its YAML-based format can be cumbersome to write manually, especially for those using TypeScript, which already involves defining types for requests and responses. Open-source projects like tsoa, Deepkit, and Spot can automate the conversion of TypeScript code into OpenAPI documentation using the TypeScript Compiler API. This API, though considered unstable, offers robust functionalities such as parsing TypeScript source files, type-checking programs, and inspecting abstract syntax trees. Tools like tsoa can efficiently transform TypeScript code into OpenAPI documents by leveraging the TypeScript Compiler API to extract metadata from code elements, convert these into internal models, and finally output the data as YAML in the OpenAPI format. Additionally, tsoa provides automatic request validation based on the inferred types, which can prevent errors from reaching the server, and tools like Highlight can further assist by providing insight into how errors occur. The TypeScript Compiler API's capabilities extend beyond generating OpenAPI documents, offering potential for other applications like auto-generating forms or React component properties.