这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@kemingy
Copy link
Member

@kemingy kemingy commented Sep 12, 2025

@kemingy kemingy requested a review from Copilot September 12, 2025 04:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where Falcon's get_media() method throws an error when validating optional JSON in annotated handlers. The fix ensures that when JSON is optional (meaning it can be None or empty), the validation process doesn't fail due to missing media content.

  • Adds default_when_empty={} parameter to get_media() calls in Falcon plugin
  • Introduces OptionalJSON model and corresponding test views for optional JSON validation
  • Adds comprehensive test coverage for optional JSON scenarios in both sync and async Falcon handlers

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
spectree/plugins/falcon_plugin.py Modified validation logic to handle optional JSON by providing default empty dict when media is missing
tests/common.py Added OptionalJSON model for testing optional JSON validation scenarios
tests/test_plugin_falcon.py Added OptionalUserScore class and test for optional JSON validation in sync Falcon
tests/test_plugin_falcon_asgi.py Added OptionalUserScore class and test for optional JSON validation in async Falcon, plus test function name updates

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Signed-off-by: Keming <kemingy94@gmail.com>
Signed-off-by: Keming <kemingy94@gmail.com>
Signed-off-by: Keming <kemingy94@gmail.com>
Signed-off-by: Keming <kemingy94@gmail.com>
@kemingy kemingy merged commit c08ba67 into 0b01001001:main Sep 12, 2025
9 checks passed
@kemingy kemingy deleted the falcon_json_optional branch September 12, 2025 05:07
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.

bug: Falcon Plugin does not return pydantic model with defaults if possible.

1 participant