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

feat: custom query key formatters #1570

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tcortega
Copy link

What kind of change does this PR introduce?

Feature and docs update.

What is the current behavior?

Query keys in the URL are formatted based on property names without any customization.

What is the new behavior?

Introduces the capability for users to define custom formatting strategies for query keys in the URL. This can be achieved by implementing the IUrlParameterKeyFormatter interface and setting it in RefitSettings. The default behavior remains unchanged (using property names as they are) to ensure backward compatibility. Also, the documentation has been updated to reflect these changes and guide users on how to utilize this feature.

What might this PR break?
Care has been taken to ensure retro-compatibility. This PR should not introduce any breaking changes, as the default behavior remains consistent with previous versions.

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Other information:

  • The AliasAs attribute always takes precedence in key naming, regardless of any custom key formatters in use.
  • Enhanced documentation has been added to clarify the behavior of IUrlParameterFormatter when dealing with dictionaries.
  • The current handling of dictionary formatting remains unchanged to ensure backward compatibility and prevent potential breaks for existing users.
  • The decision to prioritize the AliasAs attribute aligns with intuitive expectations and mirrors behaviors such as JsonPropertyName in System.Text.Json.
  • Formatters are designed to be straightforward: they accept a string and return a formatted version without considering other attributes or extraneous factors.

@tcortega
Copy link
Author

Closes #1333
Closes #1541
Closes #1258

There are probably more issues regarding this matter.

@tcortega tcortega changed the title Feat/custom query key formatters feat: custom query key formatters Sep 27, 2023
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.

None yet

1 participant