This is typically called an IDL and TLA mentions inspiration from several examples under "prior art." At the top is the Web Assembly Interface proposal which has the wit [0] format,
[0] https://github.com/WebAssembly/component-model/blob/main/des...
[0] https://github.com/WebAssembly/component-model/blob/main/des...
IDL := Interface Description Language
TLA := linked article