Beispiel #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
Beispiel #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
def test_no_op():
    fragment = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    expected = {
        'MON': {
            '$ref': '#/definitions/DayHours',
        }
    }
    assert expected == strip_xscope(fragment)
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]
Beispiel #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
Beispiel #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
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']
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]
def test_petstore_spec(petstore_spec):
    assert petstore_spec.client_spec_dict == strip_xscope(petstore_spec.spec_dict)
def test_empty():
    assert {} == strip_xscope({})