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

Allow looking for properties by multiple tags #73

Closed vearutop closed 1 year ago

vearutop commented 1 year ago

Related to https://github.com/swaggest/rest/issues/108.

github-actions[bot] commented 1 year ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 6 1912 (+15) 1299 (+10) 219 (+2) 394 (+3) 508 (+3) 46.5K (+544B)
Go (test) 11 2547 (+18) 1823 (+14) 280 444 (+4) 45 64.2K (+457B)
github-actions[bot] commented 1 year ago

Go API Changes

# github.com/swaggest/jsonschema-go
## incompatible changes
PropertyNameTag: changed from func(string) func(*ReflectContext) to func(string, ...string) func(*ReflectContext)
## compatible changes
ReflectContext.PropertyNameAdditionalTags: added

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

Unit Test Coverage

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

Coverage of changed lines | File | Function | Coverage | |----------------|-----------------|----------| | Total | | 100.0% | | context.go | | 100.0% | | context.go:26 | PropertyNameTag | 100.0% | | reflect.go | | 100.0% | | reflect.go:738 | propertyTag | 100.0% | | reflect.go:758 | walkProperties | 100.0% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |----------------------------------------------|----------------|---------------|------------------| | Total | | 78.8% | 78.9% (+0.1%) | | github.com/swaggest/jsonschema-go/reflect.go | propertyTag | no function | 100.0% | | github.com/swaggest/jsonschema-go/reflect.go | walkProperties | 88.5% | 88.0% (-0.5%) |
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 84.9µs ± 4% 93.1µs ± 6% +9.69% (p=0.004 n=6+6) Schema_UnmarshalJSON-2 682µs ± 4% 729µs ± 9% +6.77% (p=0.026 n=6+6) Schema_MarshalJSON_raw-2 77.7µs ± 1% 85.8µs ± 4% +10.44% (p=0.004 n=5+6) Schema_MarshalJSON-2 261µs ± 3% 275µs ± 4% +5.29% (p=0.009 n=6+6) name old alloc/op new alloc/op delta Schema_UnmarshalJSON_raw-2 31.7kB ± 0% 31.7kB ± 0% ~ (p=0.113 n=5+6) Schema_UnmarshalJSON-2 184kB ± 0% 184kB ± 0% ~ (p=0.182 n=6+6) Schema_MarshalJSON_raw-2 21.9kB ± 0% 21.9kB ± 0% ~ (all equal) Schema_MarshalJSON-2 55.3kB ± 0% 55.3kB ± 0% ~ (p=0.608 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 93.1µs ± 6% Schema_UnmarshalJSON-2 729µs ± 9% Schema_MarshalJSON_raw-2 85.8µs ± 4% Schema_MarshalJSON-2 275µs ± 4% 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% ```