Exports
The export declaration enables exports for the API.
Declaration
ruby
Apiwork::API.define '/api/v1' do
export :openapi
export :typescript
export :zod
endConfiguration
Export options and endpoint behavior are configured in the block:
ruby
export :openapi do
key_format :camel
endpoint do
mode :always
path '/openapi.json'
end
endExports inherit key_format from the API by default.
Endpoint Mode
| Mode | Behavior |
|---|---|
:auto | Development only (default) |
:always | Always mount endpoint |
:never | Never mount endpoint (rake/code only) |
ruby
export :openapi do
endpoint do
mode :auto # Only in development (default)
end
end
export :typescript do
endpoint do
mode :never # Generate via rake task only
end
endCustom Path
ruby
export :openapi do
endpoint do
path '/openapi.json' # Instead of /.openapi
end
endDefault paths:
| Declaration | Endpoint |
|---|---|
export :openapi | GET /api/v1/.openapi |
export :typescript | GET /api/v1/.typescript |
export :zod | GET /api/v1/.zod |
See Exports for endpoints, rake tasks, and programmatic generation.
See also
- Export reference — programmatic generation API