Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
 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)
Пример #4
0
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)
Пример #5
0
 def test_oas_20_valid(self):
     assert schemas.validate({
         'swagger': '2.0',
         'info': {
             'title': 'An empty minimal specification',
             'version': '1.0',
         },
         'paths': {},
     })
Пример #6
0
 def test_unknown_version(self):
     with pytest.raises(errors.SpecsError):
         schemas.validate({'swagger': '42.0'})
Пример #7
0
 def test_unknown_schema(self):
     with pytest.raises(errors.SpecsError):
         schemas.validate({'valid': 'no'})
Пример #8
0
 def test_swagger_specs_validate(self, api):
     response = api.get(url_for('api.specs'))
     schemas.validate(response.json)