### Question:
OpenApiSpecStyleValidator { public List<StyleError> validate(ValidatorParameters parameters) { this.parameters = parameters; validateInfo(); validateOperations(); validateModels(); validateNaming(); return errorAggregator.getErrorList(); } OpenApiSpecStyleValidator(OpenAPI openApi); List<StyleError> validate(ValidatorParameters parameters); static final String INPUT_FILE; }### Answer:
@Test void validatePingOpenAPI() { OpenAPI openAPI = createPingOpenAPI(); OpenApiSpecStyleValidator validator = new OpenApiSpecStyleValidator(openAPI); ValidatorParameters parameters = new ValidatorParameters(); List<StyleError> errors = validator.validate(parameters); assertTrue(errors.size() == 1); assertEquals("*ERROR* in Model 'Myobject', property 'name', field 'example' -> This field should be present and not empty", errors.get(0).toString()); }
@Test void validatePingOpenAPI_without_ValidateModelPropertiesExample() { OpenAPI openAPI = createPingOpenAPI(); OpenApiSpecStyleValidator validator = new OpenApiSpecStyleValidator(openAPI); ValidatorParameters parameters = new ValidatorParameters(); parameters.setValidateModelPropertiesExample(false); List<StyleError> errors = validator.validate(parameters); assertTrue(errors.size() == 0); }
@Test void validatePingOpenAPI_WithoutSchema_and_components() { OpenAPI openAPI = createSimplePingOpenAPI(); OpenApiSpecStyleValidator validator = new OpenApiSpecStyleValidator(openAPI); ValidatorParameters parameters = new ValidatorParameters(); List<StyleError> errors = validator.validate(parameters); assertTrue(errors.size() == 0); }