kubeshop / kusk-gateway

Kusk-gateway is an OpenAPI-driven API Gateway for Kubernetes
https://kubeshop.github.io/kusk-gateway/
MIT License
263 stars 21 forks source link

API Mocking returns different Content-Type each execution #297

Closed aabedraba closed 2 years ago

aabedraba commented 2 years ago

Describe the bug Running the mocking on an API (json, xml and text mocking) sometimes returns xml and sometimes returns text.

To Reproduce Apply the following manifest with

kgw api generate -i https://pastebin.com/raw/avYFtZpX | k apply -f -

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

kylehodgetts commented 2 years ago

Ouch, yeah that doesn't look right! Thanks for reporting this

jasmingacic commented 2 years ago

Behavior is as expected of accept header is passed the response will be of the corresponding content-type see below:

# curl -v -H 'accept: application/xml'  localhost:8011/todos
*   Trying ::1:8011...
* TCP_NODELAY set
* Connected to localhost (::1) port 8011 (#0)
> GET /todos HTTP/1.1
> Host: localhost:8011
> User-Agent: curl/7.68.0
> accept: application/xml
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: application/xml
< x-kusk-mocked: true
< date: Wed, 20 Apr 2022 12:09:07 GMT
< content-length: 117
< x-envoy-upstream-service-time: 0
< server: envoy
< 
* Connection #0 to host localhost left intact
<doc><completed>true</completed><order>13</order><title>Mocked XML title</title><url>http://mockedURL.com</url></doc>

If accept is not passed or you use / then it will return each time a different content-type. I'm closing this as an non-issue