Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(request-form): add handling for additional properties #81

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

hamzamahmood
Copy link
Collaborator

@hamzamahmood hamzamahmood commented Nov 14, 2024

What

This PR addresses an issue with the handling of additional properties in models that use [JsonExtensionData]. Specifically, it ensures that additional properties are flattened along with the model’s main members when data is sent as form data. Previously, the additional properties were being sent as a nested dictionary in form data, causing inconsistencies between the form data and the JSON body representation.

Why

Flattening the additional properties in form data ensures consistency between how data is represented in both the JSON body and form data formats. This alignment is important for APIs that process form data in a similar way to JSON payloads, ensuring the behavior is predictable and that consumers of the API receive a consistent structure. Additionally, this change improves compatibility with clients that expect all model properties, including those from [JsonExtensionData], to be at the top level.

Closes #80

Type of change

Select multiple if applicable.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause a breaking change)
  • Tests (adds or updates tests)
  • Documentation (adds or updates documentation)
  • Refactor (style improvements, performance improvements, code refactoring)
  • Revert (reverts a commit)
  • CI/Build (adds or updates a script, change in external dependencies)

Testing

  • Added unit tests to verify that models with additional properties, defined as both a property and a field, are correctly flattened when sent as form data.
  • The tests include scenarios where:
    • Additional properties are included as part of a [JsonExtensionData] dictionary.
    • Form data correctly represents additional properties as flattened key-value pairs.
    • Consistency is maintained between the JSON body and form data outputs for models with [JsonExtensionData].
  • These tests confirm that additional properties are no longer sent as nested dictionaries in form data.

Checklist

  • My code follows the coding conventions
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added new unit tests

@hamzamahmood hamzamahmood added the bug Something isn't working label Nov 14, 2024
@hamzamahmood hamzamahmood self-assigned this Nov 14, 2024
Copy link

@asadali214 asadali214 merged commit ffaa365 into main Nov 28, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for handling additional properties in Form request
2 participants