Comments (2)
I was suspicious myself, so I did some additional testing based on the officially obtained open API example from the Microcks:
https://raw.githubusercontent.com/microcks/microcks/master/samples/APIPastry-openapi.yaml
I tried :
- launch the mock service with above openapi 3 spec:
npx @stoplight/prism-cli@latest mock https://raw.githubusercontent.com/microcks/microcks/master/samples/APIPastry-openapi.yaml
- list api works well:
$ http :4010/pastry
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: *
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: *
Connection: keep-alive
Content-Length: 378
Content-type: application/json
Date: Tue, 17 Oct 2023 00:51:50 GMT
Keep-Alive: timeout=5
[
{
"description": "Delicieux Baba au Rhum pas calorique du tout",
"name": "Baba Rhum",
"price": 3.2,
"size": "L",
"status": "available"
},
{
"description": "Delicieux Divorces pas calorique du tout",
"name": "Divorces",
"price": 2.8,
"size": "M",
"status": "available"
},
{
"description": "Delicieuse Tartelette aux Fraises fraiches",
"name": "Tartelette Fraise",
"price": 2,
"size": "S",
"status": "available"
}
]
- the get api for specific id works well too, but the expected example (the matching response would be value of 'Millefeuille') wasn't returned but the default example was returned
$ http :4010/pastry/Millefeuille
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: *
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: *
Connection: keep-alive
Content-Length: 113
Content-type: application/json
Date: Tue, 17 Oct 2023 00:52:31 GMT
Keep-Alive: timeout=5
{
"description": "A short description os my pastry",
"name": "My Pastry",
"price": 4.5,
"size": "M",
"status": "available"
}
- the patch api returns wrong validation too. (price must be number even if I gave the 10.5 which is proper number input with httpie)
$ http patch :4010/pastry/M
illefeuille price=10.5
HTTP/1.1 422 Unprocessable Entity
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: *
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: *
Connection: keep-alive
Content-Length: 372
Date: Tue, 17 Oct 2023 00:54:22 GMT
Keep-Alive: timeout=5
content-type: application/problem+json
{
"detail": "Your request is not valid and no HTTP validation response was found in the spec, so Prism is generating this error for you.",
"status": 422,
"title": "Invalid request",
"type": "https://stoplight.io/prism/errors#UNPROCESSABLE_ENTITY",
"validation": [
{
"code": "type",
"location": [
"body",
"price"
],
"message": "Request body property price must be number",
"severity": "Error"
}
]
}
from prism.
Hi @jinyoung, it looks like the default behavior for httpie is to pass variables as strings according to their documentation. In order to pass a body param as an integer you have to use the :=
syntax. So you're actually sending Prism a string and not an integer for those body params, so Prism's response is correct and expected. You can also use the --print
option as outlined here to see what request you're actually sending Prism.
from prism.
Related Issues (20)
- An invalid schema will cause the validation proxy to always pass HOT 1
- query parameter name with "[]" not work on prism proxy
- Same URLs with differently typed path variables does not route correctly HOT 2
- Prism misvalidate boolean query params HOT 1
- [NOT A BUG -> QUESTION] how to set fix path variables HOT 2
- Add dynamic mocking to proxy
- Unable to build binary on node.js 20 HOT 2
- Enable Multi arch Build in DockerHub HOT 1
- Prism Proxy Request Violation for Valid oneOf Schemas HOT 2
- Accept array parameters in request body regardless of name convention HOT 2
- Prism Proxy is not working as expected for binary content types image/jpeg and application/pdf HOT 3
- Refactor Pino Logger usage to allow any logger
- Proxy is not validating against the correct response schema when using accept header for versioning HOT 3
- Docker images fail on startup when api specification.yml is specified HOT 1
- Prism docker image vulnerabilities HOT 1
- AdditionalItems never returned in response HOT 2
- Prism proxy returns 401 when the actual response from the server is 403 HOT 3
- Facilitate fully dynamic response generation by default in "prism proxy" scenario HOT 2
- Missing response validation HOT 2
- How to run and maintain Prism mock server on Azure Devops pipeline (Linux agents) with powershell HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prism.