Open RafDevX opened 1 week ago
Hi @RafDevX. I need to do some updates on how examples are being considered. But the generation should be find. I use the following OpenAPI spec (starting from your snippet):
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification
termsOfService: http://swagger.io/terms/
contact:
name: Swagger API Team
email: apiteam@swagger.io
url: http://swagger.io
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: http://petstore.swagger.io/api
paths:
/sum:
post:
operationId: sum
summary: Sum multiple numbers
requestBody:
description: The list of numbers to sum
content:
application/json:
schema:
type: array
items:
type: number
examples:
list-of-three:
value:
nums: [ 23, 27, 2 ]
responses:
'200':
description: The sum of the numbers
content:
application/json:
schema:
type: number
examples:
sum-of-three:
value: 52
And I get the following payload:
[
8.586701801327482,
8.586701801327482
]
Hi, you're right -- if I change the OpenAPI spec version to 3.0.0, then it does generate numbers as expected. I think the problem was using v3.1.
To be honest I'm not even sure if you officially support 3.1, I couldn't find that information in the documentation. If you don't, then please feel free to close this issue, as far as I can tell from a quick test it's working fine in 3.0, but maybe consider specifying that in the README.
I just (perhaps incorrectly) assumed v3.1 was supported because of this line: https://github.com/Endava/cats/blob/16d76559184f0aa6bf6449c717049d6822ff799a/src/main/java/com/endava/cats/util/OpenApiParseResult.java#L29
Thanks again for your help!
It does support OpenAPI v3.1. There was an issue I've fixed last night. I'll push the fix later today.
Describe the bug When specifying that a request body should be a JSON array of numbers, CATS's HappyPath fuzzer is using strings (e.g.
DGZTERFXUNVTGLSACSDVVV
) instead of numbers.To Reproduce Steps to reproduce the behaviour:
cats --contract=... --server=... --fuzzers=Happy
HappyPath
's attempted request is something likeExpected behaviour CATS should send an array of numbers, not an array of strings, if it expects a 2xx response
Environment: Output of
cats info
:Contract snippet:
Additional context I have tried
type: number
as well astype: integer
(with and withoutformat: int32
).This may very well be my own fault, and if so I apologize in advance - this is my first time using CATS.
Thank you for all your work maintaining this tool! :grinning: