oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

Content-type when empty response in Fiber strict server

Open ShouheiNishi opened this issue 2 years ago • 1 comments

In Fiber strict server, if response body is not existed, Content-type in HTTP response header is “text/plain; charset=utf-8". This behavior is differed than strict server for other framework.

ShouheiNishi avatar Dec 27 '23 02:12 ShouheiNishi

Test code is https://github.com/ShouheiNishi/oapi-codegen/tree/9a8e5274f5a10f05caba603932510c9d471cdb70/internal/test/strict-server-response

$ git status
HEAD detached at 9a8e527
nothing to commit, working tree clean
$ (cd internal/test ; go generate ./strict-server-response/... && go test ./stri
ct-server-response/...)
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response [no test files]
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/chi/pkg2        [no test files]
ok      github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/chi/pkg1        (cached)
ok      github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/echo/pkg1       (cached)
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/echo/pkg2       [no test files]
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/fiber/pkg2      [no test files]
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/generator       [no test files]
--- FAIL: TestNoContent (0.00s)
    pkg1_test.go:45:
                Error Trace:    /home/nishi/free5gc-deb/free5gc/lib/oapi-codegen/internal/test/strict-server-response/fiber/pkg1/pkg1_test.go:45
                Error:          Not equal:
                                expected: ""
                                actual  : "text/plain; charset=utf-8"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -
                                +text/plain; charset=utf-8
                Test:           TestNoContent
--- FAIL: TestFixedNoContent (0.00s)
    pkg1_test.go:72:
                Error Trace:    /home/nishi/free5gc-deb/free5gc/lib/oapi-codegen/internal/test/strict-server-response/fiber/pkg1/pkg1_test.go:72
                Error:          Not equal:
                                expected: ""
                                actual  : "text/plain; charset=utf-8"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -
                                +text/plain; charset=utf-8
                Test:           TestFixedNoContent
--- FAIL: TestRefNoContent (0.00s)
    pkg1_test.go:101:
                Error Trace:    /home/nishi/free5gc-deb/free5gc/lib/oapi-codegen/internal/test/strict-server-response/fiber/pkg1/pkg1_test.go:101
                Error:          Not equal:
                                expected: ""
                                actual  : "text/plain; charset=utf-8"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -
                                +text/plain; charset=utf-8
                Test:           TestRefNoContent
--- FAIL: TestRefFixedNoContent (0.00s)
    pkg1_test.go:128:
                Error Trace:    /home/nishi/free5gc-deb/free5gc/lib/oapi-codegen/internal/test/strict-server-response/fiber/pkg1/pkg1_test.go:128
                Error:          Not equal:
                                expected: ""
                                actual  : "text/plain; charset=utf-8"

                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1 +1 @@
                                -
                                +text/plain; charset=utf-8
                Test:           TestRefFixedNoContent
FAIL
FAIL    github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/fiber/pkg1      0.020s
ok      github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/gin/pkg1        (cached)
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/gin/pkg2        [no test files]
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/gorilla/pkg2    [no test files]
ok      github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/gorilla/pkg1    (cached)
?       github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/iris/pkg2       [no test files]
ok      github.com/deepmap/oapi-codegen/v2/internal/test/strict-server-response/iris/pkg1       (cached)
FAIL
$

ShouheiNishi avatar Dec 27 '23 02:12 ShouheiNishi