<commit_before>import 'package:discovery_api_client_generator/generator.dart';
import 'package:discovery_api_client_generator/src'
       '/generated_googleapis/discovery/v1.dart';
import 'package:unittest/unittest.dart';

withParsedDB(json, function) {
  var namer = new ApiLibraryNamer();
  var imports = new DartApiImports.fromNamer(namer);

  var description = new RestDescription.fromJson(json);
  var db = parseSchemas(imports, description);

  namer.nameAllIdentifiers();

  return function(db);
}

withParsedApiResource(db, json, function) {
  var namer = new ApiLibraryNamer();
  var imports = new DartApiImports.fromNamer(namer);

  var description = new RestDescription.fromJson(json);
  var apiClass = parseResources(imports, db, description);

  namer.nameAllIdentifiers();

  return function(apiClass);
}

main() {
  var schema = {
    'schemas' : {
      'Task' : {
        'type' : 'object',
        'properties' : {
          'name' : { 'type': 'string' },
          'isMale' : { 'type': 'boolean' },
          'age' : { 'type': 'integer' },
          'any' : { 'type': 'any' },
          'labels' : {
            'type': 'array',
            'items' : {
              'type' : 'integer',
            },
          },
          'properties' : {
            'type': 'object',
            'additionalProperties' : {
              'type' : 'string',
            },
          },
        },
      },
    }
  };

  withParsedDB(schema, (DartSchemaTypeDB db) {
    Map buildApi(String i, {Map methods, Map resources}) {
      var api = {
          'name' : 'apiname$i',
          'version' : 'apiversion$i',
          'rootUrl' : 'https://www.googleapis.com/',
          'servicePath' : 'mapsengine/v1/',
      };
      if (methods != null) {
        api['methods'] = methods;
      }
      if (resources != null) {
        api['resources'] = resources;
      }
      return api;
    }

    checkApi(String i, DartApiClass apiClass) {
      expect(apiClass, isNotNull);
      expect(apiClass.className.name, equals('Apiname${i}Api'));
      expect(apiClass.rootUrl, equals('https://www.googleapis.com/'));
      expect(apiClass.basePath, equals('mapsengine/v1/'));
    }

    Map buildMethods(String i) {
      var map = {
         'foo$i' : {
           'path' : 'foo$i/{id$i}',
           'httpMethod' : 'GET',
           'parameters' : {
             'id$i' : {
               'type' : 'string',
               'required' : true,
               'location' : 'path',
             },
             'reapetedPathParam$i' : {
               'type' : 'string',
               'required' : true,
               'repeated' : true,
               'location' : 'path',
             },
             'reapetedQueryParam$i' : {
              'type' : 'string',
              'required' : true,<commit_msg>Fix bug in test after changing basePath to servicePath<commit_after>import 'package:discovery_api_client_generator/generator.dart';
import 'package:discovery_api_client_generator/src'
       '/generated_googleapis/discovery/v1.dart';
import 'package:unittest/unittest.dart';

withParsedDB(json, function) {
  var namer = new ApiLibraryNamer();
  var imports = new DartApiImports.fromNamer(namer);

  var description = new RestDescription.fromJson(json);
  var db = parseSchemas(imports, description);

  namer.nameAllIdentifiers();

  return function(db);
}

withParsedApiResource(db, json, function) {
  var namer = new ApiLibraryNamer();
  var imports = new DartApiImports.fromNamer(namer);

  var description = new RestDescription.fromJson(json);
  var apiClass = parseResources(imports, db, description);

  namer.nameAllIdentifiers();

  return function(apiClass);
}

main() {
  var schema = {
    'schemas' : {
      'Task' : {
        'type' : 'object',
        'properties' : {
          'name' : { 'type': 'string' },
          'isMale' : { 'type': 'boolean' },
          'age' : { 'type': 'integer' },
          'any' : { 'type': 'any' },
          'labels' : {
            'type': 'array',
            'items' : {
              'type' : 'integer',
            },
          },
          'properties' : {
            'type': 'object',
            'additionalProperties' : {
              'type' : 'string',
            },
          },
        },
      },
    }
  };

  withParsedDB(schema, (DartSchemaTypeDB db) {
    Map buildApi(String i, {Map methods, Map resources}) {
      var api = {
          'name' : 'apiname$i',
          'version' : 'apiversion$i',
          'rootUrl' : 'https://www.googleapis.com/',
          'servicePath' : 'mapsengine/v1/',
      };
      if (methods != null) {
        api['methods'] = methods;
      }
      if (resources != null) {
        api['resources'] = resources;
      }
      return api;
    }

    checkApi(String i, DartApiClass apiClass) {
      expect(apiClass, isNotNull);
      expect(apiClass.className.name, equals('Apiname${i}Api'));
      expect(apiClass.rootUrl, equals('https://www.googleapis.com/'));
      expect(apiClass.servicePath, equals('mapsengine/v1/'));
    }

    Map buildMethods(String i) {
      var map = {
         'foo$i' : {
           'path' : 'foo$i/{id$i}',
           'httpMethod' : 'GET',
           'parameters' : {
             'id$i' : {
               'type' : 'string',
               'required' : true,
               'location' : 'path',
             },
             'reapetedPathParam$i' : {
               'type' : 'string',
               'required' : true,
               'repeated' : true,
               'location' : 'path',
             },
             'reapetedQueryParam$i' : {
              'type' : 'string',
              'required' : true,
{'fraction_non_alphanumeric': 0.15286624203821655, 'fraction_numerical': 0.0010615711252653928, 'mean_word_length': 1.9581371009942439, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2343778', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1724, 'n_words': 325}