@Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-tag-name-not-upper-camel-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(TagNameCaseValidator.CONFIG_KEY, "upper-camel-case") ); List<OasViolation> violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).hasSize(1); assertThat(violations) .containsExactly( createViolation(TagNameCaseValidator.ERROR + "upper-camel-case", "tags[0]", TAG, "name", null)); }
@Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { if (!isMatchCase(expectedCase, tag.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); }
TagNameCaseValidator implements TagValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { if (!isMatchCase(expectedCase, tag.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } }
TagNameCaseValidator implements TagValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { if (!isMatchCase(expectedCase, tag.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } TagNameCaseValidator(String expectedCase); }
TagNameCaseValidator implements TagValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { if (!isMatchCase(expectedCase, tag.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } TagNameCaseValidator(String expectedCase); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag); }
TagNameCaseValidator implements TagValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag) { if (!isMatchCase(expectedCase, tag.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } TagNameCaseValidator(String expectedCase); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Tag tag); static final String CONFIG_KEY; static final String ERROR; }