mirror of
https://github.com/modrinth/code.git
synced 2026-08-24 16:44:51 +00:00
1.3 KiB
1.3 KiB
name, description
| name | description |
|---|---|
| api-module | Add an API endpoint module to packages/api-client from an OpenAPI schema. Use for new backend endpoints, API client modules, or tasks that provide an OpenAPI schema. |
Add an API Module
Read the applicable AGENTS.md files before you edit code.
Read the API module standard in full.
- Identify the OpenAPI schema from the request. If more than one schema is possible, ask the user to select one.
- Read the schema. Identify each endpoint, HTTP method, request type, response type, and path parameter.
- Get the service and version from the URL prefix. For example, map
/v3/projectstolabrinth/v3/. - Define the API types in
types.ts. Make each type match the schema exactly. - Do not change, rename, or remove API fields.
- Make a module class that extends
AbstractModule. Implement each endpoint withthis.client.request()orthis.client.upload(). - Use the request-option pattern from the standard. Do not call
$fetch,fetch, or another HTTP client directly. - Add the module to
MODULE_REGISTRYso the client can instantiate it. - Export new service types from the applicable barrel
index.ts. - Check the module paths, registry key, public type exports, and endpoint types.
Run only the checks that the user or the applicable AGENTS.md permits.