Skip to content

feat(api): multi-slide rendering (response_format=json + slide_index) - #89

Merged
ajianaz merged 1 commit into
developfrom
feat/multi-slide-api
Sep 17, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/multi-slide-api

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

What

POST /api/render previously always rendered slide 0 only and returned raw
PNG bytes — carousels (multi-slide templates like carousel-default) were
unreachable over HTTP, and the CLI could render them only by writing to a
directory.

Two additive request fields:

  • response_format: "json" — renders every slide and returns a JSON
    envelope: {template, slides, width, height, data: [{index, png_base64}…]}.
    Dimensions are template canvas × scale. Content-Type: application/json.
  • slide_index: N — with the default png response, renders slide N
    instead of slide 0.

Validation added: empty slides array → 400; slide_index out of range → 400
(descriptive message with slide count). Everything defaults to the previous
behavior when the new fields are absent.

Why

Server-side automation (cron pipelines, integration workflows) needs to render
full carousels in one call and receive machine-parseable output; base64 PNG
entries can be decoded straight into MinIO uploads or Discord attachments.

Testing

  • 4 new integration tests in tests/api_server.rs: json multi-slide envelope
    (3 slides, dims check at scale 0.5), slide_index PNG selection, out-of-range
    index → 400, empty slides → 400. Full api_server suite: 26/26 pass
  • cargo clippy --all-targets -- -D warnings clean; cargo fmt applied
  • Docs: docs/api/endpoints.md request table + multi-slide example +
    response-format section; CHANGELOG [Unreleased] entry added

POST /api/render previously always rendered slide 0 and returned raw PNG.
Now:

- response_format: "json" renders every slide and returns a JSON envelope
  {template, slides, width, height, data: [{index, png_base64}...]}
- slide_index: N renders a specific slide with the default png response
- empty slides array and out-of-range slide_index are rejected with 400

Docs: endpoints.md updated with field table + multi-slide example.
Tests: 4 new integration tests (json multi-slide, slide_index png,
out-of-range 400, empty slides 400) - 26/26 api_server suite passes,
clippy -D warnings clean.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 929c186 into develop Sep 17, 2026
11 checks passed
@ajianaz
ajianaz deleted the feat/multi-slide-api branch September 17, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant