How to use the prance.util.formats.parse_spec function in prance

To help you get started, we’ve selected a few prance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jfinkhaeuser / prance / tests / test_convert.py View on Github external
def test_convert_url():
  from prance.util import url
  converted, content_type = convert.convert_url(url.absurl('python://tests/specs/petstore.yaml'))

  # Check correct content type
  assert 'yaml' in content_type

  # Parsing can't fail.
  from prance.util import formats
  parsed = formats.parse_spec(converted, content_type = content_type)

  # Assert the correct target version
  assert 'openapi' in parsed
  assert parsed['openapi'].startswith('3.')
github jfinkhaeuser / prance / tests / test_util_formats.py View on Github external
def test_parse_unknown_ctype():
  with pytest.raises(formats.ParseError):
    formats.parse_spec('{-', None, content_type = 'text/xml')
github jfinkhaeuser / prance / tests / test_util_formats.py View on Github external
def test_parse_yaml_ctype():
  yaml = """---
foo: bar
"""
  parsed = formats.parse_spec(yaml, None, content_type = 'text/yaml')
  assert parsed['foo'] == 'bar', 'Did not parse with explicit YAML'
github jfinkhaeuser / prance / tests / test_util_formats.py View on Github external
def test_parse_unknown():
  with pytest.raises(formats.ParseError):
    formats.parse_spec('{-')
github jfinkhaeuser / prance / tests / test_util_formats.py View on Github external
def test_parse_json():
  json = '{ "foo": "bar" }'

  parsed = formats.parse_spec(json, 'foo.js')
  assert parsed['foo'] == 'bar', 'Did not parse with explicit JSON'
github jfinkhaeuser / prance / tests / test_util_formats.py View on Github external
def test_parse_unknown_ext():
  with pytest.raises(formats.ParseError):
    formats.parse_spec('{-', 'asdf.xml')