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

Swagger claims receive endpoint returns string, but it's an object

Open crummy opened this issue 1 year ago • 1 comments

The problem

I ran the liblab API generator against the swagger code with:

liblab init --spec https://bbernhard.github.io/signal-cli-rest-api/src/docs/swagger.json
liblab build --language java

(I had to fix the /search endpoint missing {number}, but after that...)

When I call the /v1/receive endpoint, I get this error in my client:

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList<java.lang.Object>` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (String)"[{"envelope":{"source":"+178...","sourceNumber":"+1781...","sourceUuid":"...","sourceName":"...","sourceDevice":2,"timestamp":1732652479395,"dataMessage":{"timestamp":1732652479395,"message":"...",...

The function func (a *Api) Receive(c *gin.Context) does seem to return a string, rather than a JSON object. But presumably it's a JSON string, returned from the client.

I think the fix would be to, in signal-cli-rest-api, parse the returned string into an object, return it with c.JSON(200, obj), and add the object type to the swagger comments. Does that sound right?

Are you using the latest released version?

  • [X] Yes

Have you read the troubleshooting page?

  • [ ] Yes

What type of installation are you running?

signal-cli-rest-api Docker Container

In which mode are you using the docker container?

Native Mode

What's the architecture of your host system?

x86-64

Additional information

No response

crummy avatar Nov 27 '24 02:11 crummy

Thanks for the report!

I think the fix would be to, in signal-cli-rest-api, parse the returned string into an object, return it with c.JSON(200, obj), and add the object type to the swagger comments. Does that sound right?

yeah, right. It is on my todo list since a while, but I haven't found time to work on that.

bbernhard avatar Nov 29 '24 21:11 bbernhard