@hasagi/schema
v0.7.1
Published
The schema / type-generation toolkit behind Hasagi. It reads the League of Legends client's own API description (the LCU "help" schema, exposed by a running client), builds an OpenAPI v3 (swagger) document from it, and generates the TypeScript definitions
Readme
@hasagi/schema
The schema / type-generation toolkit behind Hasagi. It reads the League of Legends client's own API description (the LCU "help" schema, exposed by a running client), builds an OpenAPI v3 (swagger) document from it, and generates the TypeScript definitions that power typed LCU requests and events.
This is the engine used by the @hasagi/cli schema
command and the generated types shipped in
@hasagi/core/types and
@hasagi/types.
Most users don't need this package directly — use
hasagi schema(from@hasagi/cli) to generate types, or just consume the pre-generated types. Use@hasagi/schemaonly if you're building your own generation pipeline.
Installation
npm install @hasagi/schemaAPI
import { getExtendedHelp, getSwagger, getTypeScript } from "@hasagi/schema";
// 1. Fetch and normalize the LCU help schema (requires a running League client).
const xhelp = await getExtendedHelp();
// 2. Build an OpenAPI v3 (swagger) document.
const swagger = await getSwagger(xhelp);
// 3. Generate the TypeScript definitions.
const { lcuTypes, lcuEndpoints, lcuEvents } = await getTypeScript(swagger, xhelp /*, namespace? */);getExtendedHelp()— retrieves and normalizes the LCU's API description from a running client.getSwagger(xhelp)— produces an OpenAPI v3 schema object (with helpers for generating types).getTypeScript(swagger, xhelp, namespace?)— returns the generatedlcuTypes,lcuEndpointsandlcuEventssource strings. Pass anamespaceto wrap the generated types.
Disclaimer
Hasagi is not endorsed by Riot Games and does not reflect the views or opinions of Riot Games or anyone officially involved in producing or managing Riot Games properties. Riot Games and all associated properties are trademarks or registered trademarks of Riot Games, Inc.
