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

Improve interface assertions to allow val/ptr receivers without data loss #112

Closed vearutop closed 4 months ago

github-actions[bot] commented 4 months ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 7 2415 (+72) 1649 (+60) 275 491 (+12) 654 (+36) 58.2K (+1.3K)
Go (test) 13 4011 (+491) 2973 (+367) 308 730 (+124) 51 101.6K (+13.1K)
github-actions[bot] commented 4 months ago

Go API Changes

# summary
Inferred base version: v0.3.68
Suggested version: v0.3.69
github-actions[bot] commented 4 months ago

Unit Test Coverage

total: (statements) 80.4% changed lines: (statements) 92.7%

Coverage of changed lines | File | Function | Coverage | |-----------------|------------------|----------| | Total | | 92.7% | | reflect.go | | 92.7% | | reflect.go:128 | checkSchemaSetup | 100.0% | | reflect.go:404 | reflect | 100.0% | | reflect.go:559 | safeInterface | 100.0% | | reflect.go:571 | ptrTo | 100.0% | | reflect.go:1427 | loadFromField | 100.0% | | reflect.go:582 | applySubSchemas | 91.2% | | reflect.go:382 | checkTitle | 66.7% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |------------|------------------|---------------|------------------| | Total | | 79.3% | 80.4% (+1.1%) | | reflect.go | applySubSchemas | 86.8% | 92.1% (+5.3%) | | reflect.go | checkSchemaSetup | 91.2% | 90.0% (-1.2%) | | reflect.go | checkTitle | 100.0% | 83.3% (-16.7%) | | reflect.go | loadFromField | 92.3% | 100.0% (+7.7%) | | reflect.go | ptrTo | no function | 100.0% | | reflect.go | reflect | 96.7% | 96.9% (+0.2%) | | reflect.go | reflectEnum | 62.5% | 100.0% (+37.5%) |
github-actions[bot] commented 4 months ago

Benchmark Result

Benchmark diff with base branch ``` name old time/op new time/op delta Schema_UnmarshalJSON_raw-4 61.1µs ± 1% 60.8µs ± 1% ~ (p=0.329 n=6+5) Schema_UnmarshalJSON-4 498µs ± 2% 497µs ± 0% ~ (p=0.818 n=6+6) Schema_MarshalJSON_raw-4 44.6µs ± 1% 44.0µs ± 1% -1.51% (p=0.002 n=6+6) Schema_MarshalJSON-4 187µs ± 0% 186µs ± 1% ~ (p=0.537 n=5+6) name old alloc/op new alloc/op delta Schema_UnmarshalJSON_raw-4 31.7kB ± 0% 31.7kB ± 0% ~ (p=0.455 n=6+6) Schema_UnmarshalJSON-4 180kB ± 0% 180kB ± 0% ~ (p=1.000 n=6+6) Schema_MarshalJSON_raw-4 14.6kB ± 0% 14.6kB ± 0% ~ (p=1.000 n=6+6) Schema_MarshalJSON-4 53.9kB ± 0% 53.9kB ± 0% ~ (p=0.606 n=5+6) name old allocs/op new allocs/op delta Schema_UnmarshalJSON_raw-4 457 ± 0% 457 ± 0% ~ (all equal) Schema_UnmarshalJSON-4 1.85k ± 0% 1.85k ± 0% ~ (all equal) Schema_MarshalJSON_raw-4 370 ± 0% 370 ± 0% ~ (all equal) Schema_MarshalJSON-4 468 ± 0% 468 ± 0% ~ (all equal) ```
Benchmark result ``` name time/op Schema_UnmarshalJSON_raw-4 60.8µs ± 1% Schema_UnmarshalJSON-4 497µs ± 0% Schema_MarshalJSON_raw-4 44.0µs ± 1% Schema_MarshalJSON-4 186µs ± 1% name alloc/op Schema_UnmarshalJSON_raw-4 31.7kB ± 0% Schema_UnmarshalJSON-4 180kB ± 0% Schema_MarshalJSON_raw-4 14.6kB ± 0% Schema_MarshalJSON-4 53.9kB ± 0% name allocs/op Schema_UnmarshalJSON_raw-4 457 ± 0% Schema_UnmarshalJSON-4 1.85k ± 0% Schema_MarshalJSON_raw-4 370 ± 0% Schema_MarshalJSON-4 468 ± 0% ```