- edited description
Throws Exception for additional Properties
Issue #123
resolved
We have a Complex Object defined as following, and when we run PACT testing it fails.
#Settings:
Settings:
description: Elasticsearch settings
type: object
additionalProperties:
$ref: '#/definitions/ComplexObject'
example:
number_of_shards: 5
number_of_replicas: 1
analysis.analyzer.keyword_lowercase_analyzer.filter: lowercase
#ComplexObject
ComplexObject:
type: object
Error Stack trace:
java.lang.AssertionError: * test-elastic-pact
- a request to create index for test1
[ERROR] [Path '/settings/analysis.analyzer.keyword_lowercase_analyzer.filter'] Instance type (string) does not match any allowed primitive type (allowed: ["object"])
[ERROR] [Path '/settings/analysis.analyzer.keyword_lowercase_analyzer.tokenizer'] Instance type (string) does not match any allowed primitive type (allowed: ["object"])
[ERROR] [Path '/settings/analysis.analyzer.keyword_lowercase_analyzer.type'] Instance type (string) does not match any allowed primitive type (allowed: ["object"])
[ERROR] [Path '/settings/number_of_replicas'] Instance type (integer) does not match any allowed primitive type (allowed: ["object"])
[ERROR] [Path '/settings/number_of_shards'] Instance type (integer) does not match any allowed primitive type (allowed: ["object"])
Expected: is <false>
but: was <true>
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:956)
at com.amdocs.catalogone.ms.entitysearch.pact.EntitySearchPactProviderTest.validate_withLocalPact_withValidInteractions(EntitySearchPactProviderTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Comments (3)
-
-
From my understanding, the schema
additionalProperties: $ref: '#/definitions/ComplexObject'
Says "every additional property should look like a
ComplexObject
", whereas you are passing e.g. StringsI would suggest trying:
- Replace with
additionalProperties: true
to allow any schema for additional props; OR - Use the OpenAPI v3 spec with
anyOf
oroneOf
to allow Objects or Strings or Integers etc.
- Replace with
-
- changed status to resolved
Closing due to inactivity. Please feel free to re-open.
- Log in to comment