Skip to content

Conversation

@Fluf22
Copy link
Collaborator

@Fluf22 Fluf22 commented Feb 5, 2025

🧭 What and Why

fixes algolia/algoliasearch-client-swift#876

OpenAPI Generator overrides the default decoding/encoding methods for Decimal to be able to decode/encode from strings, in order to avoid losing precision
If users work with Decimal, it will override the default behavior for them
Also, we don't use the Decimal type in our specs, so it shouldn't be an issue for us

⚠️ For the future, here are some more details:

  • OpenAPI Generator uses a string to avoid losing precision, because using a Double as an intermediary container WILL LOSE some
  • When writing a spec, you can use a Decimal by specifying { "type": "string", "format": "decimal" }, but we should avoid that and prefer a number type directly

Changes included:

  • remove Decimal encoding/decoding methods

@Fluf22 Fluf22 requested a review from a team as a code owner February 5, 2025 08:46
@Fluf22 Fluf22 requested review from millotp and shortcuts February 5, 2025 08:46
@algolia-bot
Copy link
Collaborator

algolia-bot commented Feb 5, 2025

✔️ Code generated!

Name Link
🪓 Triggered by 86b47383e6360dc0873fb4d868d3d9a9792fada4
🍃 Generated commit fd0bd79e1cb4f5052543e253c3ae3cbfcb7a3d0e
🌲 Generated branch generated/fix/swift-decimal-coding
📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
swift 758

@Fluf22 Fluf22 self-assigned this Feb 5, 2025
@Fluf22 Fluf22 merged commit 397ff17 into main Feb 5, 2025
14 checks passed
@Fluf22 Fluf22 deleted the fix/swift-decimal-coding branch February 5, 2025 09:34
algolia-bot added a commit that referenced this pull request Feb 5, 2025
algolia-bot added a commit to algolia/algoliasearch-client-swift that referenced this pull request Feb 5, 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.

[bug]: KeyedDecodingContainerProtocol public extension breaks decoding on other consumers.

4 participants