-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specmatic unusual behaviour #1417
Comments
@twinkle12b thanks a lot for sharing the details regarding the issue. We are taking a look. |
hello @twinkle12b, we did a initial analysis of the issues you have reported and here are our findings and comments on the same. Issue no 1: I see that the pattern That said there is indeed an issue in how Specmatic is also handling this contradiction. When generating test, it is purely going by the pattern thereby coming up with strings of length greater than 11. We are already in the process of addressing this by flagging such contradictions while reading the API spec itself so that we can give you feedback on the same. I will keep you posted on the progress. Meanwhile can you please update the spec so that Issue no 2: Question regarding discriminator with In the schema you have shared, the discriminator syntax does not seem to be as per OpenAPI spec docs. Please let me know if I am missing something here. We took a stab at updating it ourselves, here is the version that in line with OpenAPI spec. components:
schemas:
BaseAnimal:
type: object
required:
- type
- name
properties:
type:
type: string
name:
type: string
Dog:
allOf:
- $ref: '#/components/schemas/BaseAnimal'
- type: object
properties:
animal:
type: string
pattern: "^Dog$"
breed:
type: string
barkVolume:
type: integer
Cat:
allOf:
- $ref: '#/components/schemas/BaseAnimal'
- type: object
properties:
animal:
type: string
pattern: "^Cat$"
breed:
type: string
isIndoor:
type: boolean
Animal:
oneOf:
- $ref: '#/components/schemas/Dog'
- $ref: '#/components/schemas/Cat'
discriminator:
propertyName: type
mapping:
dog: '#/components/schemas/Dog'
cat: '#/components/schemas/Cat' Can you please have a look at the above and see if this is what you wanted to achieve with your schema design? Also took the liberty to update your issue description to improve formatting for readability. Please let us know if you have any questions on this. Thanks. |
Hello @harikrishnan83 thank you so much for going through my issues and also kind of resolving the first one. Let me get back to you on the discriminator issue that I am facing with more detail example. |
Issue regarding generating wrong examples - For a property specified in openapi.yaml with maxlength 11 and type: string, pattern:
"^([1-9]\\d{0,10})(\\.\\d{0,10})?$"
it keeps generating a string sometimes with length greater than 11 and fails in generative tests. Can you please help?Also We use discriminator types in openapi.yaml instead of enums, and usage of pattern to generate specific string names as the name of discriminator types for eg:
----- So when use specmatic examples openapi.yaml to generate examples specmatic generate proper examples but for the examples that get generated with second discriminator types say- animal cat-- it keeps throwing error on run saying expected Dog but found cat which is against the contract. Please help me with these issues
UPDATE: Formatting changes by @harikrishnan83 for readability
The text was updated successfully, but these errors were encountered: