{"id":8684426,"url":"https://github.com/ueg1990/faker-schema","last_synced_at":"2025-08-21T08:31:40.597Z","repository":{"id":49260304,"uuid":"96709412","full_name":"ueg1990/faker-schema","owner":"ueg1990","description":"Generate fake data using joke2k's faker and your own schema","archived":false,"fork":false,"pushed_at":"2021-06-21T14:19:36.000Z","size":18,"stargazers_count":94,"open_issues_count":7,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-12-07T22:10:55.335Z","etag":null,"topics":["faker","python","schema"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ueg1990.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-09T20:26:09.000Z","updated_at":"2024-06-18T09:15:47.000Z","dependencies_parsed_at":"2022-09-02T15:31:23.358Z","dependency_job_id":null,"html_url":"https://github.com/ueg1990/faker-schema","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueg1990%2Ffaker-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueg1990%2Ffaker-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueg1990%2Ffaker-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ueg1990%2Ffaker-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ueg1990","download_url":"https://codeload.github.com/ueg1990/faker-schema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230501172,"owners_count":18236061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["faker","python","schema"],"created_at":"2024-04-27T23:56:42.094Z","updated_at":"2024-12-19T21:10:33.418Z","avatar_url":"https://github.com/ueg1990.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"faker-schema\n============\n\nGenerate fake data using `joke2k's\nfaker \u003chttps://github.com/joke2k/faker\u003e`__ and your own schema.\n\nInstallation\n------------\n\n.. code:: bash\n\n    pip install faker-schema\n\nUsage\n-----\n\nGetting started\n^^^^^^^^^^^^^^^\n\n.. code:: python\n\n\n    from faker_schema.faker_schema import FakerSchema\n\n    schema = {'employee_id': 'uuid4', 'employee_name': 'name', 'employee address': 'address',\n              'email_address': 'email'}\n    faker = FakerSchema()\n    data = faker.generate_fake(schema)\n    print(data)\n    # {'employee_id': '956f0cf3-a954-5bff-0aaf-ee0e1b7e1e1b', 'employee_name': 'Adam Wells',\n    #  'employee address': '189 Kyle Springs Suite 110\\nNorth Robin, OR 73512',\n    #  'email_address': 'jmcgee@gmail.com'}\n\n\nThis library is dependent on `faker \u003chttps://github.com/joke2k/faker\u003e`__\nfor available schema types. Faker provides a wide variety of data types\nvia providers. For a list of available providers, checkout\n`Providers \u003chttp://faker.readthedocs.io/en/master/providers.html\u003e`__ and\n`Community\nProviders \u003chttp://faker.readthedocs.io/en/master/communityproviders.html\u003e`__\n\nOnce you know what types you want to generate your fake data, you can\nstart defining your own schema\n\nDefining your schema\n^^^^^^^^^^^^^^^^^^^^\n\nThe expected schema is a dictionary, where the keys are field names and\nthe values are the types of the fields. The schema dictionay can have\nnested dictionaries and lists too.\n\nLoading schemas\n^^^^^^^^^^^^^^^\n\nfaker-schema currently provides two ways of loading your schema:\n\n-  JSON file\n-  JSON string\n\n.. code:: python\n\n    import json\n\n    from faker_schema.faker_schema import FakerSchema\n    from faker_schema.schema_loader import load_json_from_file, load_json_from_string\n\n    schema = load_json_from_file('path_to_json_file')\n    faker = FakerSchema()\n    data = faker.generate_fake(schema)\n\n    # OR\n\n    json_string = '{\"employee_id\"\": \"uuid4\", \"employee_name\": \"name\"\", \"employee address\":\n                    \"address\", \"email_address\": \"email\"}'\n\n    schema = load_json_from_string(json_string)\n    faker = FakerSchema()\n    data = faker.generate_fake(schema)\n\nYou can define your own way of loading a schema, convert it to a Python\ndictionary and pass it to the FakerSchema instance. The aim was to\nde-couple schema loading/generation from fake data generation. If you\nwant to contribute more schema loading techniques, please open a GitHub\nissue or send a pull request.\n\nUsing different locales\n^^^^^^^^^^^^^^^^^^^^^^^\n\nThe `Faker \u003chttps://github.com/joke2k/faker\u003e`__ library provides a list\nof different `locales \u003chttps://github.com/joke2k/faker#localization\u003e`__.\nYou can choose your required locale from that list and provide it to the\nFakerSchema instance\n\n.. code:: python\n\n    from faker_schema.faker_schema import FakerSchema\n\n    schema = {'employee_id': 'uuid4', 'employee_name': 'name', 'employee address': 'address',\n              'email_address': 'email'}\n    faker = FakerSchema(locale='it_IT')\n    data = faker.generate_fake(schema)\n    print(data)\n    # {'employee_id': '47f8bb04-fc05-25c9-73cc-e8a22f29ee4e', 'employee_name': 'Caio Negri',\n    #  'employee address': 'Stretto Davis 34\\nDamico lido, 54802 Vibo Valentia (TR)',\n    #  'email_address': 'nunzia19@libero.it'}\n\nMore Schema Examples\n^^^^^^^^^^^^^^^^^^^^\n\nNested Dictionary\n^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n    from faker_schema.faker_schema import FakerSchema\n\n    schema = {'EmployeeInfo': {'ID': 'uuid4', 'Name': 'name', 'Contact': {'Email': 'email',\n              'Phone Number': 'phone_number'}, 'Location': {'Country Code': 'country_code',\n              'City': 'city', 'Country': 'country', 'Postal Code': 'postalcode',\n              'Address': 'street_address'}}}\n    faker = FakerSchema()\n    data = faker.generate_fake(schema)\n    # {'EmployeeInfo': {'ID': '0751f889-0d83-d05f-4eeb-16f575c6b4a3', 'Name': 'Stacey Williams',\n    #  'Contact': {'Email':'jpatterson@yahoo.com', 'Phone Number': '1-077-859-6393'},\n    #  'Location': {'Country Code': 'IE', 'City': 'Dyermouth', 'Country':\n    #  'United States Minor Outlying Islands', 'Postal Code': '84239',\n    #  'Address': '94806 Joseph Plaza Apt. 783'}}}\n\nNested List\n^^^^^^^^^^^\n\n.. code:: python\n\n    from faker_schema.faker_schema import FakerSchema\n\n    schema = {'Employer': 'name', 'EmployeList': [{'Name': 'name'}, {'Name': 'name'},\n              {'Name': 'name'}]}\n    faker = FakerSchema()\n    data = faker.generate_fake(schema)\n    # {'Employer': 'Faith Knapp', 'EmployeList': [{'Name': 'Douglas Bailey'},\n    # {'Name': 'Karen Rivera'}, {'Name': 'Linda Vance MD'}]}\n\nGenerating a certain number of fake data from given schema\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code:: python\n\n\n    from faker_schema.faker_schema import FakerSchema\n\n    schema = {'employee_id': 'uuid4', 'employee_name': 'name', 'employee address': 'address',\n              'email_address': 'email'}\n    faker = FakerSchema()\n    data = faker.generate_fake(schema, iterations=4)\n    print(data)\n    # [{'employee_id': 'e07a7964-9636-bca6-2a58-4a69ac126dc5', 'employee_name':\n    # 'Charlene Blankenship', 'employee address': '0431 Edward Mountains Suite 697\\nPort Douglas,\n    # TX 96239-7277', 'email_address': 'ashley86@yahoo.com'}, {'employee_id':\n    # '42b02262-3e0c-cf40-8257-4a0af122dddb', 'employee_name': 'Cheryl Stevens',\n    # 'employee address': '48066 Eric Lake\\nPhillipshire, MO 57224', 'email_address':\n    # 'lisa05@nash.info'}, {'employee_id': '41efbcc4-bb32-9260-b2b3-8fac29782e01',\n    # 'employee_name': 'Dennis Campbell', 'employee address':\n    # '52418 Diana Mills Suite 590\\nEast Mackenzie, HI 16222', 'email_address':\n    # 'jennifer39@gmail.com'}, {'employee_id': '80bf12ff-2f3a-6db6-f3a6-14cb50076a46',\n    # 'employee_name': 'Jimmy Avery', 'employee address':\n    # '6867 Eddie Forest Apt. 735\\nBranditon, IL 32717', 'email_address': 'ashley64@griffin.com'}]\n\nBYOP (Bring Your Own Provider)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nIf you are using a community provider or you created your own provider,\nyou can use those with faker-schema as well. I will use the provider,\n`faker\\_web \u003chttps://github.com/thiagofigueiro/faker_web\u003e`__ as an\nexample.\n\nAfter `installing \u003chttps://github.com/thiagofigueiro/faker_web#usage\u003e`__\nfaker\\_web,\n\n.. code:: python\n\n    from faker import Faker\n    from faker_schema import FakerSchema\n    from faker_web import WebProvider\n\n    fake = Faker()\n    fake.add_provider(WebProvider)\n\n    faker = FakerSchema(faker=fake)\n    headers_schema = {'Content-Type': 'content_type', 'Server': 'server_token'}\n    fake_headers = faker.generate_fake(headers_schema)\n    print(fake_headers)\n    # {'Content-Type': 'application/json', 'Server': 'Apache/2.0.51 (Ubuntu)'} \n\nDevelopment\n-----------\n\nRunning tests\n^^^^^^^^^^^^^\n\n-  Using make\n\n.. code:: bash\n\n    make test\n\n-  Using nose\n\n.. code:: bash\n\n    nosetests \n\n-  Using nose with coverage\n\n.. code:: bash\n\n    nosetests --with-coverage --cover-package=faker_schema --cover-erase -v --cover-html\n\nRunning flake8\n^^^^^^^^^^^^^^\n\n-  Using make\n\n.. code:: bash\n\n    make flake8\n\n-  Using flake8\n\n.. code:: bash\n\n    flake8 --max-line-length 99 faker_schema/ tests/\n\nAuthor\n------\n\nUsman Ehtesham Gul (`ueg1990 \u003chttps://github.com/ueg1990\u003e`__) -\nuehtesham90@gmail.com\n\nContribute\n----------\n\nIf you want to add any new features, or improve existing one or if you\nfind bugs, please open a GitHub issue or feel free to send a pull\nrequest. If you have any questions or need help/mentoring with\ncontributions, feel free to contact me via email\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fueg1990%2Ffaker-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fueg1990%2Ffaker-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fueg1990%2Ffaker-schema/lists"}