Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path normalization via new NodeTransformer interface #413

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Apr 4, 2024

  1. Support node normalization, add a path normalizer

    The purpose of the path normalizer is to normalize all inbound paths
    by making them lower case, and removing any "-" characters. Normalizing
    paths means sources with different idiomatic approaches to defining
    key values will all map correctly to the defined config classes.
    
    The only downside to this is multiple config attributes in the same
    class that differ only by case can no longer be disambiguated. This
    should be a rare case and the advantages are more than worth losing
    this "feature".
    
    We also add a LowercaseParameterMapper by default which can handle
    the normalized paths.
    rocketraman committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    373c382 View commit details
    Browse the repository at this point in the history
  2. Improve reporting for key values

    With path normalization (and even before path normalization), it was
    possible for the reported path to not match the input value. For
    example, with environment variables, the environment variable may have
    been `FOO__BAR`, but the report showed `FOO.BAR`, which makes it harder
    for users to trace the report back to the original source.
    
    We now add a `sourceKey` attribute to `Node` and report on it, to show
    user's the key value as it was originally present in the source.
    rocketraman committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    eac8a0b View commit details
    Browse the repository at this point in the history
  3. Enable path normalization by default

    Remove both the `SnakeCaseParamMapper` and `KebabCaseParamMapper`
    by default, add the `PathNormalizer` by default.
    
    Add removal of `_` to path normalizer.
    
    Fix some issues with the `HikariDataSourceDecoder` when enabling
    path normalization by default -- that decoder requires the
    original key case as its props are case-sensitive. Create an
    abstract `UnnormalizedKeysDecoder` which has the ability to restore
    the case of keys via the `sourceKey`.
    
    Fix breaking explicit sealed types with normalization because the
    discriminator field defaults to `_type` which normalizes to `type`.
    Disable normalization if the field name matches the discriminator field
    name, and the node is a `MapNode`.
    
    Fix reporting for strict mode to use the `sourceKey` value, so that
    reporting matches the source value, not the normalized value.
    
    Update Preprocessor implementations to correctly copy the source key
    when new Map and Array nodes are created.
    rocketraman committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    80c6ed8 View commit details
    Browse the repository at this point in the history

Commits on May 5, 2024

  1. Configuration menu
    Copy the full SHA
    ee1adb5 View commit details
    Browse the repository at this point in the history