Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #826 +/- ##
============================================
- Coverage 95.72% 91.72% -4.00%
- Complexity 1773 2027 +254
============================================
Files 154 199 +45
Lines 4586 5439 +853
============================================
+ Hits 4390 4989 +599
- Misses 196 450 +254 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Once any case of a #[Type]-mapped enum carries #[EnumValue], the enum enters opt-in mode: only annotated cases are exposed and unannotated cases are hidden from the schema. A fully-unannotated mapped enum stays in legacy mode (every case exposed) and emits the existing deprecation advisory. Adds Types\ExposedEnumCase and reshapes EnumType's internal constructor to take the resolved exposed cases the mapper decided, replacing the parallel per-name metadata arrays. BREAKING CHANGE: partially-annotated #[Type] enums now hide their unannotated cases from the schema. Annotate every case you want exposed.
0cd846f to
42b0fd0
Compare
|
Hello @oojacoboo, Regarding the new I was wondering if you had considered having a class-level attribute that could expose all the enum cases, rather than requiring the attribute on each individual case? If not, perhaps this could be something worth considering. I think it could help keep the code a bit cleaner and more readable, especially for enums with many cases. Just sharing some feedback from trying it out in a real-world codebase. |
|
@enricobono thanks for the feedback. If you don't annotate any of the cases, all of them should be included. Maybe this is a bit confusing an an argument on the type annotation would be more ideal. Is that what you're thinking here? Or have you tried not annotating any of them for full inclusion? |
|
Thanks! I tried it, and it works exactly as described.
My concern was more about the future behavior. As I understand it, starting with a future release, once the schema is generated, only enum cases explicitly annotated with #[EnumValue] will be included. So in that context, I was wondering whether a type-level annotation could be a more explicit and less verbose way to opt in all cases. |
|
@enricobono great.
Yea, I think this would be a reasonable addition. I am questioning just leaving it like it is now though, instead of forcing the |
Builds on #793 (which added
#[EnumValue]for per-case metadata). This makes#[EnumValue]the schema-exposure toggle for#[Type]-mapped enums, mirroring#[Field]'s opt-in model on classes.Behavior
Once any case of a mapped enum carries
#[EnumValue], the enum enters opt-in mode: only annotated cases are exposed, and unannotated cases are hidden from the schema. A fully-unannotated mapped enum stays in legacy mode (every case exposed) and keeps emitting the existing deprecation advisory.Implementation
Types\ExposedEnumCaseand reshapesEnumType's internal constructor to take the resolved exposed cases the mapper decided, replacing the parallel per-name metadata arrays.EnumTypeMapperbuckets cases in a single pass, preserving deprecation precedence (explicit#[EnumValue(deprecationReason:)]wins, an empty string clears, otherwise the@deprecateddocblock is honored).Breaking change
Partially-annotated
#[Type]enums now hide their unannotated cases from the schema. Annotate every case you want exposed.Docs updated (
attributes-reference,descriptions); tests added (EnumExposureTest+ fixtures, covering opt-in, legacy, and mixed enums).