Documentation previewThese docs are actively being built. Some pages may change as the framework and examples are finalized.
Skip to content

OpenAPI

GoForj can generate OpenAPI output from the App's indexed HTTP surface.

The generated HTTP runtime can serve the OpenAPI document through a built-in API reference route.

Generated Output

The default OpenAPI path is:

text
build/openapi.json

Run:

bash
forj build

to refresh generated components, Wire, API indexing, OpenAPI output, and the binary.

Swagger/API Reference Route

When HTTP is enabled, the generated HTTP runtime can serve:

text
GET /swagger
GET /swagger/
GET /swagger/doc.json

/swagger serves the API reference UI. /swagger/doc.json serves the OpenAPI JSON.

Configuration

Swagger/API reference serving is controlled by:

text
API_SWAGGER_ENABLED=true

Legacy fallback:

text
SWAGGER_ENABLED=true

The OpenAPI spec path can be overridden:

text
OPENAPI_SPEC_PATH=build/openapi.json

Validation

GoForj includes a maintainer validation command for generated OpenAPI behavior:

bash
forj test:openapi

This command is hidden and intended for framework validation rather than normal App development.

Current Limits

OpenAPI output depends on what API indexing can infer from the source.

Use conventional route/controller patterns when you want strong generated metadata. Keep unusual dynamic behavior documented and tested.

Common Mistakes

Common mistakes

  • Do not edit build/openapi.json by hand.
  • Do not assume OpenAPI output proves runtime authorization behavior.
  • Do not expose Swagger in environments where your deployment policy disables it.
  • Do not ignore diagnostics when generated operations are missing.

Next Steps