{"id":22598503,"url":"https://github.com/commitconfirmed/jsnac","last_synced_at":"2026-02-02T18:01:58.092Z","repository":{"id":262060934,"uuid":"860717719","full_name":"commitconfirmed/jsnac","owner":"commitconfirmed","description":"Network Automation focused JSON Schema Creator","archived":false,"fork":false,"pushed_at":"2025-11-09T05:16:34.000Z","size":291,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-09T07:09:03.384Z","etag":null,"topics":["json","json-schema","json-schema-generator","network-automation","yaml"],"latest_commit_sha":null,"homepage":"https://jsnac.readthedocs.io/","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/commitconfirmed.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-21T02:12:45.000Z","updated_at":"2025-09-03T03:08:39.000Z","dependencies_parsed_at":"2025-04-11T01:33:16.772Z","dependency_job_id":"33d6a3c4-cc46-464d-a394-45f7429b5434","html_url":"https://github.com/commitconfirmed/jsnac","commit_stats":null,"previous_names":["commitconfirmed/jsnac"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/commitconfirmed/jsnac","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitconfirmed%2Fjsnac","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitconfirmed%2Fjsnac/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitconfirmed%2Fjsnac/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitconfirmed%2Fjsnac/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commitconfirmed","download_url":"https://codeload.github.com/commitconfirmed/jsnac/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commitconfirmed%2Fjsnac/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29016663,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T16:17:30.374Z","status":"ssl_error","status_checked_at":"2026-02-02T15:58:50.469Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json","json-schema","json-schema-generator","network-automation","yaml"],"created_at":"2024-12-08T11:05:47.214Z","updated_at":"2026-02-02T18:01:58.077Z","avatar_url":"https://github.com/commitconfirmed.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://github.com/commitconfirmed/jsnac/workflows/JSNAC%20TOX%20Suite/badge.svg)\n[![Documentation Status](https://readthedocs.org/projects/jsnac/badge/?version=latest)](https://jsnac.readthedocs.io/en/latest/?badge=latest) \n\n\n# JSNAC\nJSON Schema (for) Network Automation Creator \n\n- [Overview](#overview)\n- [Installation](#installation)\n- [Brief Example](#brief-example)\n- [YAML Validation](#yaml-validation)\n- [Detailed Example](#detailed-example)\n- [Usage](#usage)\n\n## Overview\n\nThe majority of Network and Infrastructure automation is done in YAML. Be it Ansible Host Variables, Network Device data to build a Jinja2 configuration with, or just a collection of data you want to run a script against to put into another product you have likely written a YAML file and have had to debug a typo or had to help another colleague build a new file for a new device.\n\nIn an ideal world you can (and should) put a lot of this data into a database or Network Source of Truth solution and pull from it so the validation is done for you. However, these solutions don't cover every use case so you will likely end up creating some YAML files here and there.\n\nUsing a JSON schema for validating \u0026 documenting your YAML is a good practice in a CI/CD world but is very cumbersome to create from scratch.\n\nThis project aims to simplify this whole process by helping you build a JSON schema using YAML syntax that has network and infrastructure templates (or sub-schemas) in mind.\n\nNow you can hopefully catch those rare mistakes before you run that Playbook, create that configuration with a Jinja2 template or run a REST query to that Source of Truth or Telemetry solution :)\n\n## Installation\n\nJSNAC can be installed using pip: ``pip install jsnac`` and can be used as either a command line tool or as a Python library in your own python project (See [Usage](#usage)).\n\n## Brief Example\n\nTake a basic Ansible host_vars YAML file for a host below:\n\n```yaml\nchassis:\n  hostname: \"ceos-spine1\"\n  model: \"ceos\"\n  device_type: \"router\"\n\nsystem:\n  domain_name: \"example.com\"\n  ntp_servers: [ \"10.0.0.1\", \"10.0.0.2\" ]\n    \ninterfaces:\n  - if: \"Loopback0\"\n    desc: \"Underlay Loopback\"\n    ipv4: \"10.0.0.101/32\"\n    ipv6: \"2001:2:a1::1/128\"\n  - if: \"Ethernet0\"\n    desc: \"Management Interface\"\n    ipv4: \"10.1.0.20/24\"\n```\n\nYou can simply write out how you would like to document \u0026 validate this data in a YAML file, and this program will generate a JSON schema you can use. \n\n```yaml\nheader:\n  title: \"Ansible host vars\"\n\nschema:\n  chassis:\n    title: \"Chassis\"\n    properties:\n      hostname:\n        js_kind: { name: \"string\" }\n      model:\n        js_kind: { name: \"string\" }\n      device_type:\n        js_kind: { name: \"choice\", choices: [ \"router\", \"switch\", \"firewall\", \"load-balancer\" ] }\n  system:\n    properties:\n      domain_name:\n        js_kind: { name: \"string\" }\n      ntp_servers:\n        items:\n          js_kind: { name: \"ipv4\" } \n  interfaces:\n    items:\n      properties:\n        if:\n          js_kind: { name: \"string\" }\n        desc:\n          js_kind: { name: \"string\" }\n        ipv4:\n          js_kind: { name: \"ipv4_cidr\" }\n        ipv6:\n          js_kind: { name: \"ipv6_cidr\" }\n```\n\n```bash\n(.venv) user@server:~/jsnac$ jsnac -f data/example-jsnac.yml \n[INFO] - jsnac - Starting JSNAC CLI\n[INFO] - jsnac - Schema built in 0.0006 seconds\n[INFO] - jsnac - Schema written to: jsnac.schema.json\n[INFO] - jsnac - JSNAC CLI complete\n```\n\n## YAML Validation\n\nTo be able to validate the orginal YAML file or any new YAML file you create using this schema you first need to reference your JSON schema using the yaml-language-server comment at the top of your YAML file\n\n```yaml\n# yaml-language-server: $schema=jsnac.schema.json\n---\nchassis:\n  hostname: \"hostname\"\n```\n\nWhich language server you use is specific to your environment and editor that you use. For Visual Studio Code I recommend that you use the [Red Hat YAML Language Server](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) extension. Once installed you will now see that you will have automatic code completion, syntax highlighting, schema validation etc. while editing your YAML file.\n\n\n## Detailed Example\n\nWe also have full support for writing your own titles, descriptions, js_kinds (sub-schemas), objects that are required, etc. A more fleshed out example of the same schema is below:\n\n```yaml\nheader:\n  id: \"example-schema.json\"\n  title: \"Ansible host vars\"\n  description: |\n    Ansible host vars for my networking device. Requires the below objects:\n    - chassis\n    - system\n    - interfaces\n\njs_kinds:\n  hostname:\n    title: \"Hostname\"\n    description: \"Hostname of the device\"\n    type: \"pattern\"\n    regex: \"^[a-zA-Z0-9-]{1,63}$\"\n\nschema:\n  chassis:\n    title: \"Chassis\"\n    description: | \n      Object containing Chassis information. Has the below properties: \n      hostname [required]: hostname\n      model [required]: string\n      device_type [required]: choice (router, switch, firewall, load-balancer)\n    properties:\n      hostname:\n        js_kind: { name: \"hostname\" }\n      model:\n        js_kind: { name: \"string\" }\n      device_type:\n        title: \"Device Type\"\n        description: |\n          Device Type options are:\n          router, switch, firewall, load-balancer\n        js_kind: { name: \"choice\", choices: [ \"router\", \"switch\", \"firewall\", \"load-balancer\" ] }\n    required: [ \"hostname\", \"model\", \"device_type\" ]\n  system:\n    title: \"System\"\n    description: |\n      Object containing System information. Has the below properties:\n      domain_name [required]: string\n      ntp_servers [required]: list of ipv4 addresses\n    properties:\n      domain_name:\n        js_kind: { name: \"string\" }\n      ntp_servers:\n        title: \"NTP Servers\"\n        description: \"List of NTP servers\"\n        items:\n          js_kind: { name: \"ipv4\" } \n    required: [ \"domain_name\", \"ntp_servers\" ]\n  interfaces:\n    title: \"Device Interfaces\"\n    description: |\n      List of device interfaces. Each interface has the below properties:\n      if [required]: string\n      desc: string\n      ipv4: ipv4_cidr\n      ipv6: ipv6_cidr\n    items:\n      properties:\n        if:\n          js_kind: { name: \"string\" }\n        desc:\n          js_kind: { name: \"string\" }\n        ipv4:\n          js_kind: { name: \"ipv4_cidr\" }\n        ipv6:\n          js_kind: { name: \"ipv6_cidr\" }\n      required: [ \"if\" ]\n```\n\nA full list of js_kinds are available in the [documentation](https://jsnac.readthedocs.io/en/latest/)\n\n## Usage\n\n### CLI\n\n```bash\n# Print the help message\njsnac -h\n\n# Build a JSON schema from a YAML file (default file is jsnac.schema.json)\njsnac -f data/example-jsnac.yml\n\n# Build a JSON schema from a YAML file and save it to a custom file\njsnac -f data/example-jsnac.yml -o my.schema.json\n\n# Increase the verbosity of the output (this generates alot of messages as I use it for debugging)\njsnac -f data/example-jsnac.yml -v\n```\n\n### Library\n```python\n\"\"\"\nThis example demonstrates how to use the jsnac library to build a JSON schema \nfrom a YAML file in a Python script. An example YAML file is available below:\n\u003chttps://www.github.com/commitconfirmed/jsnac/blob/main/data/example-jsnac.yml\u003e\n\"\"\"\nfrom jsnac.core.build import SchemaBuilder\n\ndef main():\n    # Create a SchemaInferer object\n    jsnac = SchemaBuilder()\n\n    # Load the YAML data however you like into the SchemaInferer object\n    with open('data/example-jsnac.yml', 'r') as file:\n        data = file.read()\n    jsnac.add_yaml(data)\n\n    # Loading from JSON directly is also supported if needed\n    # jsnac.add_json(json_data)\n\n    # Build the JSON schema\n    schema = jsnac.build_schema()\n    print(schema)\n\nif __name__ == '__main__':\n    main()\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommitconfirmed%2Fjsnac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommitconfirmed%2Fjsnac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommitconfirmed%2Fjsnac/lists"}