コード例 #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
コード例 #2
0
ファイル: api.py プロジェクト: lovelysystems/pyramid_swagger
 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
コード例 #3
0
def test_no_op():
    fragment = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    expected = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    assert expected == strip_xscope(fragment)
コード例 #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]
コード例 #5
0
ファイル: api.py プロジェクト: shrayus/pyramid_swagger
    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
コード例 #6
0
ファイル: api.py プロジェクト: macisamuele/pyramid_swagger
    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
コード例 #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']
コード例 #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]
コード例 #9
0
def test_petstore_spec(petstore_spec):
    assert petstore_spec.client_spec_dict == strip_xscope(petstore_spec.spec_dict)
コード例 #10
0
def test_empty():
    assert {} == strip_xscope({})