Object instance has properties which are not allowed by the schema
Hello,
I get this weird exception with version 1.5.0. however with version 1.47-SNAPSHOT that I had built locally a month back, it looks fine. So, I tried to debug and see inputs to core-validator (validator.validate(PactRequest.of(i.getRequest()), PactResponse.of(i.getResponse()))
) in both cases and input is same in both cases.. but the output has error in case of 1.50 (in case of 1.47-SNAPSHOT, there is no error).
I have attached swagger json file (if you can make that private that would be preferred).
PactRequest input (PactRequest.of(i.getRequest())
) to validator::
Optional[{"amount":100,"myId":3,"sellerId":3333,"levelTwoCategory":"CARS VANS UTES","levelOneCategory":"AUTOS","sellerRandomUserId":222222,"buyerId":1234,"buyerRandomUserId":111111}]
PactResponse input (PactResponse.of(i.getResponse())
) to validator:
Optional[{"result":{"l1Category":"AUTOS","modificationDate":"2017-10-10T13:36:27.359+1100","amount":100,"l2Category":"CARS VANS UTES","myId":3,"currency":"AUD","id":1,"state":"PENDING","creationDate":"2017-10-10T13:36:27.359+1100","version":0}}]
I am wondering whether there is any change recently in core validator that might be breaking it. Can you please have a look. Thanks a lot.
com.atlassian.oai.validator.pact.ValidatedPactProviderRule$PactValidationError: Validation failed.
[ERROR] [Path '/result'] Object instance has properties which are not allowed by the schema: ["myId","amount","creationDate","currency","id","l1Category","l2Category","modificationDate","state","version"]
at com.atlassian.oai.validator.pact.ValidatedPactProviderRule.validatePactDef(ValidatedPactProviderRule.java:98)
at com.atlassian.oai.validator.pact.ValidatedPactProviderRule.access$000(ValidatedPactProviderRule.java:27)
at com.atlassian.oai.validator.pact.ValidatedPactProviderRule$1.evaluate(ValidatedPactProviderRule.java:78)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Comments (7)
-
-
https://bitbucket.org/atlassian/swagger-request-validator/pull-requests/93 is the PR that fixed the additional properties validation.
-
reporter Thanks @jnavin. No worries about the file, it does not really have any sensitive data. My request/response looks fine and aligned with swagger API spec. Having a look at issue description.
-
reporter Great.. worked! Please resolve this. It was issue with the spec.. Lazy developers. ;) Thanks!
-
Awesome! Happy to help.
-
- changed status to resolved
-
reporter - edited description
- Log in to comment
I cant make the issue private, unfortunately (Bitbucket issues don't support that functionality). If the attached file is sensitive I would recommend removing it and maybe try to reproduce the problem with a simpler dummy example.
Re changes - I suspect it is probably to do with issue
#131which was merged in the 1.4.7 release (basically, additional field validation wasn't being performed properly for nested schema).