opengb
opengb copied to clipboard
TypeScript Codegen
- Use the models generated by OpenAPI, generate our own routes/endpoints
- We already have an OpenAPI generator working
- We already generate an openapi.json, not sure if we should keep that or not
- Override files in OpenAPI: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md
- More info: https://www.notion.so/rivet-gg/OpenGB-SDK-Gen-6ae256f578504241ba2c77aa8225f3a2
- Codegen framework needs to support multiple targets to make it easy to adapt for Unity, Godot, Rust, and Unreal in the future
- Only generate public types
- Keep the codegen as simple as possible
Resulting API should look very similar to our ctx, like:
import Backend from "path/to/backend";
let backend = new Backend({ endpoint: "https://abc.opengb.rivet.gg" }); // endpoint is required
await backend.modules.users.create({
// Request body
});
Should use vanilla fetch API under the hood with a custom error type