feat(api): multi-slide rendering (response_format=json + slide_index) - #89
Merged
Merged
Conversation
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.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
POST /api/render previously always rendered slide 0 only and returned raw
PNG bytes — carousels (multi-slide templates like
carousel-default) wereunreachable 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 JSONenvelope:
{template, slides, width, height, data: [{index, png_base64}…]}.Dimensions are template canvas × scale. Content-Type:
application/json.slide_index: N— with the defaultpngresponse, renders slide Ninstead of slide 0.
Validation added: empty
slidesarray → 400;slide_indexout 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
tests/api_server.rs: json multi-slide envelope(3 slides, dims check at scale 0.5),
slide_indexPNG selection, out-of-rangeindex → 400, empty slides → 400. Full api_server suite: 26/26 pass
cargo clippy --all-targets -- -D warningsclean;cargo fmtapplieddocs/api/endpoints.mdrequest table + multi-slide example +response-format section; CHANGELOG [Unreleased] entry added