DeconflictingStrategy implements RefStrategy { @Override public String toPointer(ShapeId id) { return pointers.computeIfAbsent(id, delegate::toPointer); } DeconflictingStrategy(Model model, RefStrategy delegate); @Override String toPointer(ShapeId id); @Override boolean isInlined(Shape shape);  }
@Test public void canDeconflictNamesWhereListsAreActuallyDifferent() { StringShape str = StringShape.builder().id("com.bar#String").build(); MemberShape memberA = MemberShape.builder().id("com.bar#Page$member").target("com.bar#String").build(); ListShape a = ListShape.builder().id("com.bar#Page").member(memberA).build(); IntegerShape integer = IntegerShape.builder().id("com.foo#Int").build(); MemberShape memberB = MemberShape.builder().id("com.foo#Page$member").target("com.foo#Int").build(); ListShape b = ListShape.builder().id("com.foo#Page").member(memberB).build(); Model model = Model.builder().addShapes(str, integer, a, b, memberA, memberB).build(); PropertyNamingStrategy propertyNamingStrategy = PropertyNamingStrategy.createDefaultStrategy(); RefStrategy strategy = RefStrategy .createDefaultStrategy(model, new JsonSchemaConfig(), propertyNamingStrategy); assertThat(strategy.toPointer(a.getId()), equalTo("#/definitions/Page")); assertThat(strategy.toPointer(b.getId()), equalTo("#/definitions/PageComFoo")); }
@Test public void deconflictingStrategyPassesThroughToDelegate() { Model model = Model.builder().build(); PropertyNamingStrategy propertyNamingStrategy = PropertyNamingStrategy.createDefaultStrategy(); RefStrategy strategy = RefStrategy .createDefaultStrategy(model, new JsonSchemaConfig(), propertyNamingStrategy); assertThat(strategy.toPointer(ShapeId.from("com.foo#Nope")), equalTo("#/definitions/Nope")); }