swaggest / php-json-schema

High definition PHP structures with JSON-schema based validation
MIT License
438 stars 50 forks source link

Allow properties mapping in reflected names #125

Closed vearutop closed 3 years ago

vearutop commented 3 years ago

Resolves #124.

This PR upgrades names reflector with properties mappings, so that it is possible to use mapped names in further schema configuration.

Example:

        // Define default mapping if any.
        $ownerSchema->addPropertyMapping('date_time', Order::names()->dateTime);

        // Use mapped name references after the default mapping was configured.
        $names = self::names($ownerSchema->properties);
        $ownerSchema->required = array(
            $names->id,         
            $names->dateTime, // "date_time"
            $names->price       
        );
github-actions[bot] commented 3 years ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Markdown 2 602 (+8) 473 (+7) 0 129 (+1) 0 19.4K (+271B)
PHP 133 11088 (+22) 8021 (+12) 1473 (+5) 1594 (+5) 556 (+3) 320.3K (+675B)
codecov[bot] commented 3 years ago

Codecov Report

Merging #125 (aeac3b7) into master (d0126bd) will increase coverage by 0.02%. The diff coverage is 100.00%.

:exclamation: Current head aeac3b7 differs from pull request most recent head 54957e0. Consider uploading reports for the commit 54957e0 to get more accurate results Impacted file tree graph

@@             Coverage Diff              @@
##             master     #125      +/-   ##
============================================
+ Coverage     92.34%   92.36%   +0.02%     
- Complexity      756      760       +4     
============================================
  Files            27       27              
  Lines          1645     1651       +6     
============================================
+ Hits           1519     1525       +6     
  Misses          126      126              
Impacted Files Coverage Δ
src/NameMirror.php 75.00% <100.00%> (+25.00%) :arrow_up:
src/Structure/ClassStructureTrait.php 95.83% <100.00%> (+0.11%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d0126bd...54957e0. Read the comment docs.