Refactor API allowedValues to derive values from enums - #13895
Refactor API allowedValues to derive values from enums#13895dheeraj12347 wants to merge 8 commits into
Conversation
|
Hi @Pearl1594 and @soreana , I’ve opened PR #13895 with the updated allowedValues implementation. I incorporated the work from #13783 into this branch and addressed the hard-coded enum concern by adding allowedValueType to @parameter and deriving the values from the enum constants during API discovery. I’ve also retained the existing explicit allowedValues path for parameters where there is no corresponding enum, and added test coverage for both paths. I’ve verified the implementation with the API Discovery build, the API Discovery tests (8/8 passing), git diff --check, and checkstyle. Regarding your earlier request to merge #13783 into #13543: since the #13783 work is now incorporated into #13895, should I still merge #13783 explicitly into #13543, or is #13895 intended to supersede that merge? I also want to confirm whether you’d like me to do any further audit of the remaining explicit allowedValues entries where a corresponding enum may exist, before considering this complete. |
Description
Refactor API parameter
allowedValuesdiscovery to support enum-backed values.Previously, enum values were specified directly as hard-coded strings in API parameter annotations. This can result in duplicated sources of truth when the corresponding enum changes.
This change introduces
allowedValueTypeto@Parameter. When an enum type is provided, API discovery derives the allowed values directly from the enum constants.The existing explicit
allowedValuesmechanism is retained for parameters that do not have a corresponding enum.The change also expands enum-backed allowed-values coverage across existing API parameters.
Changes
allowedValueTypeto@Parameter.ApiDiscoveryServiceImpl.allowedValuessupport as a fallback.Validation
mvn -pl plugins/api/discovery -am -DskipTests compilemvn -pl plugins/api/discovery -Dtest=ApiDiscoveryServiceImplTest -DfailIfNoTests=false testgit diff --checkAPI Discovery tests: 8/8 passed.