@Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-operation-servers-empty.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(OperationServersSizeEqValidator.CONFIG_KEY, "0") ); List<OasViolation> violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactly( createViolation(OperationServersSizeEqValidator.ERROR + "0", "paths", PATHS, "/pets", PATH_ITEM, "get", OPERATION, "servers", SERVER)); }
@Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (CollectionUtils.size(oasObject.getServers()) != expectedSize) { return singletonList(new OasViolation(location.property("servers", SERVER), ERROR + expectedSize)); } return emptyList(); }
OperationServersSizeEqValidator implements OperationValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (CollectionUtils.size(oasObject.getServers()) != expectedSize) { return singletonList(new OasViolation(location.property("servers", SERVER), ERROR + expectedSize)); } return emptyList(); } }
OperationServersSizeEqValidator implements OperationValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (CollectionUtils.size(oasObject.getServers()) != expectedSize) { return singletonList(new OasViolation(location.property("servers", SERVER), ERROR + expectedSize)); } return emptyList(); } OperationServersSizeEqValidator(int expectedSize); }
OperationServersSizeEqValidator implements OperationValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (CollectionUtils.size(oasObject.getServers()) != expectedSize) { return singletonList(new OasViolation(location.property("servers", SERVER), ERROR + expectedSize)); } return emptyList(); } OperationServersSizeEqValidator(int expectedSize); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location,
    Operation oasObject); }
OperationServersSizeEqValidator implements OperationValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Operation oasObject) { if (CollectionUtils.size(oasObject.getServers()) != expectedSize) { return singletonList(new OasViolation(location.property("servers", SERVER), ERROR + expectedSize)); } return emptyList(); } OperationServersSizeEqValidator(int expectedSize); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location,
    Operation oasObject); static final String CONFIG_KEY; static final String ERROR; }