-
Notifications
You must be signed in to change notification settings - Fork 60
Closed
Description
Description
Failure when calling a simple string returning GET call
Repro steps
- create a F# web api app with the following controller
[<ApiController>]
type YatpApiController() =
inherit ControllerBase()
[<HttpGet("version")>]
member __.Get() = "0.0"- create a F# client console application
module Yatp.Client
open SwaggerProvider
open System.Net.Http
open System
//let [<Literal>] Schema = "swagger.json"
let [<Literal>] Schema = @"http://localhost:5166/swagger/v1/swagger.json"
type YatpClient = OpenApiClientProvider<Schema>
let client = YatpClient.Client(new HttpClient(BaseAddress = Uri(@"http://localhost:5166/")))
let version = client.GetVersion().Result //Error
printfn "%A" versionSchema
{
"openapi": "3.0.1",
"info": {
"title": "Yatp.Api",
"version": "1.0"
},
"paths": {
"/version": {
"get": {
"tags": [
"YatpApi"
],
"responses": {
"200": {
"description": "Success",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
},
"application/json": {
"schema": {
"type": "string"
}
},
"text/json": {
"schema": {
"type": "string"
}
}
}
}
}
}
},
Expected behavior
the value "0.0" should be returned and then printed
Actual behavior
An exception is raised in the client.GetVersion().Result line
One or more errors occurred. (The JSON value could not be converted to System.String. Path: $ | LineNumber: 0 | BytePositionInLine: 3.)
Known workarounds
None
Affected Type Providers
- OpenApiClientProvider
Related information
- Operating system: Windows 10
- .NET Runtime: .NET 6
NOTE: C# client generated with NSwag or Visual Studio works as expected
var yatpClient = new Yatp.Client.YatpClient(@"http://localhost:5166/", new HttpClient());
var version = await yatpClient.VersionAsync(); //OK
Console.WriteLine(version);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels