Ejemplo n.º 1
0
 def view_for_swagger_schema(request):
     path, ext = os.path.splitext(request.path)
     ext = ext.lstrip('.')
     actual_fname = file_map[request.path]
     with spec.resolver.resolving(actual_fname) as spec_dict:
         clean_response = strip_xscope(spec_dict)
         ref_walker = NodeWalkerForCleaningRefs()
         fixed_spec = ref_walker.walk(clean_response, ext)
         return fixed_spec
Ejemplo n.º 2
0
 def view_for_swagger_schema(request):
     path, ext = os.path.splitext(request.path)
     ext = ext.lstrip('.')
     actual_fname = file_map[request.path]
     with spec.resolver.resolving(actual_fname) as spec_dict:
         clean_response = strip_xscope(spec_dict)
         ref_walker = NodeWalkerForCleaningRefs()
         fixed_spec = ref_walker.walk(clean_response, ext)
         return fixed_spec
Ejemplo n.º 3
0
def test_no_op():
    fragment = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    expected = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    assert expected == strip_xscope(fragment)
Ejemplo n.º 4
0
def test_contained_in_list():
    fragment = [{
        '$ref':
        '#/definitions/DayHours',
        'x-scope': [
            'file:///happyhour/api_docs/swagger.json',
            'file:///happyhour/api_docs/swagger.json#/definitions/WeekHours'
        ]
    }]
    expected = [{
        '$ref': '#/definitions/DayHours',
    }]
    assert expected == strip_xscope(fragment)
    assert 'x-scope' in fragment[0]
Ejemplo n.º 5
0
    def view_for_swagger_schema(request):
        _, ext = os.path.splitext(request.path)
        ext = ext.lstrip('.')

        base_path = config.registry.settings\
            .get('pyramid_swagger.base_path_api_docs', '').rstrip('/')

        key_path = request.path_info[len(base_path):]

        actual_fname = file_map[key_path]

        with spec.resolver.resolving(actual_fname) as spec_dict:
            clean_response = strip_xscope(spec_dict)
            ref_walker = NodeWalkerForCleaningRefs()
            fixed_spec = ref_walker.walk(clean_response, ext)
            return fixed_spec
Ejemplo n.º 6
0
    def view_for_swagger_schema(request):
        _, ext = os.path.splitext(request.path)
        ext = ext.lstrip('.')

        base_path = config.registry.settings\
            .get('pyramid_swagger.base_path_api_docs', '').rstrip('/')

        key_path = request.path_info[len(base_path):]

        actual_fname = file_map[key_path]

        with spec.resolver.resolving(actual_fname) as spec_dict:
            clean_response = strip_xscope(spec_dict)
            ref_walker = NodeWalkerForCleaningRefs()
            fixed_spec = ref_walker.walk(clean_response, ext)
            return fixed_spec
Ejemplo n.º 7
0
def test_contained_in_dict():
    fragment = {
        'MON': {
            '$ref': '#/definitions/DayHours',
            'x-scope': [
                'file:///happyhour/api_docs/swagger.json',
                'file:///happyhour/api_docs/swagger.json#/definitions/WeekHours'
            ]
        }
    }
    expected = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    assert expected == strip_xscope(fragment)
    assert 'x-scope' in fragment['MON']
Ejemplo n.º 8
0
def test_contained_in_list():
    fragment = [
        {
            '$ref': '#/definitions/DayHours',
            'x-scope': [
                'file:///happyhour/api_docs/swagger.json',
                'file:///happyhour/api_docs/swagger.json#/definitions/WeekHours'
            ]
        }
    ]
    expected = [
        {
            '$ref': '#/definitions/DayHours',
        }
    ]
    assert expected == strip_xscope(fragment)
    assert 'x-scope' in fragment[0]
Ejemplo n.º 9
0
def test_petstore_spec(petstore_spec):
    assert petstore_spec.client_spec_dict == strip_xscope(petstore_spec.spec_dict)
Ejemplo n.º 10
0
def test_empty():
    assert {} == strip_xscope({})