swaggest / jsonschema-go

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

Reduce impact of Text(Un)Marshaler on schema processing #72

Closed vearutop closed 1 year ago

vearutop commented 1 year ago

Fixes #64.

Now implementing a pair of TextMarshaler/TextUnmarshaler would add string type to schema, but would allow further processing and configuration (it would stop at {"type":"string"} before).

github-actions[bot] commented 1 year ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 6 1897 (-2) 1289 (-1) 217 391 (-1) 505 46K (-15B)
Go (test) 11 2529 (+34) 1809 (+25) 280 440 (+9) 45 63.8K (+686B)
github-actions[bot] commented 1 year ago

Unit Test Coverage

total: (statements) 78.8% changed lines: (statements) 100.0%

Coverage of changed lines | File | Function | Coverage | |----------------|----------|----------| | Total | | 100.0% | | reflect.go | | 100.0% | | reflect.go:335 | reflect | 100.0% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |----------------------------------------------|------------|---------------|------------------| | Total | | 78.6% | 78.8% (+0.2%) | | github.com/swaggest/jsonschema-go/helper.go | AddType | 85.7% | 92.9% (+7.2%) | | github.com/swaggest/jsonschema-go/reflect.go | kindSwitch | 87.8% | 90.2% (+2.4%) | | github.com/swaggest/jsonschema-go/reflect.go | reflect | 96.5% | 96.6% (+0.1%) |
github-actions[bot] commented 1 year ago

Go API Changes

# summary
Inferred base version: v0.3.43
Suggested version: v0.3.44
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 73.2µs ± 0% 73.5µs ± 1% ~ (p=0.126 n=6+5) Schema_UnmarshalJSON-2 596µs ± 1% 597µs ± 1% ~ (p=0.699 n=6+6) Schema_MarshalJSON_raw-2 72.2µs ± 1% 71.6µs ± 0% ~ (p=0.065 n=6+6) Schema_MarshalJSON-2 242µs ± 0% 244µs ± 1% +0.60% (p=0.015 n=6+6) name old alloc/op new alloc/op delta Schema_UnmarshalJSON_raw-2 31.7kB ± 0% 31.7kB ± 0% ~ (p=0.835 n=6+6) Schema_UnmarshalJSON-2 184kB ± 0% 184kB ± 0% ~ (p=0.545 n=6+5) Schema_MarshalJSON_raw-2 21.9kB ± 0% 21.9kB ± 0% ~ (all equal) Schema_MarshalJSON-2 55.3kB ± 0% 55.3kB ± 0% ~ (p=0.325 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 73.5µs ± 1% Schema_UnmarshalJSON-2 597µs ± 1% Schema_MarshalJSON_raw-2 71.6µs ± 0% 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% ```