def test_swagger_specs_validate(self, api): response = api.get(url_for('api.specs')) try: schemas.validate(response.json) except schemas.SchemaValidationError as e: print(e.errors) raise
def test_oas_20_invalid(self): with pytest.raises(schemas.SchemaValidationError) as excinfo: schemas.validate({ 'swagger': '2.0', 'should': 'not be here', }) for error in excinfo.value.errors: assert isinstance(error, ValidationError)
def validate(): '''Validate the Swagger/OpenAPI specification with your config''' with current_app.test_request_context(): schema = json.loads(json.dumps(api.__schema__)) try: schemas.validate(schema) success('API specifications are valid') except schemas.SchemaValidationError as e: exit_with_error('API specifications are not valid', e)
def test_oas_20_valid(self): assert schemas.validate({ 'swagger': '2.0', 'info': { 'title': 'An empty minimal specification', 'version': '1.0', }, 'paths': {}, })
def test_unknown_version(self): with pytest.raises(errors.SpecsError): schemas.validate({'swagger': '42.0'})
def test_unknown_schema(self): with pytest.raises(errors.SpecsError): schemas.validate({'valid': 'no'})
def test_swagger_specs_validate(self, api): response = api.get(url_for('api.specs')) schemas.validate(response.json)