EagleUmlCommon icon indicating copy to clipboard operation
EagleUmlCommon copied to clipboard

Swagger plugin fails if a augment has more than 3 hierarchy in the path

Open PrathibaJee opened this issue 8 months ago • 0 comments

If a yang module has augment statement with more than 3 hierarchy in the path , then yang2swagger produces the following issue ,

(env) [xxxxxx@xxxxxxxx YangJsonTools]$ pyang --plugindir $PYBINDPLUGIN -f swagger -p input/ -o export/onf.json input/equipment-augment-1-0.yang
Traceback (most recent call last):
  File "/home/stdapp/YANG2SWAGGER/onmi-iisomi-uml-common/YangJsonTools/env/bin/pyang", line 8, in <module>
    sys.exit(run())
  File "/home/stdapp/YANG2SWAGGER/onmi-iisomi-uml-common/YangJsonTools/env/lib/python3.6/site-packages/pyang/scripts/pyang_tool.py", line 548, in run
    emit_obj.emit(ctx, modules, fd)
  File "/home/stdapp/YANG2SWAGGER/onmi-iisomi-uml-common/YangJsonTools/swagger.py", line 103, in emit
    emit_swagger_spec(ctx, modules, fd, ctx.opts.path)
  File "/home/stdapp/YANG2SWAGGER/onmi-iisomi-uml-common/YangJsonTools/swagger.py", line 180, in emit_swagger_spec
    genAugmentedStatements(ctx, augments, definitions, model['paths'])
  File "/home/stdapp/YANG2SWAGGER/onmi-iisomi-uml-common/YangJsonTools/swagger.py", line 205, in genAugmentedStatements
    for api in apis:
RuntimeError: OrderedDict mutated during iteration

Details :

The equipment-augment-1-0.yang which I m trying to translate has 4 augment statements. The below augment statement in the YANG is causing this problem which has 5 hierarchy in its path ,

augment "/core-model:control-construct/core-model:equipment/core-model:actual-equipment/core-model:manufactured-thing/core-model:equipment-type" {
    description
      "none";
    uses equipment-type-spec;
  }

After removing this augment statement , I could able to generate swagger2.0 yaml file.

Note : The mentioned path in the yang is valid(validated with pyang and able to generate pyang tree)

Please let us know whether this is an issue in the YANG2Swagger tool. If so , kindly please let us know is it possible to fix. Many thanks.

PrathibaJee avatar Jun 24 '24 18:06 PrathibaJee