Beispiel #1
0
    def __init__(self):
        self.resources, self.apis, self.models = api.introspect()
        self.resources.sort(key=lambda res: res['id'])
        for r in self.apis.values():
            r.sort(key=lambda a: a['path'])
        # Add path to each resource
        for r in self.resources:
            r['path'] = '/' + r['id']

        self.fts_core_version = _get_fts_core_version()
           'resourcePath': resource_path,
           'authorizations': {},
           'apis': apis.get(resource_path, []),
           'models': models.get(resource_path, []),
        }
        
        api_path = os.path.join(options.output_directory, resource_path.strip('/'))
        open(api_path, 'wt').write(json.dumps(swagger_api, indent=2, sort_keys = True))


if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option('-d', '--directory', dest='output_directory', default=None,
                      help='Where to write the output files. This is mandatory.')
    parser.add_option('-f', '--file', dest='index', default='resources.json',
                      help='Name of the resources file')
    
    (options, args) = parser.parse_args()
    if options.output_directory is None:
        parser.print_help()
        parser.exit(1)

    resources, apis, models = api.introspect()

    resources.sort(key=lambda r:r['path'])
    for api in apis.values():
        api.sort(key=lambda a:a['path'])
    
    write_resources(options, resources)
    write_apis(options, resources, apis, models)
Beispiel #3
0
 def __init__(self):
     self.resources, self.apis, self.models = api.introspect()
     self.resources.sort(key=lambda res: res['path'])
     for r in self.apis.values():
         r.sort(key=lambda a: a['path'])
             'wt').write(json.dumps(swagger_api, indent=2, sort_keys=True))


if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option(
        '-d',
        '--directory',
        dest='output_directory',
        default=None,
        help='Where to write the output files. This is mandatory.')
    parser.add_option('-f',
                      '--file',
                      dest='index',
                      default='resources.json',
                      help='Name of the resources file')

    (options, args) = parser.parse_args()
    if options.output_directory is None:
        parser.print_help()
        parser.exit(1)

    resources, apis, models = api.introspect()

    resources.sort(key=lambda r: r['id'])
    for api in apis.values():
        api.sort(key=lambda a: a['path'])

    write_resources(options, resources)
    write_apis(options, resources, apis, models)