-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AID] Handling of semantic annotations #54
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find some comments below.
What I would highly recommend is to add some test-cases by either updating some samples or adding new ones.
EDIT: Some CI tests are failing which proves we should add more tests.
Co-authored-by: danielpeintner <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #54 +/- ##
==========================================
+ Coverage 65.23% 65.99% +0.76%
==========================================
Files 1 1
Lines 558 594 +36
Branches 224 231 +7
==========================================
+ Hits 364 392 +28
- Misses 155 162 +7
- Partials 39 40 +1 ☔ View full report in Codecov by Sentry. |
I have fixed the failing test, the assumption based code and adding the new test now |
I think the code looks much better now and I hope we can step-by-step answer some of the TODOs in the source code. |
I was still working on them :D I have added test specifically targeting the semantics conversion. EDIT: I have no idea why the JSON Schema validation fails. So it is commented out now. Maybe @Kaz040 has an idea? |
I will look at it @egekorkan . Can you please send me the TD you are using for testing and the converted AID? |
The validation fails because of "myPrefix1_suffix4" term that was converted. The schema does not accept terms that are not defined in AID specification. The terms that are defines are mostly TD terms and protocol binding terms (HTTP,Modbus, and MQTT). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine. You could also add a test for the outer prefix sample just to be sure
console.log("###\n\n" + JSON.stringify(smObj) + "\n\n###"); | ||
// const isValid = this.validateAID(smObj); | ||
// expect(isValid.valid, isValid.errors).to.equal(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console log and commented code?
}, | ||
base: "http://example.com:3003", | ||
security: ["nosec_sc"], | ||
"myPrefix2:suffix3": "value1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not part of the test?
myProperty1: { | ||
type: "number", | ||
title: "Property Title", | ||
"myPrefix1:suffix4": "myPrefix2:value4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the idea/system/schema behind the attached numbers but it is fine by me
If a TD has a semantic annotation, it is simply ignored in the conversion. This PR adds a basic support in this direction. I am not exactly satisfied since there can be many corner cases. The worst is if there is an additional context without a prefix. That would mean looking into the context for each possible unknown key. I have added a good amount of comments in the code but also adding now some in the PR review.