Skip to content

Unify allowedKeys and allowedKeysWithConfig into single method#95

Open
cwperks wants to merge 1 commit into
mainfrom
rest-api-simplification
Open

Unify allowedKeys and allowedKeysWithConfig into single method#95
cwperks wants to merge 1 commit into
mainfrom
rest-api-simplification

Conversation

@cwperks

@cwperks cwperks commented May 7, 2026

Copy link
Copy Markdown
Owner

Summary

Simplifies the REST API validation by removing the dual-method pattern where allowedKeys() returned a Map<String, DataType> and allowedKeysWithConfig() returned a Map<String, FieldConfiguration>. Now there is only one method: allowedKeys() returning Map<String, FieldConfiguration>.

What changed

  • ValidationContext.allowedKeys() return type changed from Map<String, DataType> to Map<String, FieldConfiguration>
  • ValidationContext.allowedKeysWithConfig() removed entirely
  • All branching logic in RequestContentValidator (if (fieldConfigs != null) ... else ...) removed
  • All API actions updated to use FieldConfiguration.of(DataType.X) for simple type-only validation
  • Enhanced validation (maxLength, custom validators) uses the same allowedKeys() method with FieldConfiguration.of(DataType.X, maxLength, validator)

Motivation

The two methods represented the same concept (defining valid request body fields) with confusing precedence rules. allowedKeysWithConfig() silently overrode allowedKeys() when present, and any API action implementing both had dead code in its allowedKeys() method. This unification makes the validation path easier to trace and eliminates the cognitive overhead of choosing between two methods.

Testing

All existing validation tests pass with no behavioral changes.

@cwperks cwperks requested a review from willyborankin as a code owner May 7, 2026 19:44
@cwperks cwperks force-pushed the rest-api-simplification branch from f26c2c1 to 9dee5c0 Compare May 26, 2026 13:49
Simplifies the REST API validation by removing the dual-method pattern
(allowedKeys returning DataType map + allowedKeysWithConfig returning
FieldConfiguration map). Now there is only allowedKeys() returning
Map<String, FieldConfiguration>.

- allowedKeys() return type changed from Map<String, DataType> to
  Map<String, FieldConfiguration>
- allowedKeysWithConfig() removed from ValidationContext interface
- All branching logic in RequestContentValidator removed
- API actions use FieldConfiguration.of(DataType.X) for simple fields
- Enhanced validation (maxLength, custom validators) uses the same method

Signed-off-by: Craig Perkins <cwperks@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
@cwperks cwperks force-pushed the rest-api-simplification branch from 9dee5c0 to 76e013a Compare May 26, 2026 13:53
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.

1 participant