Extensible YANG validator
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
c_src
ebin
include
modules
plugins
priv
src
test
.gitignore
LICENSE
Makefile
README.md
env.sh
vsn.mk

README.md

yanger

Extensible YANG validator.

Prerequisites

erlang libxml2-dev

Installation of Yanger on OS X Example

Tested on OS X 10.13.5 (High Sierra)

  1. Install brew package manager (if not present)

  2. Install erlang and coreutils using brew

brew install erlang coreutils

  1. (optional) install lux to verify test cases
##deps
brew update
brew upgrade
brew install erlang coreutils

##make local env
mkdir ~/local
cd ~/local
git clone https://github.com/hawk/lux.git

##export path
export PATH=$PATH:~/local/lux/bin
(put the above in .bash_profile or .profile)

##rebuild to use brew erlang
cd ~/local/lux
./bin/lux --make

##test
./bin/lux examples/intro.lux
  1. git clone yanger and build it, and source the env bash
git clone https://github.com/mbj4668/yanger.git
cd yanger
source env.sh
make

Sample Usage

To create a Swagger JSON file from a yang file, you must first have a yang file, for example, create the following test_leaf.yang file in your current working directory:

module test_leaf {
  namespace "http://example.com/ns/example/test_leaf";
  prefix ns;

container test_vars{
    leaf single_value
    {
      type string;
    }
   }
}

Next you must tell yanger which format to output the yang into, in this example, it is the swagger JSON format, giving the new file output name test_leaf_now_swagger.json:

yanger -t expand -f swagger test_leaf.yang -o test_leaf_now_swagger.json

You will now have a JSON file created from the yang file:

$ more test_leaf_now_swagger.json
{
  "swagger": "2.0",
  "info": {
    "title": "test_leaf",
    "description": "",
    "version": "2018-10-15"
  },
  "basePath": "/restconf",
  "tags": [
    {
      "name": "root",
.....

You can for example take the Swagger file to the Swaggerhub and auto create an SDK from it in a python flask format or other languages. The Swaggerhub requires free registration.

For running tests

lux (https://github.com/hawk/lux)

Contributing

Code style

Do not introduce trailing whitespace.

Do not introduce lines longer than 80 characters.

Do not use tabs for indentation.

Hint for emacs users:

(setq whitespace-style (quote (face trailing tabs lines)))

and use whitespace-mode.