swaggest / rest

Web services with OpenAPI and JSON Schema done quick in Go
https://pkg.go.dev/github.com/swaggest/rest
MIT License
335 stars 17 forks source link

Fix: Setting the HTTP status during the Encoder setup is insufficient #156

Closed haimgel closed 1 year ago

haimgel commented 1 year ago

Sorry, my previous PR had a bug ๐Ÿ˜…

Setting the HTTP status during the Encoder setup is insufficient: we must also set it when actually encoding the output (as concrete output values might have different statuses).

vearutop commented 1 year ago

Could you also add a test for this fix (original bug reproducer)?

codecov[bot] commented 1 year ago

Codecov Report

Merging #156 (51366bd) into master (558c9ad) will increase coverage by 0.12%. The diff coverage is 66.66%.

@@            Coverage Diff             @@
##           master     #156      +/-   ##
==========================================
+ Coverage   77.67%   77.79%   +0.12%     
==========================================
  Files          28       28              
  Lines        1608     1608              
==========================================
+ Hits         1249     1251       +2     
+ Misses        236      235       -1     
+ Partials      123      122       -1     
Flag Coverage ฮ”
unittests 77.79% <66.66%> (+0.12%) :arrow_up:

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

Impacted Files Coverage ฮ”
response/encoder.go 67.78% <66.66%> (+0.83%) :arrow_up:

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

haimgel commented 1 year ago

@vearutop I added an explicit test for this.

I don't think this linter complaint is valid, though. This is something that is fixed in golangci-lint 1.51.2...