Beispiel #1
0
def test_openapi_spec_validator_issue_20_spec_version_handling():
  # The spec is OpenAPI 3, but broken. Need to set 'strict' to False to stringify keys
  with pytest.raises(ValidationError):
    parser = BaseParser('tests/specs/issue_20.yaml', backend = 'openapi-spec-validator', strict = False)

  # Lazy parsing should let us validate what's happening
  parser = BaseParser('tests/specs/issue_20.yaml', backend = 'openapi-spec-validator', strict = False, lazy = True)
  assert not parser.valid
  assert parser.version_parsed == ()

  with pytest.raises(ValidationError):
    parser.parse()

  # After parsing, the specs are not valid, but the correct version is
  # detected.
  assert not parser.valid
  assert parser.version_parsed == (3, 0, 0)
Beispiel #2
0
def test_load_and_parse_lazy():
    parser = BaseParser("tests/specs/petstore.yaml", lazy=True)
    assert parser.specification is None, "Should not have specs yet!"

    parser.parse()
    assert parser.specification, "No specs loaded!"
Beispiel #3
0
def test_load_and_parse_lazy():
    parser = BaseParser('tests/specs/petstore.yaml', lazy=True)
    assert parser.specification is None, 'Should not have specs yet!'

    parser.parse()
    assert parser.specification, 'No specs loaded!'