Skip to content

Add render template support#975

Open
MovinduJay wants to merge 3 commits into
meilisearch:mainfrom
MovinduJay:add-render-template-route
Open

Add render template support#975
MovinduJay wants to merge 3 commits into
meilisearch:mainfrom
MovinduJay:add-render-template-route

Conversation

@MovinduJay

@MovinduJay MovinduJay commented Jun 30, 2026

Copy link
Copy Markdown

Pull Request

Related issue

Fixes #974

What does this PR do?

Adds Java SDK support for the experimental /render-template route.

  • Added RenderTemplateRequest to serialize the render template request body
  • Added RenderTemplateResult to represent the API response
  • Added Client#renderTemplate to call POST /render-template
  • Added request serialization tests for render template requests with and without input
  • Added a code sample in .code-samples.meilisearch.yaml

How I tested

  • Ran ./gradlew.bat spotlessApply
  • Ran ./gradlew.bat compileJava
  • Ran ./gradlew.bat test --tests "com.meilisearch.sdk.RenderTemplateRequestTest" -x jacocoTestCoverageVerification
  • Ran bash ./scripts/lint.sh
  • Ran ./gradlew.bat clean build

Note: clean build fails locally only on SettingsHandlerTest with java.net.ConnectException because a local Meilisearch instance is not running.

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features
    • Added Java SDK support for rendering templates, including new request/response models and a renderTemplate API to obtain rendered output.
    • Added a Java documentation code sample demonstrating usage of the experimental template rendering feature.
  • Tests
    • Added/expanded unit tests covering request toString() output, HTTP request serialization, builder/accessor behavior, and response deserialization.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f9e806a7-1baf-4947-a78c-803a24ef2de7

📥 Commits

Reviewing files that changed from the base of the PR and between 3202599 and a44e5c1.

📒 Files selected for processing (1)
  • src/test/java/com/meilisearch/sdk/model/RenderTemplateResultTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/com/meilisearch/sdk/model/RenderTemplateResultTest.java

📝 Walkthrough

Walkthrough

Adds experimental render template support to the Java SDK: a RenderTemplateRequest model with template/input maps and custom JSON serialization, a RenderTemplateResult response model, a Client.renderTemplate() method posting to /render-template, unit tests for serialization and builder behavior, and a .code-samples.meilisearch.yaml entry.

Changes

Render Template Experimental Feature

Layer / File(s) Summary
Request and result models
src/main/java/com/meilisearch/sdk/RenderTemplateRequest.java, src/main/java/com/meilisearch/sdk/model/RenderTemplateResult.java
RenderTemplateRequest holds template (required) and input (optional) maps with Lombok accessors and a custom toString() that serializes to JSON; RenderTemplateResult holds template and rendered Object fields with Lombok getters.
Client.renderTemplate method
src/main/java/com/meilisearch/sdk/Client.java
New public method issues a POST to /render-template with the request body and returns RenderTemplateResult, throwing MeilisearchException on error.
Tests and code sample
src/test/java/com/meilisearch/sdk/RenderTemplateRequestTest.java, src/test/java/com/meilisearch/sdk/model/RenderTemplateResultTest.java, .code-samples.meilisearch.yaml
Unit tests verify request serialization, HTTP request content, builder/getter behavior, and result deserialization; YAML sample demonstrates enabling the renderRoute experimental feature and calling client.renderTemplate(request).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Poem

🐇 A template sprang up, all tidy and bright,
With input and template in JSON just right.
The client hopped to /render-template with glee,
And rendered a result as neat as can be.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title succinctly reflects the main change: adding render template support.
Linked Issues check ✅ Passed The PR appears to satisfy #974 by adding the endpoint method, request/result models, tests, and the YAML code sample, with experimental opt-in shown in the sample.
Out of Scope Changes check ✅ Passed All changes are directly tied to render template support; no unrelated functionality was introduced.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/com/meilisearch/sdk/Client.java`:
- Around line 492-495: The Client.renderTemplate() method is currently always
callable, so the experimental opt-in is only documented and not enforced. Update
the Client API to gate renderTemplate behind explicit opt-in state on the
client, or expose it only through an opt-in-specific surface, and use the
existing Client and renderTemplate() symbols to ensure calls fail or are
unavailable until the caller has opted in first.

In `@src/main/java/com/meilisearch/sdk/model/RenderTemplateResult.java`:
- Around line 6-10: RenderTemplateResult currently has package-private fields
that Jackson’s default ObjectMapper won’t populate, so template and rendered
deserialize as null. Update the RenderTemplateResult model to make these
properties Jackson-visible by adding standard setters/getters or explicit
Jackson annotations on the existing template and rendered members, while keeping
the class name and field names unchanged so deserialization works correctly.

In `@src/test/java/com/meilisearch/sdk/RenderTemplateRequestTest.java`:
- Around line 13-85: The current tests only validate
RenderTemplateRequest.toString(), so they miss the real request serialization
path used by Client.renderTemplate() through BasicRequest and
JsonHandler.encode(...). Add coverage that exercises the actual outgoing body
serialization for RenderTemplateRequest, including the case where input is
absent, and assert the wire-format JSON produced by the request serializer
rather than only the model’s toString() output.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02f51f49-4d32-4234-a18a-9d389a80f85f

📥 Commits

Reviewing files that changed from the base of the PR and between acfe026 and 83941e4.

📒 Files selected for processing (5)
  • .code-samples.meilisearch.yaml
  • src/main/java/com/meilisearch/sdk/Client.java
  • src/main/java/com/meilisearch/sdk/RenderTemplateRequest.java
  • src/main/java/com/meilisearch/sdk/model/RenderTemplateResult.java
  • src/test/java/com/meilisearch/sdk/RenderTemplateRequestTest.java

Comment thread src/main/java/com/meilisearch/sdk/Client.java
Comment thread src/main/java/com/meilisearch/sdk/model/RenderTemplateResult.java Outdated
Comment thread src/test/java/com/meilisearch/sdk/RenderTemplateRequestTest.java
Adds request serialization coverage and response deserialization coverage, and updates RenderTemplateResult for safer JSON mapping.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/test/java/com/meilisearch/sdk/model/RenderTemplateResultTest.java`:
- Around line 11-20: The RenderTemplateResultTest currently only verifies the
scalar-string path in JacksonJsonHandler.decode, so add another case that
decodes a JSON object or array for the rendered field and asserts the structured
value is preserved. Reuse RenderTemplateResult and JacksonJsonHandler in the new
test, and verify both template and rendered so the new Object mapping is
covered.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9318707c-5f72-4704-9899-99f7b799071a

📥 Commits

Reviewing files that changed from the base of the PR and between 83941e4 and 3202599.

📒 Files selected for processing (3)
  • src/main/java/com/meilisearch/sdk/model/RenderTemplateResult.java
  • src/test/java/com/meilisearch/sdk/RenderTemplateRequestTest.java
  • src/test/java/com/meilisearch/sdk/model/RenderTemplateResultTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/meilisearch/sdk/model/RenderTemplateResult.java

@MovinduJay

Copy link
Copy Markdown
Author

Hi @Strift , Can you please review this?

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.

[Meilisearch v1.48.0] Add render template (experimental)

1 participant