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 nullable field tag to override nullability #96

Closed vearutop closed 9 months ago

vearutop commented 9 months ago

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

github-actions[bot] commented 9 months ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 7 2291 (+56) 1551 (+39) 269 (+5) 471 (+12) 599 (+22) 55.1K (+1.1K)
Go (test) 13 3214 (+30) 2355 (+26) 305 554 (+4) 48 80.8K (+925B)
Markdown 4 280 (+1) 226 (+1) 0 54 0 12.6K (+61B)
YAML 6 497 (+2) 411 (+2) 36 50 0 16.4K (+125B)
github-actions[bot] commented 9 months ago

Go API Changes

# github.com/swaggest/jsonschema-go
## compatible changes
(*Schema).RemoveType: added

# summary
Inferred base version: v0.3.59
Suggested version: v0.4.0
github-actions[bot] commented 9 months ago

Benchmark Result

Benchmark diff with base branch ``` name old time/op new time/op delta Schema_UnmarshalJSON_raw-2 78.0µs ± 1% 78.0µs ± 1% ~ (p=0.699 n=6+6) Schema_UnmarshalJSON-2 586µs ± 1% 589µs ± 0% ~ (p=0.126 n=6+5) Schema_MarshalJSON_raw-2 71.0µs ± 1% 70.9µs ± 1% ~ (p=0.394 n=6+6) Schema_MarshalJSON-2 240µs ± 0% 241µs ± 0% +0.28% (p=0.008 n=5+5) name old alloc/op new alloc/op delta Schema_UnmarshalJSON_raw-2 31.6kB ± 0% 31.6kB ± 0% ~ (p=0.794 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=0.182 n=6+6) Schema_MarshalJSON-2 55.3kB ± 0% 55.3kB ± 0% ~ (p=0.567 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 78.0µs ± 1% Schema_UnmarshalJSON-2 589µs ± 0% Schema_MarshalJSON_raw-2 70.9µs ± 1% Schema_MarshalJSON-2 241µs ± 0% name alloc/op Schema_UnmarshalJSON_raw-2 31.6kB ± 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% ```
github-actions[bot] commented 9 months ago

Unit Test Coverage

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

Coverage of changed lines | File | Function | Coverage | |-----------------|------------------|----------| | Total | | 82.4% | | helper.go | | 66.7% | | helper.go:113 | RemoveType | 74.3% | | reflect.go | | 94.7% | | reflect.go:1148 | checkNullability | 100.0% | | reflect.go:880 | walkProperties | 87.5% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |------------|----------------|---------------|------------------| | Total | | 78.8% | 78.7% (-0.1%) | | helper.go | RemoveType | no function | 66.7% | | reflect.go | walkProperties | 85.5% | 84.8% (-0.7%) |
codecov[bot] commented 9 months ago

Codecov Report

Merging #96 (553adb2) into master (bc13a7d) will decrease coverage by 0.28%. The diff coverage is 62.96%.

@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
- Coverage   73.97%   73.70%   -0.28%     
==========================================
  Files           7        7              
  Lines        1168     1194      +26     
==========================================
+ Hits          864      880      +16     
- Misses        237      243       +6     
- Partials       67       71       +4     
Flag Coverage Δ
unittests 73.70% <62.96%> (-0.28%) :arrow_down:

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

Files Changed Coverage Δ
helper.go 80.99% <46.66%> (-4.86%) :arrow_down:
reflect.go 84.10% <83.33%> (-0.05%) :arrow_down:

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