3 ms·
OpenAPI is cluttered with protocol specifics that are irrelevant to something that is native to your host language (function signatures). Think of it as header
by mirekrusin 3y ago
OpenAPI is cluttered with protocol specifics that are irrelevant to something that is native to your host language (function signatures). Think of it as header file for api that is highly constrained (functions, notifications and json data types only - no classes, instances, polymorphism, no way to encode callbacks or returning functions etc. just basic algebra on json types - type aliases and unions).
Imagine api like this:
// @endpoint wss://localhost:3000/api/v1
notification heartbeat = {
timestamp: number
}
type User = {
id: string,
email: Email
type: "normal" | "admin"
}
type AuthError = {
message: string,
code: -123
}
type NotLoggedInError = {
message: string,
code: -124
}
// Logs you in.
//
// @throws AuthError
login(username: string, password): User
// Adds two numbers.
// @throws NotLoggedInError
add(x: number, y: number): number
// Logs you out.
// @throws NotLoggedInError
logout(): null
It's terse, straight forward and maps to your host programming language naturally.