Skip to content

Conversation

@javidahmed64592
Copy link
Owner

This pull request introduces a configurable JSON response system to the template server, allowing JSON rendering options (such as Unicode handling, indentation, and media type) to be set via configuration. It adds a new JSONResponseConfigModel to the configuration, a CustomJSONResponse class that uses these settings, and updates the server to use this custom response class by default. Comprehensive unit tests and fixtures are also added to verify the new functionality.

Configurable JSON Response System:

  • Added json_response section to config.json for specifying JSON response options including ensure_ascii, allow_nan, indent, and media_type.
  • Introduced JSONResponseConfigModel in models.py to represent and validate the new configuration section.
  • Created CustomJSONResponse class that renders JSON responses according to the configuration, and updated exception handlers and FastAPI app to use this class by default. [1] [2] [3] [4] [5] [6]

Testing and Fixtures:

  • Added fixtures for the new JSON response config and integrated them into the template server config fixture in conftest.py. [1] [2] [3]
  • Implemented unit tests for JSONResponseConfigModel and CustomJSONResponse, covering configuration, rendering with Unicode, indentation, and compact mode. [1] [2] [3]
  • Added a test to ensure the template server configures CustomJSONResponse correctly on initialization. [1] [2]

@javidahmed64592 javidahmed64592 merged commit aee26bd into main Dec 2, 2025
7 checks passed
@javidahmed64592 javidahmed64592 deleted the implement-custom-json-response-config branch December 2, 2025 22:27
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