Skip to content

Add render template support#975

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

Add render template support#975
MovinduJay wants to merge 4 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 experimental template rendering, including a new renderTemplate API to request a template + input and receive rendered output.
    • Introduced new request/response models for template rendering.
  • Documentation
    • Added a new Java documentation code sample showing how to enable and use the experimental render route.
  • Tests
    • Added/expanded unit tests for request serialization, HTTP payload generation, builder/accessors, and response deserialization (including structured rendered JSON).

@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: 9c1b7584-b24b-455d-b595-82277b40a0f9

📥 Commits

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

📒 Files selected for processing (1)
  • .code-samples.meilisearch.yaml
💤 Files with no reviewable changes (1)
  • .code-samples.meilisearch.yaml

📝 Walkthrough

Walkthrough

Adds experimental render template support to the Java SDK: new request and response models, a Client.renderTemplate() API that posts to /render-template, validation tests for serialization and deserialization, 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 defines template and input maps with JSON toString() output; RenderTemplateResult defines template and rendered fields with Lombok accessors.
Client.renderTemplate method
src/main/java/com/meilisearch/sdk/Client.java
Adds renderTemplate(RenderTemplateRequest) that posts to /render-template and returns RenderTemplateResult.
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
Adds request serialization, HTTP body, builder, and result deserialization tests, plus a YAML sample that enables renderRoute and calls client.renderTemplate(request).

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Sample
  participant Client
  participant MeilisearchAPI
  Sample->>Client: renderTemplate(request)
  Client->>MeilisearchAPI: POST /render-template
  MeilisearchAPI-->>Client: RenderTemplateResult
  Client-->>Sample: RenderTemplateResult
Loading

Possibly related issues

Poem

🐇 A template hopped in, all fresh and neat,
With input and template in rhythm complete.
The client gave /render-template a spin,
And out came the render, tidy within.

🚥 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 is concise and accurately summarizes the main change: adding render template support.
Linked Issues check ✅ Passed The PR adds the render-template method, request/result models, tests, and the code sample, and the sample opts into the experimental feature.
Out of Scope Changes check ✅ Passed The changes are tightly scoped to render-template support, related tests, and the code sample with no unrelated additions.
✨ 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?

@Strift Strift 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.

Hey, thanks for your PR!

The CI is not passing. I suggest running linter + formatter + tests locally before requesting another review 🙏

@MovinduJay

Copy link
Copy Markdown
Author

Hi @Strift, Thanks for the review! I fixed the YAML lint issue and reran the formatter, linter, and tests locally.

@MovinduJay MovinduJay requested a review from Strift July 8, 2026 09:06
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)

2 participants