Closed aabedraba closed 2 years ago
I tried the same with curl
and i keep getting consistent results.
I will close this for now. If you want we can get on a call to try this together.
@jasmingacic what command did you run to test this?
Do you change headers or anything?
Running curl localhost:8080/todos
returns nothing, with the OpenAPI spec that I provided
Maybe I missed something I will retest.
Sorry apparently I was using the other example you used when I try to create this API controller returns this error:
failed to generate config: cannot generate mock response for path /todos operation GET: neither the body example nor a simple success (e.g. 200) code is present for mocking generation
I believe this case is not applicable. I will look into it deeper.
/cc @kylehodgetts do you have an idea what might be wrong
---
apiVersion: gateway.kusk.io/v1alpha1
kind: API
metadata:
name: todo-backend-api
namespace: default
spec:
spec: |
components: {}
info:
title: todo-backend-api
version: 0.0.2
openapi: 3.0.0
paths:
/todos:
get:
responses:
"200":
content:
application/json:
schema:
example:
completed: true
order: 13
title: Mocked JSON title
url: http://mockedURL.com
properties:
completed:
type: boolean
order:
format: int32
type: integer
title:
description: Description of what to do
type: string
url:
type: string
required:
- title
- completed
- order
- url
type: object
description: ToDos
x-kusk:
mocking:
enabled: true
x-kusk:
cors:
credentials: true
headers:
- Content-Type
max_age: 86200
methods:
- POST
- GET
origins:
- '*'
path:
prefix: /
upstream:
service:
name: todo-backend
namespace: default
port: 3000
Found it!!! The way your example was put here is incorrect:
content:
application/json:
schema:
example:
completed: true
order: 13
title: Mocked JSON title
url: http://mockedURL.com
This is the correct way:
application/json:
example:
completed: true
order: 13
title: Mocked XML title
url: http://mockedURL.com
Example has to be defined for each expected content. This way example didn't have "media-type" therefore endpoint was not created. There is the same problem in #297 in yaml example has to be a child of media-type "application/json" or any other that might be needed.
So I'm closing this ticket as not applicable since the manifest was incorrect.
feel free to reopen it if this is not the case
Should be fixed by https://github.com/kubeshop/kusk-gateway/pull/1003.
Describe the bug Running the following api with the json mocking doesn't work
https://pastebin.com/raw/RXc2TsEf
To Reproduce
or in browser
(
http
is https://httpie.io, alternative to curl)Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add log output to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.