Skip to content

Commit

Permalink
accept "default" as "ok response" fallback (#223)
Browse files Browse the repository at this point in the history
* accept "default" as "ok response" fallback

* tried run fantomas but fails format on file

* added testst

* fix: format

* fix: add new test to fsproj

---------

Co-authored-by: Sergey Tihon <sergey.tihon@gmail.com>
  • Loading branch information
jkone27 and sergey-tihon authored Apr 22, 2023
1 parent 29bd9e2 commit f1c7ef2
Show file tree
Hide file tree
Showing 4 changed files with 1,370 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/SwaggerProvider.DesignTime/v3/OperationCompiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ type OperationCompiler(schema: OpenApiDocument, defCompiler: DefinitionCompiler,
let retMimeAndTy =
let okResponse =
operation.Responses
|> Seq.tryFind(fun resp -> resp.Key = "200")
|> Option.orElseWith(fun () ->
operation.Responses
|> Seq.tryFind(fun resp -> resp.Key.StartsWith("20")))
|> Seq.tryFind(fun resp -> resp.Key = "200" || resp.Key.StartsWith("20") || resp.Key = "default")

okResponse
|> Option.bind(fun kv ->
Expand Down
Loading

0 comments on commit f1c7ef2

Please sign in to comment.