Skip to content

Add example demonstrating custom Scalar render options#1

Closed
Copilot wants to merge 3 commits intofix-issue-4381from
copilot/add-custom-scalar-render-example
Closed

Add example demonstrating custom Scalar render options#1
Copilot wants to merge 3 commits intofix-issue-4381from
copilot/add-custom-scalar-render-example

Conversation

Copy link
Copy Markdown

Copilot AI commented Oct 9, 2025

Description

This PR addresses issue litestar-org#4381 by adding a comprehensive example that demonstrates how to customize Scalar render options using the options parameter in ScalarRenderPlugin.

Changes

1. New Example File

Added docs/examples/openapi/plugins/scalar_render_options.py which demonstrates common Scalar configuration options:

ScalarRenderPlugin(
    options={
        # Hide the sidebar to give more space to the main content
        "showSidebar": False,
        # Set a custom theme (light, dark, or auto)
        "theme": "purple",
        # Hide the test request button
        "hideClientButton": True,
        # Customize the default HTTP client
        "defaultHttpClient": {
            "targetKey": "python",
            "clientKey": "requests",
        },
    }
)

2. Test Coverage

Added test_scalar_render_options() in tests/examples/test_openapi/test_plugins.py to validate:

  • The example app runs correctly
  • Custom options are properly rendered in the HTML output
  • All configuration values are correctly passed to the Scalar UI

3. Documentation Update

Updated docs/usage/openapi/ui_plugins.rst with a new section "Customizing Scalar Render Options" that:

  • Explains the purpose of the options parameter
  • References the new example
  • Links to the official Scalar configuration documentation for users to explore additional options

Benefits

This example helps users understand how to:

  • Customize the appearance and behavior of their Scalar API documentation
  • Control UI elements like the sidebar and test request button
  • Set themes to match their branding
  • Configure default code examples for their preferred language

References

Original prompt

@githubpr
The following is a snapshot of a chat conversation between a user and an AI coding assistant. Prioritize later messages in the conversation.
User: @githubpr 查找问题 litestar-org#4381 的解决方法
AI: The suggested fix for issue litestar-org#4381 involves creating an example that demonstrates how to customize Scalar render options using the options parameter. Here's the approach:

  1. Create an Example File: Add a Python script (e.g., custom_scalar_render.py) to the examples or documentation folder.

  2. Implement Customization: The script should show how to configure the ScalarRenderPlugin with custom options, such as hiding the test request button or setting a theme.

  3. Update Documentation: Add a section in the relevant documentation file explaining the customization process with the example code.

  4. Test the Example: Verify that the example works as intended in the development environment.

This will help users understand how to use the options parameter for customizing Scalar render options.
User: @githubpr

TITLE: Custom Scalar Render Options for Litestar Issue litestar-org#4381
USER INTENT: The user is seeking a solution for issue litestar-org#4381, specifically how to customize Scalar render options.
TASK DESCRIPTION: The user aims to create an example demonstrating the customization of Scalar render options using the options parameter, update documentation accordingly, and ensure the example functions correctly.
EXISTING: The assistant has proposed a structured approach to address the issue, including creating an example file and updating documentation.
PENDING: The user needs to implement the suggested changes, including creating the example file (custom_scalar_render.py), configuring the ScalarRenderPlugin, updating documentation, and testing the example.
CODE STATE:

  • Proposed file: custom_scalar_render.py (not yet created)
  • Suggested content: Example demonstrating customization of ScalarRenderPlugin with options like hiding the test request button and setting a theme.
    RELEVANT CODE/DOCUMENTATION SNIPPETS:
  • Suggested implementation steps:
    1. Create an example file.
    2. Implement customization in the script.
    3. Update documentation with the customization process.
    4. Test the example.
      OTHER NOTES: The user is collaborating with the assistant to refine the solution for the issue and may need further assistance in the implementation phase.
Created from VS Code via the [GitHub Pull Request](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extension.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits October 9, 2025 08:52
Co-authored-by: Umpire2018 <138990495+Umpire2018@users.noreply.github.com>
Co-authored-by: Umpire2018 <138990495+Umpire2018@users.noreply.github.com>
Copilot AI changed the title [WIP] Add example for customizing Scalar render options Add example demonstrating custom Scalar render options Oct 9, 2025
Copilot AI requested a review from Umpire2018 October 9, 2025 08:57
@Umpire2018 Umpire2018 closed this Oct 11, 2025
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.

2 participants