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