Skip to content
Lyle Bertz edited this page Jan 28, 2018 · 5 revisions

pyang-json-altschema-plugin wiki

This wiki will cover various notes, TODOs, etc.

The goal of the tool is to provide bi-directional mapping between YANG and Swagger. This is as much research as it is implementation.

Features

A specific mapping from YANG to JSON Schema that

  1. Places groupings under "#/definitions/groupings/definitions"
  2. Place type definitions under "#/definitions/type-definitions/definitions"
  3. Provides statistics in the debug log to understand reference frequency (un-mapped structures)

JSON Schema puts meta-info in a 'definitions' child of a namespace. Thus, if you have namespace A and sub-namesapce B you will put definitions in B under #/definitions/A/definitions/B/definitions. We have not tried #/A/B/definitions, i.e. flattening the namespace a bit (it is part of the TODO / Research).

When dealing with groupings the children of the group are copied over, i.e. the grouping is treated as a namespace. When copied, the children's names are retained, i.e. x in the grouping A is always 'x' when A is used in another structure.

Type definitions are given the namespace type-definitions. When they are used keep in mind the label of the attributed using the type definition will be different.

By separating grouping and type-definition namespaces we get the clear intent of when one can rename the child and one cannot. For example,

"a" : { "$ref" : "#/definitions/type-definitions/definitions/foo" } - legal! It's a typedef

"foo" : { "$ref" : "#/definitions/type-definitions/definitions/foo" } - legal (but not wise)! It's a typedef

"a" : { "$ref" : "#/definitions/groupings/definitions/foo/bar" } - illegal! bar is an attribute of the foo grouping

"bar" : { "$ref" : "#/definitions/groupings/definitions/foo/bar" } - legal!

TODO (Not in order of priority)

  1. Upgrade software according to the Mappings Page.

Clone this wiki locally