For .NET, it's best to write the spec as annotations on your controllers and request/response classes using NSwag[1].
The situation is similar in the Java world. It's better to annotate, rather than start with your own spec.
For TypeScript, I mostly use a CLI tool[2] that generates type definitions, which I then use in my routing system and controllers to make sure that any changes to paths, requests, and responses are going to cause compiler errors until they're fixed.
1. https://docs.microsoft.com/en-us/aspnet/core/tutorials/getti...
2. https://github.com/horiuchi/dtsgenerator/