Scroll to navigation

YANGLINT(1) General Commands Manual YANGLINT(1)

NAME

yanglint - YANG lint tool

SYNOPSIS

yanglint
yanglint [OPTIONS] [-f { yang | yin | tree } ] FILE ...
yanglint [OPTIONS] [-f { xml | json } ] SCHEMA... FILE...

DESCRIPTION

yanglint is a command-line tool for validating and converting YANG schemas and the YANG modeled data. For a simple use, it validates the provided file and if the output format specified, it converts input data into the output format. If started with no argument, yanglint opens interactive environment where the user is allowed to work with schemas and data in a more complex way.

OPTIONS

Show this help message and exit.
Show version number and exit.
Increase libyang verbosity and show verbose messages. If specified a second time, show even debug messages.
Decrease libyang verbosity and hide warnings. If specified a second time, hide errors so no libyang messages are printed.
Convert input into FORMAT. Supported formats: yang, yin, tree, info and feature-param for schemas, xml, json, and lyb for data.
Load the data in one of the following formats: xml, json, lyb. If input format not specified, it is detected from the file extension.
Search path for schema (YANG/YIN) modules. The option can be used multiple times. The current working directory and the path of the module being added is used implicitly. Subdirectories are also searched.
Do not implicitly search in current working directory for schema modules. If specified a second time, do not even search in the module directory (all modules must be explicitly specified).
Specific module features to support in the form <module-name>:(<feature>,)* Use <feature> '*' to enable all features of a module. This option can be specified multiple times, to enable features in multiple modules. If this option is not specified, all the features in all the implemented modules are enabled.
Make the imported modules referenced from any loaded module also implemented. If specified a second time, all the modules are set implemented.
Print only the specified subtree of the schema. The PATH is the XPath subset mentioned in documentation as the Path format. The option can be combined with --single-node option to print information only about the specified node.
Supplement to the --schema-node option to print information only about a single node specified as PATH argument.
Print the specific submodule instead of the main module.
File containing the specific data required by an extension. Required by the schema-mount extension, for example, when the operational data are expected in the file. File format is guessed.
Do not require strict data parsing (silently skip unknown data), has no effect for schemas.
Validate only with the schema modules whose data actually exist in the provided input data files. Takes effect only with the 'data' or 'config' TYPEs. Used to avoid requiring mandatory nodes from modules which data are not present in the provided input data files.
Specify data tree type in the input data FILEs. The TYPE is one of the following:
data - Complete (operational) datastore with state data (default).
config - Configuration datastore (without state data).
get - Result of the NETCONF <get> operation.
getconfig - Result of the NETCONF <get-config> operation.
edit - Content of the NETCONF <edit-config> operation.
rpc - Content of the NETCONF <rpc> message, defined as YANG's rpc input statement.
nc-rpc - Similar to 'rpc' but expect and check also the NETCONF envelopes <rpc> or <action>.
reply - Reply to the RPC/Action. Note that the reply data are expected inside a container
representing the original RPC/Action. This is necessary to identify appropriate
data definitions in the schema module.
nc-reply - Similar to 'reply' but expect and check also the NETCONF envelope <rpc-reply> with
output data nodes as direct descendants. The original RPC/action invocation is expected"
in a separate parameter '-R' and is parsed as 'nc-rpc'.
notif - Notification instance (content of the <notification> element without <eventTime>).
nc-notif - Similar to 'notif' but expect and check also the NETCONF envelope <notification> with
element <eventTime> and its sibling as the actual notification.
ext - Validates extension data based on loaded YANG modules. Need to be used with -k parameter.
Print data with default values, according to the MODE (to print attributes, ietf-netconf-with-defaults model must be loaded):
all - Add missing default nodes.
all-tagged - Add missing default nodes and mark all the default nodes with the attribute.
trim - Remove all nodes with a default value.
implicit-tagged - Add missing nodes and mark them with an attribute.
Evaluate XPATH expression over the data and print the nodes satisfying the expression. The output format is specific and the option cannot be combined with the -f and -d options. Also all the data inputs are merged into a single data tree where the expression is evaluated, so the -m option is always set implicitly.
Print info about the loaded schemas. (i - imported module, I - implemented module) In case the '-f' option with data encoding is specified, the list is printed as 'ietf-yang-library' data.
The limit of the maximum line length on which the 'tree' format will try to be printed.
Write the output to OUTFILE instead of stdout.
Provide optional data to extend validation of the '(nc-)rpc', '(nc-)reply' or '(nc-)notif' TYPEs. The FILE is supposed to contain the operational datastore referenced from the operation. In case of a nested notification or action, its parent existence is also checked in these operational data.
Provide source RPC for parsing of the 'nc-reply' TYPE. The FILE is supposed to contain the source 'nc-rpc' operation of the reply.
Merge input data files into a single tree and validate at once. The option has effect only for 'data' and 'config' TYPEs.
Load and implement internal 'ietf-yang-library' YANG module. Note that this module includes definitions of mandatory state data that can result in unexpected data validation errors.
Parse FILE with 'ietf-yang-library' data and use them to create an exact YANG schema context. If specified, the '-F' parameter (enabled features) is ignored.
Allow usage of deref() XPath function within leafref
Allow usage of JSON empty values ('null') within input data
Name of extension instance in format: <module-name>:<extension-name>:<argument>. Need to be used with -t ext parameter.
Enable printing of specific debugging message group (nothing will be printed unless verbosity is set to debug): <group>[,<group>]* (dict, xpath, dep-sets)

FORMATS

There are two types of formats to use.

In case of schemas, the content can be converted into the 'yang', 'yin' and 'tree' formats. As input, only YANG and YIN files are accepted. Note, that the corresponding file extension is required.
In case of YANG modeled data, the content can be converted between 'xml' and 'json' formats. Remember that the corresponding file extension of the input file is required.

EXAMPLES

Open interactive environment:
yanglint
Convert YANG model into YIN and print it to the stdout:
yanglint --format=yin ./ietf-system.yang
Convert ietf-system configuration data from XML to JSON:
yanglint --format=json --type=config --output=data.json ./ietf-system.yang ./data.xml

SEE ALSO

https://github.com/CESNET/libyang (libyang homepage and Git repository)

AUTHORS

Radek Krejci <rkrejci@cesnet.cz>, Michal Vasko <mvasko@cesnet.cz>

COPYRIGHT

Copyright © 2015 - 2025 CESNET, a.l.e.

2025-8-19 libyang