cytoscape / cyREST

Core App: REST API module for Cytoscape
https://github.com/cytoscape/cyREST/wiki
MIT License
30 stars 13 forks source link

Some of curl commands generated by Swagger do not work #56

Closed krassowski closed 6 years ago

krassowski commented 6 years ago

and I have no idea why. Could you help me?

This works fine:

curl -X GET --header 'Accept: application/json' 'http://localhost:1234/v1'

It returns:

{"apiVersion":"v1","numberOfCores":8,"memoryStatus":{"usedMemory":576,"freeMemory":4182,"totalMemory":4759,"maxMemory":26992}}

But this does not:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{}' 'http://localhost:1234/v1/commands/network/create empty'

Here is the verbose output:

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 1234 (#0)
> POST /v1/commands/network/create empty HTTP/1.1
> Host: localhost:1234
> User-Agent: curl/7.55.1
> Content-Type: application/json
> Accept: application/json
> Content-Length: 2
> 
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 400 Bad Request
< Connection: close
< Server: Jetty(8.1.15.v20140411)
< 
* Closing connection 0
dotasek commented 6 years ago

Duplicates #55

krassowski commented 6 years ago

Though it is not a duplicate of #55 (I insist), I agree that manually escaping space in the URL resolves the problem.

It does not change the fact that if the recommended REST API tool provides me with a curl command I would just expect it to work, not do manual escaping on the produced line - I still think that it is a bug and should be fixed somehow, as it wastes time of people trying to automate their Cytoscape workflow.

This worked for me fine:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{}' 'http://localhost:1234/v1/commands/network/create%20empty'

Anyway, thank you for your response and contribution. I hope the best for this project.

dotasek commented 6 years ago

I agree that this is problematic; this is an issue with Swagger UI, which generates the documentation for us. I can confirm that the version we're using treats curl this way, and that the current version they have on their demo site does as well.

I'll make an issue with them, and link to it from here.

dotasek commented 6 years ago

I created an issue with Swagger UI: https://github.com/swagger-api/swagger-ui/issues/4263

We'll eventually be upgrading to Swagger UI 3, once some outstanding issues have been resolved on their end.