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

Add support for type parameters as def names, escape references #82

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 1951 (+17) 1328 (+11) 219 404 (+6) 531 (+10) 47.3K (+305B)
Go (test) 12 (+1) 2676 (+84) 1931 (+72) 283 (+2) 462 (+10) 45 67.5K (+2.2K)
github-actions[bot] commented 1 year ago

Go API Changes

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

Unit Test Coverage

total: (statements) 79.4% changed lines: (statements) 93.3%

Coverage of changed lines | File | Function | Coverage | |-----------------|---------------------------|----------| | Total | | 93.3% | | camelcase.go | | 100.0% | | camelcase.go:14 | toCamel | 100.0% | | context.go | | 100.0% | | context.go:128 | StripDefinitionNamePrefix | 100.0% | | reflect.go | | 87.5% | | reflect.go:76 | Schema | 100.0% | | reflect.go:342 | reflect | 100.0% | | reflect.go:586 | defName | 90.9% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |------------------------------------------------|---------------------------|---------------|------------------| | Total | | 79.1% | 79.4% (+0.3%) | | github.com/swaggest/jsonschema-go/camelcase.go | toCamel | 88.9% | 100.0% (+11.1%) | | github.com/swaggest/jsonschema-go/context.go | StripDefinitionNamePrefix | 85.7% | 87.5% (+1.8%) | | github.com/swaggest/jsonschema-go/reflect.go | defName | 81.5% | 82.8% (+1.3%) | | github.com/swaggest/jsonschema-go/reflect.go | reflect | 96.7% | 96.6% (-0.1%) |
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.5µs ± 0% 74.6µs ± 1% ~ (p=0.818 n=6+6) Schema_UnmarshalJSON-2 599µs ± 1% 600µs ± 0% ~ (p=0.818 n=6+6) Schema_MarshalJSON_raw-2 71.2µs ± 1% 72.1µs ± 1% +1.27% (p=0.002 n=6+6) Schema_MarshalJSON-2 242µs ± 0% 244µs ± 1% +0.80% (p=0.009 n=6+6) name old alloc/op new alloc/op delta Schema_UnmarshalJSON_raw-2 31.7kB ± 0% 31.7kB ± 0% -0.01% (p=0.026 n=6+6) Schema_UnmarshalJSON-2 184kB ± 0% 184kB ± 0% ~ (p=0.121 n=5+6) Schema_MarshalJSON_raw-2 21.9kB ± 0% 21.9kB ± 0% ~ (p=1.000 n=6+6) Schema_MarshalJSON-2 55.3kB ± 0% 55.3kB ± 0% ~ (p=0.589 n=6+5) 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.6µs ± 1% Schema_UnmarshalJSON-2 600µs ± 0% Schema_MarshalJSON_raw-2 72.1µs ± 1% Schema_MarshalJSON-2 244µ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% ```