corenova / yang-express Goto Github PK
View Code? Open in Web Editor NEWYANG model-driven Express framework
License: Apache License 2.0
YANG model-driven Express framework
License: Apache License 2.0
Understand that this is still under development. I am reporting this for tracking -
Running the yang-express/example petstore, I get the following error -
bash-4.3$ curl localhost:5000/openapi.spec
{
"error": {
"message": "Cannot read property 'nodes' of undefined"
}
}bash-4.3$
Server Log -
TypeError: Cannot read property 'nodes' of undefined
at Function.restjson.paths (.../yang-express/lib/restjson.js:138:18)
at .../yang-express/lib/openapi.js:57:27
I am using following versions of dependencies :
"yang-express": "^0.3.9",
"yang-js": "^0.15.16",
The latest changes to yang-js project may have broken it.
Hi There,
I was trying to integrate a yang-parser in an Angular (v9) application, for which I resorted to using yang-express
. After installing I ran below command:
yang-express src/app/yangs/demo.yang
It yields below output, the issue it's pointing to is in the yang-express
file inside the bin folder.
WARNING: No configurations found in configuration directory:/home/yang-demo/config
WARNING: To disable this warning set SUPPRESS_NO_CONFIG_WARNING in the environment.
/usr/local/lib/node_modules/yang-express/bin/yang-express:37
var schema = require('..').bind({
^
TypeError: require(...).bind is not a function
at Object.<anonymous> (/usr/local/lib/node_modules/yang-express/bin/yang-express:37:28)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
I am running node version 10.19.0 and npm 6.14.4.
Please provide your thoughts.
if you run " git clone https://github.com/corenova/yang-express;" then run "cd yang-express" then run "npm install"
and finally you run "yang-express example/example-petstore.yang" or "npm run example:petstore"
you get this error message:
[email protected] example:petstore /home/bay/workspace/tmp/yang-express
NODE_ENV=example NODE_APP_INSTANCE=petstore bin/yang-express --router restjson example-petstore
TypeError: discover is not a function
at Method.rpc(listen) (/home/bay/workspace/tmp/yang-express/yang-web-store.js:36:13)
at Method.do (/home/bay/workspace/tmp/yang-express/node_modules/yang-js/lib/method.js:42:64)
at Object. (/home/bay/workspace/tmp/yang-express/bin/yang-express:45:27)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
bash-4.3$ curl localhost:5000/petstore.yang
{
"error": {
"message": "Cannot read property 'length' of undefined"
}
}
TypeError: Cannot read property 'length' of undefined
at ......./yang-express/lib/yangapi.js:16:32
Notice the strange behavior on nested list structure...
bash-4.3$ cat example/petstore.yang
module petstore {
prefix ps;
description "Yang Petstore";
grouping Pet {
leaf id { type uint64; mandatory true; }
leaf name { type string; mandatory true; }
leaf tag { type string; }
}
list pet {
key "id";
uses Pet;
list childpet {
key "id";
uses Pet;
list grandchildpet {
key "id";
uses Pet;
}
}
}
}
bash-4.3$
bash-4.3$ cat example/petstore.json
{
"petstore:pet": [
{
"id": "1",
"name": "happy",
"tag": "friendly"
},
{
"id": "2",
"name": "boba",
"tag": "hyper"
}
]
}
bash-4.3$
bash-4.3$ curl -i -X POST localhost:5000/pet/1/childpet -H 'content-type: application/json' -d '{ "id": 2, "name": "childpet-1", "tag": "test" }'
HTTP/1.1 400 Bad Request
X-Powered-By: Express
Date: Wed, 17 Aug 2016 21:27:09 GMT
Connection: keep-alive
Content-Length: 0
bash-4.3$ cat example/petstore.json
{
"petstore:pet": [
{
"id": "1",
"name": "happy",
"tag": "friendly",
"childpet": [
{
"id": 1,
"name": "childpet-1"
}
]
}
]
}
bash-4.3$ curl -i -X POST localhost:5000/pet/1/childpet -H 'content-type: application/json' -d '{ "id": 2, "name": "childpet-2", "tag": "test" }'
HTTP/1.1 400 Bad Request
X-Powered-By: Express
Date: Wed, 17 Aug 2016 21:30:32 GMT
Connection: keep-alive
Content-Length: 0
bash-4.3$
bash-4.3$ cat example/petstore.json
{
"petstore:pet": [
{
"id": "1",
"name": "happy",
"tag": "friendly",
"childpet": [
{
"id": 1,
"name": "childpet-1"
},
{
"id": 2,
"name": "childpet-2"
}
]
}
]
}
bash-4.3$
bash-4.3$curl -i -X POST localhost:5000/pet/1/childpet -H 'content-type: application/json' -d '{ "id": 3, "name": "childpet-3", "tag": "test" }'
HTTP/1.1 201 Created
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 98
ETag: W/"62-mejvL9nQf9lcsyqhkXHBMw"
Date: Wed, 17 Aug 2016 21:31:52 GMT
Connection: keep-alive
{
"childpet": [
{
"id": 3,
"name": "childpet-3",
"tag": "test"
}
]
}bash-4.3$
bash-4.3$ curl -i -X POST localhost:5000/pet -H 'content-type: application/json' -d '{ "id": 2, "name": "pet-2", "tag": "test" }'
HTTP/1.1 201 Created
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 97
ETag: W/"61-9M3Baw4B9J+SWeUkwC8qpw"
Date: Wed, 17 Aug 2016 21:35:51 GMT
Connection: keep-alive
{
"petstore:pet": [
{
"id": 2,
"name": "pet-2",
"tag": "test"
}
]
}
bash-4.3$ curl -i -X POST localhost:5000/pet/2/childpet -H 'content-type: application/json' -d '{ "id": 1, "name": "childpet-1", "tag": "test" }'
HTTP/1.1 400 Bad Request
X-Powered-By: Express
Date: Wed, 17 Aug 2016 21:35:24 GMT
Connection: keep-alive
Content-Length: 0
bash-4.3$
Any documentation providing how to use the hot deployment of YANG modules in a running instance will be helpful. Documentation in general can be helpful here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.