Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_issue_23_partial_resolution_files():
specs = get_specs('tests/specs/with_externals.yaml')
res = resolver.RefResolver(specs,
fs.abspath('tests/specs/with_externals.yaml'),
resolve_types = resolver.RESOLVE_FILES
)
res.resolve_references()
# By default, all externals need to be resolved.
from prance.util.path import path_get
val = path_get(res.specs, ('paths', '/pets', 'get', 'responses', '200', 'schema'))
assert '$ref' not in val
val = path_get(res.specs, ('paths', '/pets', 'get', 'responses', 'default', 'schema'))
assert '$ref' not in val
val = path_get(res.specs, ('paths', '/pets', 'post', 'responses', 'default', 'schema'))
assert '$ref' not in val
def __write_to_file(filename, specs): # noqa: N802
"""
Write specs to the given filename.
This takes into account file name extensions as per `fs.write_file`.
"""
from prance.util import fs, formats
contents = formats.serialize_spec(specs, filename)
fs.write_file(filename, contents)
def merge_swagger_file(main_file: str):
"""
Generate swagger into a single file
:param main_file: Swagger file path
:return:
"""
input_file = Path(main_file)
output_file = Path(input_file.parent, 'swagger-complete.yaml')
contents = formats.serialize_spec(
specs=get_bundled_specs(input_file),
filename=output_file,
)
fs.write_file(filename=output_file,
contents=contents,
encoding='utf-8')