Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Swashbuckle.v2.NoContentControllersTests

open FsUnitTyped
open Xunit
open Swashbuckle.v2.ReturnControllersTests

Expand All @@ -18,3 +19,17 @@ let ``Test 204 with PUT``() =
[<Fact>]
let ``Test 204 with DELETE``() =
task { do! api.DeleteApiNoContent() }

[<Fact>]
let ``Test 202 Accepted with GET returns string``() =
task {
let! result = api.GetApiAccepted()
result |> shouldEqual "accepted-value"
}

[<Fact>]
let ``Test 202 Accepted with POST returns string``() =
task {
let! result = api.PostApiAccepted()
result |> shouldEqual "accepted-value"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Swashbuckle.v3.NoContentControllersTests

open FsUnitTyped
open Xunit
open Swashbuckle.v3.ReturnControllersTests

Expand All @@ -18,3 +19,17 @@ let ``Test 204 with PUT``() =
[<Fact>]
let ``Test 204 with DELETE``() =
task { do! api.DeleteApiNoContent() }

[<Fact>]
let ``Test 202 Accepted with GET returns string``() =
task {
let! result = api.GetApiAccepted()
result |> shouldEqual "accepted-value"
}

[<Fact>]
let ``Test 202 Accepted with POST returns string``() =
task {
let! result = api.PostApiAccepted()
result |> shouldEqual "accepted-value"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,20 @@ type NoContentController() =
[<ProducesResponseType(204)>]
member x.Delete() =
x.NoContent()

[<Route("api/[controller]")>]
[<ApiController>]
type AcceptedController() =
inherit ControllerBase()

[<HttpGet>]
[<Produces("application/json")>]
[<ProducesResponseType(typeof<string>, 202)>]
member x.Get() : ActionResult<string> =
x.StatusCode(202, "accepted-value") |> ActionResult<string>

[<HttpPost>]
[<Produces("application/json")>]
[<ProducesResponseType(typeof<string>, 202)>]
member x.Post() : ActionResult<string> =
x.StatusCode(202, "accepted-value") |> ActionResult<string>
Comment on lines +43 to +49

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActionResult<string> cannot be created by piping an IActionResult (from StatusCode(202, ...)) into ActionResult<string>. This pattern only works when the piped value is the response body (e.g., a string). Wrap the StatusCode(...) result with the ActionResult<string>(...) constructor, or use Accepted("accepted-value") and wrap it similarly, to keep the 202 status while returning a string body.

Suggested change
x.StatusCode(202, "accepted-value") |> ActionResult<string>
[<HttpPost>]
[<Produces("application/json")>]
[<ProducesResponseType(typeof<string>, 202)>]
member x.Post() : ActionResult<string> =
x.StatusCode(202, "accepted-value") |> ActionResult<string>
ActionResult<string>(x.StatusCode(202, "accepted-value"))
[<HttpPost>]
[<Produces("application/json")>]
[<ProducesResponseType(typeof<string>, 202)>]
member x.Post() : ActionResult<string> =
ActionResult<string>(x.StatusCode(202, "accepted-value"))

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +49

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the GET action: StatusCode(202, ...) returns an IActionResult, so |> ActionResult<string> is not a valid conversion. Use ActionResult<string>(x.StatusCode(202, "accepted-value")) (or ActionResult<string>(x.Accepted("accepted-value"))) so this compiles and preserves the 202 response with a body.

Suggested change
x.StatusCode(202, "accepted-value") |> ActionResult<string>
[<HttpPost>]
[<Produces("application/json")>]
[<ProducesResponseType(typeof<string>, 202)>]
member x.Post() : ActionResult<string> =
x.StatusCode(202, "accepted-value") |> ActionResult<string>
ActionResult<string>(x.StatusCode(202, "accepted-value"))
[<HttpPost>]
[<Produces("application/json")>]
[<ProducesResponseType(typeof<string>, 202)>]
member x.Post() : ActionResult<string> =
ActionResult<string>(x.StatusCode(202, "accepted-value"))

Copilot uses AI. Check for mistakes.
Loading