headless/lib/browser/devtools_api/client_api_generator.py
def SynthesizeCommandTypes(json_api):
  """Generate types for command parameters, return values and enum
     properties.
  """
  for domain in json_api['domains']:
    if not 'types' in domain:
      domain['types'] = []
    for type in domain['types']:
      if type['type'] == 'object':
        for property in type.get('properties', []):
          if 'enum' in property and not '$ref' in property:
            SynthesizeEnumType(domain, type['id'], property)

    for command in domain.get('commands', []):
      parameters_required = False
      if 'parameters' in command:
        for parameter in command['parameters']:
          if not 'optional' in parameter:
            parameters_required = True
          if 'enum' in parameter and not '$ref' in parameter:
            SynthesizeEnumType(domain, command['name'], parameter)
        parameters_type = {
            'id': ToTitleCase(SanitizeLiteral(command['name'])) + 'Params',
            'type': 'object',
            'description': 'Parameters for the %s command.' % ToTitleCase(
                SanitizeLiteral(command['name'])),
            'properties': command['parameters']
        }
        domain['types'].append(parameters_type)
      if 'returns' in command:
        for parameter in command['returns']:
          if 'enum' in parameter and not '$ref' in parameter:
            SynthesizeEnumType(domain, command['name'], parameter)
        result_type = {
            'id': ToTitleCase(SanitizeLiteral(command['name'])) + 'Result',
            'type': 'object',
            'description': 'Result for the %s command.' % ToTitleCase(
                SanitizeLiteral(command['name'])),
            'properties': command['returns']
        }
        domain['types'].append(result_type)
      command['parameters_required'] = parameters_required
Generate types for command parameters, return values and enum
     properties.
  
Generate types for command parameters, return values and enum
properties.
Generate types for command parameters return values and enum properties .
def SynthesizeCommandTypes(json_api):
  for domain in json_api['domains']:
    if not 'types' in domain:
      domain['types'] = []
    for type in domain['types']:
      if type['type'] == 'object':
        for property in type.get('properties', []):
          if 'enum' in property and not '$ref' in property:
            SynthesizeEnumType(domain, type['id'], property)
    for command in domain.get('commands', []):
      parameters_required = False
      if 'parameters' in command:
        for parameter in command['parameters']:
          if not 'optional' in parameter:
            parameters_required = True
          if 'enum' in parameter and not '$ref' in parameter:
            SynthesizeEnumType(domain, command['name'], parameter)
        parameters_type = {
            'id': ToTitleCase(SanitizeLiteral(command['name'])) + 'Params',
            'type': 'object',
            'description': 'Parameters for the %s command.' % ToTitleCase(
                SanitizeLiteral(command['name'])),
            'properties': command['parameters']
        }
        domain['types'].append(parameters_type)
      if 'returns' in command:
        for parameter in command['returns']:
          if 'enum' in parameter and not '$ref' in parameter:
            SynthesizeEnumType(domain, command['name'], parameter)
        result_type = {
            'id': ToTitleCase(SanitizeLiteral(command['name'])) + 'Result',
            'type': 'object',
            'description': 'Result for the %s command.' % ToTitleCase(
                SanitizeLiteral(command['name'])),
            'properties': command['returns']
        }
        domain['types'].append(result_type)
      command['parameters_required'] = parameters_required
def SynthesizeCommandTypes ( json_api ) : for domain in json_api [ 'domains' ] : if not 'types' in domain : domain [ 'types' ] = [ ] for type in domain [ 'types' ] : if type [ 'type' ] == 'object' : for property in type . get ( 'properties' , [ ] ) : if 'enum' in property and not '$ref' in property : SynthesizeEnumType ( domain , type [ 'id' ] , property ) for command in domain . get ( 'commands' , [ ] ) : parameters_required = False if 'parameters' in command : for parameter in command [ 'parameters' ] : if not 'optional' in parameter : parameters_required = True if 'enum' in parameter and not '$ref' in parameter : SynthesizeEnumType ( domain , command [ 'name' ] , parameter ) parameters_type = { 'id' : ToTitleCase ( SanitizeLiteral ( command [ 'name' ] ) ) + 'Params' , 'type' : 'object' , 'description' : 'Parameters for the %s command.' % ToTitleCase ( SanitizeLiteral ( command [ 'name' ] ) ) , 'properties' : command [ 'parameters' ] } domain [ 'types' ] . append ( parameters_type ) if 'returns' in command : for parameter in command [ 'returns' ] : if 'enum' in parameter and not '$ref' in parameter : SynthesizeEnumType ( domain , command [ 'name' ] , parameter ) result_type = { 'id' : ToTitleCase ( SanitizeLiteral ( command [ 'name' ] ) ) + 'Result' , 'type' : 'object' , 'description' : 'Result for the %s command.' % ToTitleCase ( SanitizeLiteral ( command [ 'name' ] ) ) , 'properties' : command [ 'returns' ] } domain [ 'types' ] . append ( result_type ) command [ 'parameters_required' ] = parameters_required
Generate types for command parameters, return values and enum
properties.
Generate types for command parameters return values and enum properties .
"""Generate types for command parameters, return values and enum
     properties.
  """
json_api