As someone who has used JAX-RS (Java) and ASP.NET, APIs are basically created with these kinds of annotations right in the language.
@GET
public Character getCharacter(@PathParam("id") int id) {
return db.getCharacter(id);
}
That's very similar to TypeSpec's
op getCharacter(@path id: safeint): Character;
Java and C# classes already have the type information that you'd be getting from a TypeSpec:
// TypeSpec
model Character {
name: string;
id: safeint;
status: "Alive" | "Dead";
class: Class;
}
enum Class { warrior; wizard; }
// C#
public class Character {
public string Name { get; set; }
public int Id { get; set; }
public Status Status { get; set; }
public CharacterClass CharacterClass { get; set; }
}
public enum Status { Alive, Dead }
public enum CharacterClass { Warrior, Wizard }
But with C#/Java you don't need to write the spec and make sure that it stays in sync with what your endpoints are actually doing. TypeSpec looks a lot better than writing YAML by hand, but I'd still rather something that was tied to the actual code that will be executing so that things are never out of sync or wrong.