Map OpenAPI Discriminator mapping's values to their real value in enums #3074
Map OpenAPI Discriminator mapping's values to their real value in enums #3074ilovelinux wants to merge 2 commits intokoxudaxi:mainfrom
Conversation
📝 WalkthroughWalkthroughThis PR fixes integer discriminator handling in OpenAPI schema generation. When a discriminator property has multiple enum values, the parser now correctly generates integer literals instead of string literals, and refactors the discriminator value resolution logic based on a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will degrade performance by 21.57%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | WallTime | test_perf_kubernetes_style_pydantic_v2 |
2.2 s | 2.8 s | -18.73% |
| ❌ | WallTime | test_perf_aws_style_openapi_pydantic_v2 |
1.6 s | 2 s | -19.05% |
| ❌ | WallTime | test_perf_large_models_pydantic_v2 |
3.1 s | 3.9 s | -20.72% |
| ❌ | WallTime | test_perf_complex_refs |
1.8 s | 2.3 s | -20.38% |
| ❌ | WallTime | test_perf_graphql_style_pydantic_v2 |
706.7 ms | 871.4 ms | -18.9% |
| ❌ | WallTime | test_perf_multiple_files_input |
3.1 s | 3.9 s | -20.15% |
| ❌ | WallTime | test_perf_all_options_enabled |
5.6 s | 6.9 s | -18.66% |
| ❌ | WallTime | test_perf_duplicate_names |
900.1 ms | 1,121.9 ms | -19.77% |
| ❌ | WallTime | test_perf_stripe_style_pydantic_v2 |
1.7 s | 2.1 s | -18.49% |
| ❌ | WallTime | test_perf_openapi_large |
2.5 s | 3.2 s | -21.57% |
| ❌ | WallTime | test_perf_deep_nested |
5.2 s | 6.5 s | -19.75% |
Comparing ilovelinux:fix/ilovelinux-3073-enum-literal-values (a07509f) with main (5ba49a7)
Footnotes
-
98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3074 +/- ##
===========================================
- Coverage 100.00% 99.99% -0.01%
===========================================
Files 87 87
Lines 18237 18244 +7
Branches 2087 2091 +4
===========================================
+ Hits 18237 18243 +6
- Partials 0 1 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This PR is draft because of the following tasks:
|
Context
mappingfield is a key-value dictionary.Ref: https://swagger.io/specification/#options-for-mapping-values-to-schemas
What's changed
mapping's keys are mapped to their real enum values, if availableNotes
Summary by CodeRabbit