NestJS-hosted apibuilder code generator service for Forsyte API specs.
| Key | Output |
|---|---|
forsyte_nestjs_dtos |
{app}-enums.ts, {app}-dtos.ts under generated/{application-key}/ (or src/generated/ in consumer repos) |
forsyte_nestjs_controllers |
{app}-controllers.ts under generated/{application-key}/ (or src/generated/ in consumer repos) |
Example for forsyte/address:
generated/address/
βββ address-enums.ts
βββ address-dtos.ts
βββ address-controllers.ts
Example for forsyte/feature_flag:
generated/feature-flag/
βββ feature-flag-dtos.ts
βββ feature-flag-controllers.ts
pnpm install
node test/fixtures/build-fixtures.mjs # refresh fixtures from forsyteco-spec
pnpm start:dev # http://localhost:7050curl http://localhost:7050/generators
curl -X POST http://localhost:7050/invocations/forsyte_nestjs_dtos \
-H "Content-Type: application/json" \
-d @test/fixtures/forms/address-invocation.jsonpnpm validate:local # build + offline spec validation; writes golden files to test-output/
pnpm validate:http # requires pnpm start:devGolden snapshots under test-output/ are regenerated by pnpm validate:local and checked in CI.
Spec route and import conventions: see forsyteco-spec/CONVENTIONS.md.
pnpm build
node scripts/write-consumer-generated.mjs /path/to/consumer-project addressnode test/fixtures/build-fixtures.mjs
pnpm test:e2eExpose port 7050 (e.g. via ngrok), then:
curl -X POST https://api.apibuilder.io/generator_services \
-H "Authorization: Bearer $APIBUILDER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"uri": "https://<your-public-url>"}'Generate from the UI or CLI:
apibuilder code forsyte address 0.0.1 forsyte_nestjs_dtos .Set GENERATED_OUTPUT_ROOT to the project root (not src/). Output lands in src/generated/:
# PowerShell
$env:GENERATED_OUTPUT_ROOT = "C:\Repos\forsyteco-data-gateway"
pnpm generate data_gatewaysrc/generated/
βββ data-gateway/
βββ error/
βββ healthcheck/
βββ tsconfig.json
import { AddressesController as AddressesControllerTrait } from "@/generated/address/address-controllers";
@UseGuards(JwtAuthGuard, IsOrganisationGuard)
export class AddressesController extends AddressesControllerTrait {
constructor(private readonly service: AddressesService) {
super();
}
findOne(organisationIdOrSlug: string, addressId: string): Promise<AddressDto> {
return this.service.getAddressById(addressId, organisationIdOrSlug, organisationIdOrSlug);
}
}