Jacob Rede
01/11/2023, 6:23 PM"response": {
"status": 200,
"headers": {
"content-type": "application/json",
"access-control-allow-origin": "<http://exampleapi.com|exampleapi.com>"
},
"oneOf": {
"body": {
"id": "string",
"email": "string",
"group": "string",
"isOnboarded": true,
"organizationId": 0,
"createdAt": "string",
"updatedAt": "string",
"contactType": "string",
"devices": ["string"],
"notificationPreferences": { "email": true, "sms": true },
"phone": "string",
"isDeactivated": true,
"deactivatedAt": "string",
"entityName": "string"
}
}
}
However its impossible to create a response like this with cypress. Cypress’s intercept can only return a body, not a oneOf. How can we resolve this?Matt (pactflow.io / pact-js / pact-go)
oneOf
?Matt (pactflow.io / pact-js / pact-go)
oneOf
is a logical keyword in JSON schema, and not something that should appear in an actual body.Jacob Rede
01/11/2023, 9:26 PMMatt (pactflow.io / pact-js / pact-go)
Jacob Rede
01/11/2023, 9:28 PMJacob Rede
01/11/2023, 9:28 PM"responses": {
"200": {
"description": "The found contact if they exist",
"content": {
"application/json": {
"schema": {
"oneOf": [
{ "$ref": "#/components/schemas/IndividualContact" },
{ "$ref": "#/components/schemas/AgentContact" },
{ "$ref": "#/components/schemas/EntityContact" },
{ "$ref": "#/components/schemas/LenderContact" },
{ "$ref": "#/components/schemas/InternalContact" }
]
}
}
}
},
Jacob Rede
01/11/2023, 9:28 PMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Jacob Rede
01/11/2023, 9:50 PMJacob Rede
01/11/2023, 9:52 PMJacob Rede
01/11/2023, 9:53 PMMatt (pactflow.io / pact-js / pact-go)
entityName
in either of those schemasMatt (pactflow.io / pact-js / pact-go)
Jacob Rede
01/11/2023, 11:20 PMJacob Rede
01/11/2023, 11:21 PMMatt (pactflow.io / pact-js / pact-go)
Jacob Rede
01/11/2023, 11:56 PMMatt (pactflow.io / pact-js / pact-go)
Candy Goodison
01/18/2023, 12:27 AM/v2/contacts/{contactId}
.
Digging into this the issue here is that the 2 objects provided are too similar for our tool to match the response from your pact file to one of these objects. This is because one has properties that are the subset of the other, and no unique properties of its own.
In this case we recommend combining the objects into one schema rather than using the oneOf keyword, and making the required list contain the fields that your consumers are using.Eugene Malihins
01/25/2023, 3:46 PMinlining the oneOf
keywords please? I'm observing issues very similar to what Jacob posted here - this is after i dereferenced all $ref
, and in our schema we also have a bunch of oneOf
responses.
json-schema-merge-allof
seems to not affect oneOf
keywords at all 🤔Eugene Malihins
01/26/2023, 7:52 PMoneOf
keywords inside the schema with Properties, each of the oneOf
schemas also having Properties. Errors of the kind should NOT have additional properties
- not sure how to work around it if there's no option to allow additional properties? Something along these lines?
• if i set --additionalPropertiesInResponse true
in swagger-mock-validator ^ goes away, but two more issues occur:
• Response body is incompatible with the response body schema in the spec file: should match exactly one schema in oneOf
and Request body is incompatible with the request body schema in the spec file: should match exactly one schema in oneOf
What's strange looking to me about the last two errors are these two comparisons:
Comparing Mock
value: { day: 5, interval: 2, month: 4, type: 'YEARLY' }
With OAS
value: [ 'daysOfWeek', 'interval', 'type' ]
and
Comparing Mock
value: { daysOfMonth: [Array], interval: 1, type: 'MONTHLY' }
With OAS
value: [ [Object], [Object], [Object], [Object] ]
In the first case it compares mock response with a non-matching oneOf
schema (while there is a matching one, but it doesn't error). And in the second case it compares request with a literal [Object]
?
Any help/pointers are appreciated 🙏Candy Goodison
01/29/2023, 10:57 PMEugene Malihins
01/30/2023, 9:24 AMMatt (pactflow.io / pact-js / pact-go)