swaggest / jsonschema-go

JSON Schema mapping for Go
https://pkg.go.dev/github.com/swaggest/jsonschema-go
MIT License
102 stars 13 forks source link

Refactor interceptors for better extensibility #79

Closed vearutop closed 1 year ago

github-actions[bot] commented 1 year ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 6 2087 (+136) 1406 (+78) 253 (+34) 428 (+24) 542 (+11) 50.8K (+3.6K)
Go (test) 12 2723 (+47) 1970 (+39) 284 (+1) 469 (+7) 48 (+3) 68.9K (+1.4K)
Markdown 4 216 176 0 40 0 10.9K (-4B)
github-actions[bot] commented 1 year ago

Go API Changes

# github.com/swaggest/jsonschema-go
## compatible changes
InterceptProp: added
InterceptPropFunc: added
InterceptPropParams: added
InterceptSchema: added
InterceptSchemaFunc: added
InterceptSchemaParams: added

# summary
Inferred base version: v0.3.49
Suggested version: v0.4.0
github-actions[bot] commented 1 year ago

Unit Test Coverage

total: (statements) 78.1% changed lines: (statements) 64.2%, coverage is less than 90.0%, consider testing the changes more thoroughly

Coverage of changed lines | File | Function | Coverage | |----------------|--------------------|----------| | Total | | 64.2% | | context.go | | 38.2% | | context.go:120 | InterceptSchema | 100.0% | | context.go:152 | InterceptProp | 31.2% | | context.go:316 | deprecatedFallback | 21.4% | | context.go:113 | InterceptType | 0.0% | | context.go:141 | InterceptProperty | 0.0% | | reflect.go | | 90.9% | | reflect.go:121 | checkSchemaSetup | 100.0% | | reflect.go:238 | Reflect | 100.0% | | reflect.go:347 | reflect | 100.0% | | reflect.go:804 | walkProperties | 96.9% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |----------------------------------------------|--------------------|---------------|------------------| | Total | | 79.4% | 78.1% (-1.3%) | | github.com/swaggest/jsonschema-go/context.go | InterceptProp | no function | 33.3% | | github.com/swaggest/jsonschema-go/context.go | InterceptProperty | 33.3% | 0.0% (-33.3%) | | github.com/swaggest/jsonschema-go/context.go | InterceptSchema | no function | 88.9% | | github.com/swaggest/jsonschema-go/context.go | InterceptType | 88.9% | 0.0% (-88.9%) | | github.com/swaggest/jsonschema-go/context.go | deprecatedFallback | no function | 16.7% | | github.com/swaggest/jsonschema-go/reflect.go | checkSchemaSetup | 84.2% | 85.7% (+1.5%) | | github.com/swaggest/jsonschema-go/reflect.go | walkProperties | 88.0% | 85.2% (-2.8%) |
github-actions[bot] commented 1 year ago

Benchmark Result

Benchmark diff with base branch ``` name old time/op new time/op delta Schema_UnmarshalJSON_raw-2 74.8µs ± 3% 74.3µs ± 2% ~ (p=0.699 n=6+6) Schema_UnmarshalJSON-2 597µs ± 1% 594µs ± 1% ~ (p=0.093 n=6+6) Schema_MarshalJSON_raw-2 71.4µs ± 1% 71.2µs ± 1% ~ (p=0.329 n=6+5) Schema_MarshalJSON-2 242µs ± 0% 243µs ± 1% ~ (p=0.126 n=5+6) name old alloc/op new alloc/op delta Schema_UnmarshalJSON_raw-2 31.7kB ± 0% 31.7kB ± 0% ~ (p=0.654 n=6+6) Schema_UnmarshalJSON-2 184kB ± 0% 184kB ± 0% ~ (all equal) Schema_MarshalJSON_raw-2 21.9kB ± 0% 21.9kB ± 0% ~ (p=0.667 n=4+6) Schema_MarshalJSON-2 55.3kB ± 0% 55.3kB ± 0% ~ (p=0.799 n=6+6) name old allocs/op new allocs/op delta Schema_UnmarshalJSON_raw-2 457 ± 0% 457 ± 0% ~ (all equal) Schema_UnmarshalJSON-2 2.00k ± 0% 2.00k ± 0% ~ (all equal) Schema_MarshalJSON_raw-2 484 ± 0% 484 ± 0% ~ (all equal) Schema_MarshalJSON-2 477 ± 0% 477 ± 0% ~ (all equal) ```
Benchmark result ``` name time/op Schema_UnmarshalJSON_raw-2 74.3µs ± 2% Schema_UnmarshalJSON-2 594µs ± 1% Schema_MarshalJSON_raw-2 71.2µs ± 1% Schema_MarshalJSON-2 243µs ± 1% name alloc/op Schema_UnmarshalJSON_raw-2 31.7kB ± 0% Schema_UnmarshalJSON-2 184kB ± 0% Schema_MarshalJSON_raw-2 21.9kB ± 0% Schema_MarshalJSON-2 55.3kB ± 0% name allocs/op Schema_UnmarshalJSON_raw-2 457 ± 0% Schema_UnmarshalJSON-2 2.00k ± 0% Schema_MarshalJSON_raw-2 484 ± 0% Schema_MarshalJSON-2 477 ± 0% ```
codecov[bot] commented 1 year ago

Codecov Report

Merging #79 (b124ef3) into master (0cdbfda) will decrease coverage by 1.05%. The diff coverage is 58.20%.

@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
- Coverage   73.83%   72.78%   -1.05%     
==========================================
  Files           6        6              
  Lines        1070     1117      +47     
==========================================
+ Hits          790      813      +23     
- Misses        214      235      +21     
- Partials       66       69       +3     
Flag Coverage Δ
unittests 72.78% <58.20%> (-1.05%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
context.go 46.57% <21.87%> (-17.58%) :arrow_down:
reflect.go 82.49% <91.42%> (+0.13%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more