Kde stiahnuť strojovo čitateľnú špecifikáciu, ako si z nej vygenerovať klienta a kde si volania vyskúšať.Where to download the machine-readable specification, how to generate a client from it and where to try the calls.
1 min čítania1 min read
#openapi
#špecifikácia
#klient
#generovanie
#scalar
#openapi
#specification
#client
#code generation
#scalar
Obe API plochy — Enterprise API aj SAPI-SK — sú popísané jednou OpenAPI špecifikáciou.
Nie je to ručne písaný dokument: vzniká z definícií samotných rout a rozchod medzi
ňou a kódom zachytí test už na strane API. Čo si z nej stiahnete, teda zodpovedá tomu,
čo server naozaj robí.
Kompletnú referenciu so schémami, príkladmi požiadaviek aj odpovedí a tlačidlom Try it
nájdete na /docs. Enterprise API je predvolené, SAPI-SK je pod záložkou
/docs#sapi.
Generovanie klienta
Špecifikáciu prijme ktorýkoľvek bežný generátor (openapi-generator, orval, NSwag,
Kiota). Väčšina operácií má vyplnené operationId a práve z neho generátory odvodzujú
názvy funkcií — createApiKey, listApiKeys, getBalance. Rovnaký postup používame aj
my sami: klient, ktorým portál volá vlastné API, je generovaný z tohto súboru.
Both API surfaces — the Enterprise API and SAPI-SK — are described by a single OpenAPI
specification. It is not a hand-written document: it is produced from the route
definitions themselves, and any drift between it and the code is caught by a test on
the API side. What you download therefore matches what the server actually does.
The complete reference, with schemas, request and response examples and a Try it
button, lives at /docs. The Enterprise API is the default; SAPI-SK sits under
the /docs#sapi tab.
Generating a client
Any common generator accepts the specification (openapi-generator, orval, NSwag, Kiota).
Most operations carry an operationId, and that is what generators derive function names
from — createApiKey, listApiKeys, getBalance. We follow the same route ourselves:
the client the portal uses to call our own API is generated from this file.