@Test public void testValidate() { OpenAPI openAPI = loadRelative("petstore-parameter-header-upper-hyphen-case.yaml"); OasSpecValidator oasSpecValidator = oasSpecValidatorFactory.create( singleOption(ParameterNameHeaderCaseValidator.CONFIG_KEY, "upper-hyphen-case") ); List<OasViolation> violations = oasSpecValidator.validate(createContext(openAPI), openAPI); assertThat(violations).containsExactlyInAnyOrder( createViolation( ParameterNameHeaderCaseValidator.ERROR + "upper-hyphen-case", "paths", PATHS, "/pets/{petId}", PATH_ITEM, "get", OPERATION, "parameters[1]", PARAMETER, "name", null ), createViolation( ParameterNameHeaderCaseValidator.ERROR + "upper-hyphen-case", "components", COMPONENTS, "parameters.'Bar'", PARAMETER, "name", null ) ); }
@Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"header".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); }
ParameterNameHeaderCaseValidator implements ParameterValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"header".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } }
ParameterNameHeaderCaseValidator implements ParameterValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"header".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } ParameterNameHeaderCaseValidator(String expectedCase); }
ParameterNameHeaderCaseValidator implements ParameterValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"header".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } ParameterNameHeaderCaseValidator(String expectedCase); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location,
    Parameter oasObject); }
ParameterNameHeaderCaseValidator implements ParameterValidator { @Override public List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location, Parameter oasObject) { if (StringUtils.isNotBlank(oasObject.get$ref())) { return emptyList(); } if (!"header".equalsIgnoreCase(oasObject.getIn())) { return emptyList(); } if (!isMatchCase(expectedCase, oasObject.getName())) { return singletonList(new OasViolation(location.property("name"), ERROR + expectedCase)); } return emptyList(); } ParameterNameHeaderCaseValidator(String expectedCase); @Override List<OasViolation> validate(OasValidationContext context, OasObjectPropertyLocation location,
    Parameter oasObject); static final String CONFIG_KEY; static final String ERROR; }