CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
136 stars 74 forks source link

config false deviation not working when leaf did not mention config true explicitly #1087

Closed gunhanoral closed 1 year ago

gunhanoral commented 1 year ago

This is the same problem with this issue. It's solved with this commit.

Expected Behavior

Current Behavior

Fails with error: the "config" property does not exist in node "example::someleaf"

If I change deviate replace on example-dev.yang:13 to deviate add then it fails with error:

the "config" property already exists in node "example::someleaf"

Steps to Reproduce

docker run --rm -it --name ydkgentest -v $PWD/schemas:/root/ydk-gen/schemas -w /root/ydk-gen/ ydksolutions/ydk-gen:0.8.6.4 python generate.py --adhoc-bundle-name test --adhoc-bundle schemas/custom/example.yang schemas/custom/example-dev.yang

Your Script

❯ cat schemas/custom/example.yang
module example {
   yang-version 1.1;
   namespace "http://example.com/main";

   prefix ex;

   container top {
     leaf someleaf {
       type string;
     }
   }
}

❯ cat schemas/custom/example-dev.yang
module example-dev {
   yang-version 1.1;
   namespace "http://example.com/dev";

   prefix exdev;

   import example {
     prefix ex;
   }

   deviation "/ex:top/ex:someleaf" {
    deviate replace {
        config false;
    }
   }

   container top {
     leaf someleaf {
       type string;
     }
   }
}

Logs

Enable logging and post the logs below

/root/ydk-gen/gen-api/.cache/models/test@0.1.0/example-dev.yang:13: the "config" property does not exist in node "example::someleaf"

Error(s) occurred in YdkGenerator()!

Error occured: "/root/ydk-gen/gen-api/.cache/models/test@0.1.0/example-dev.yang:13: the "config" property does not exist in node "example::someleaf"
".
The models supplied to the YDK generator are invalid. Please make sure the models are valid by compiling the models together using pyang. Please run "pyang *.yang" in the models directory, make sure there are no errors and then try running the generator again. If there are model errors, please fix the errors by editing the model, contacting the model owner or deleting the model from the list of models to generate the YDK bindings for.

System Information

ydksolutions/ydk-gen:0.8.6.4 docker image

ygorelik commented 1 year ago

Not the YDK issue, hence closing.