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
3 changes: 2 additions & 1 deletion docs/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#### 2.0.0-beta2 - Aug 13, 2022
#### 2.0.0-beta3 - Aug 15, 2022
- F# 6 task{} instead of async{} under thee hood - [#200](https://github.com/fsprojects/SwaggerProvider/pull/200)
- BREAKING: `ProvidedApiClientBase.CallAsync` returns `task` instead of `async`
- BREAKING: `task` CE wrap all exceptions in `AggregateException` (with `OpenApiException` inside)
- Model enums as `string`, `int32` or `boolean` (Fixed [#186](https://github.com/fsprojects/SwaggerProvider/issues/186) )
- Add `Accept` header to all request (Fixed [#196](https://github.com/fsprojects/SwaggerProvider/issues/196))

#### 1.0.2 - Jul 10, 2022
- SharpYaml 2.0.0
Expand Down
12 changes: 8 additions & 4 deletions src/SwaggerProvider.DesignTime/v2/OperationCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ type OperationCompiler(schema: SwaggerObject, defCompiler: DefinitionCompiler, i
let headers =
let jsonConsumable =
op.Consumes |> Seq.exists(fun mt -> mt = MediaTypes.ApplicationJson)
let jsonProducible =
op.Produces |> Seq.exists(fun mt -> mt = MediaTypes.ApplicationJson)

<@
if jsonConsumable then
[| "Content-Type", MediaTypes.ApplicationJson |]
else
[||]
[|
if jsonProducible then
"Accept", MediaTypes.ApplicationJson
if jsonConsumable then
"Content-Type", MediaTypes.ApplicationJson
|]
@>

// Locates parameters matching the arguments
Expand Down
11 changes: 5 additions & 6 deletions src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ type OperationCompiler(schema: OpenApiDocument, defCompiler: DefinitionCompiler,
let httpMethod = opTy.ToString()

let headers =
let jsonConsumable = true // TODO: take a look at media types
// op.Consumes |> Seq.exists (fun mt -> mt="application/json")
// TODO: add headers conditionally
<@
if jsonConsumable then
[ "Content-Type", MediaTypes.ApplicationJson ]
else
[]
[
"Accept", MediaTypes.ApplicationJson
"Content-Type", MediaTypes.ApplicationJson
]
@>

// Locates parameters matching the arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<Compile Include="v2\Swashbuckle.ReturnControllers.Tests.fs" />
<Compile Include="v2\Swashbuckle.UpdateControllers.Tests.fs" />
<Compile Include="v2\Swashbuckle.ResourceControllers.Tests.fs" />
<Compile Include="v2\Swashbuckle.SpecialCasesControllers.Tests.fs" />
<Compile Include="v2\Swagger.PetStore.Tests.fs" />
<Compile Include="v2\Swagger.GitHub.Tests.fs" />
<Compile Include="v2\Swagger.Instagram.Tests.fs" />
Expand All @@ -27,6 +28,7 @@
<Compile Include="v3\Swashbuckle.UpdateControllers.Tests.fs" />
<Compile Include="v3\Swashbuckle.ResourceControllers.Tests.fs" />
<Compile Include="v3\Swashbuckle.FileController.Tests.fs" />
<Compile Include="v3\Swashbuckle.SpecialCasesControllers.Tests.fs" />
<Compile Include="..\SwaggerProvider.Tests\APIs.guru.fs">
<Link>APIs.guru.fs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Swashbuckle.SpecialCasesControllersTests

open Expecto
open System
open Swashbuckle.v2.ReturnControllersTests

[<Tests>]
let resourceControllersTests =
testList "All/v2/Swashbuckle.SpecialCasesControllers.Tests" [

testCaseAsync "Requst response in JSON format from MultiFormatController"
<| async { do! api.GetApiMultiFormat() |> asyncEqual "0.0" }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module Swashbuckle.v3.SpecialCasesControllersTests

open Expecto
open System
open Swashbuckle.v3.ReturnControllersTests

[<Tests>]
let resourceControllersTests =
testList "All/v3/Swashbuckle.SpecialCasesControllers.Tests" [

testCaseAsync "Requst response in JSON format from MultiFormatController"
<| async { do! api.GetApiMultiFormat() |> asyncEqual "0.0" }
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Swashbuckle.WebApi.Server.Controllers

open System
open Microsoft.AspNetCore.Mvc
open Swagger.Internal

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

[<HttpGet>]
member __.Get() = "0.0"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<Compile Include="Controllers\ResourceControllers.fs" />
<Compile Include="Controllers\ValuesController.fs" />
<Compile Include="Controllers\FileController.fs" />
<Compile Include="Controllers\SpecialCasesControllers.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
<None Include="paket.references" />
Expand Down