def validate(path): try: abspath = os.path.abspath(path) validate_spec_url(pathlib.Path(abspath).as_uri()) except ValidationError as e: pprint(e) sys.exit(1) except Exception as e: pprint(e) sys.exit(2) else: log.info('validating bundled spec: OK')
#!/bin/env python3 # pip3 install --user openapi-spec-validator from openapi_spec_validator import validate_spec_url validate_spec_url('file:///home/kefah/Development/edraj/api-spec/edraj.json')
def test_failed(self, spec_url): with pytest.raises(ValidationError): validate_spec_url(spec_url)
def test_valid(self, spec_url): validate_spec_url(spec_url)
def test_swagger_specification(host): endpoint = os.path.join(host, 'api', 'swagger.json') validate_spec_url(endpoint)
def test_api_definition_validity(self): validate_spec_url('file://' + os.path.abspath('./mygpo/api/openapi.yaml'))
def test_api_definition_validity(self): validate_spec_url("file://" + os.path.abspath("./mygpo/api/openapi.yaml"))