signal-cli-rest-api icon indicating copy to clipboard operation
signal-cli-rest-api copied to clipboard

Swagger description for /v1/receive/{number} return type incorrect?

Open heinrich-ulbricht opened this issue 2 years ago • 2 comments

The problem

When using NSwag to generate C# code the generated return type for /v1/receive/{number} is wrong. What gets generated is ICollection<string> but should rather be ICollection<object> since the returned list does not contain strings but objects.

Looking at the Swagger description it seems the described return value does not reflect what is actually returned. It seems like [string] should be something like [object]?

Are you using the latest released version?

  • [X] Yes

Have you read the troubleshooting page?

  • [X] Yes

What type of installation are you running?

signal-cli-rest-api Docker Container

In which mode are you using the docker container?

Normal Mode

What's the architecture of your host system?

x86-64

Additional information

No response

heinrich-ulbricht avatar Jan 17 '22 20:01 heinrich-ulbricht

Thanks for the ticket!

For the receive endpoint the results from signal-cli are directly returned without parsing them into any datastructures first - that's why internally it's just a big string blob (that's btw. also the reason why the data, that is returned in the receive endpoint, is camelCased, whereas everything else uses snake_case). But I want to clean that up with one of the next releases - so v1/receive will probably be marked as deprecated and superseded with v2/receive. That should also fix the documentation issue :)

bbernhard avatar Jan 18 '22 19:01 bbernhard

The code generator I use (NSwag) parses the result via Json.NET into objects. When presented with a [string] it assumes the collection contains strings and expects a " after the opening [. But it finds a { which means it's an object. This throws an exception. So for this kind of code generator it makes a difference if it's [string] or [object].

After finding the cause I changed the type and all was well. But it would be nice if this manual step would go away. And it sounds like with the new v2/receive endpoint it might indeed. Thanks for the feedback.

heinrich-ulbricht avatar Jan 21 '22 22:01 heinrich-ulbricht