def generate_discovery_doc(self, api_config, api_format):
    """Generates a discovery document from an API file.

    Args:
      api_config: A string containing the .api file contents.
      api_format: A string, either 'rest' or 'rpc' depending on the which kind
        of discvoery doc is requested.

    Returns:
      The discovery doc as JSON string.

    Raises:
      ValueError: When api_format is invalid.
    """
    if api_format not in ['rest', 'rpc']:
      raise ValueError('Invalid API format')
    path = 'apis/generate/' + api_format
    request_dict = {'config': json.dumps(api_config)}
    request_body = json.dumps(request_dict)
    return self._dispatch_request(path, request_body)
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/devappserver2/endpoints/discovery_api_proxy.py/DiscoveryApiProxy.generate_discovery_doc/original