-
-
Notifications
You must be signed in to change notification settings - Fork 442
[WIP][REST] Extend the file format conversion APIs to support DSL items #4630
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
Conversation
This PR is not yet ready for review because not yet finished. I consider it finished at around 75%. |
18df1df
to
41f606c
Compare
f4e1437
to
70b9979
Compare
It seems you decided to use the following naming schema:
I think this is very good and I like it very much. However for |
/file-format/items is IMHO obvious that we are talking about file format for items. /file-format/items-file is redundant IMHO.. But if an official reviewer thinks your suggestion is better than mine, I will then change. |
But
|
I don't want to steer this discussion too much and I would be fine with any conclusion on this, but here is another alternative that could be considered:
As the 'what' is already in the MIME type (e.g. |
For parse the input is always a string and the output schema could be set according to the MIME type (thank you @mherwege for showing that that's possible). That would also be fine with me. |
For output, as type is Response, there to s no problem to return any DTO object inside the Response. |
@mherwege : the day we have a YAML file format, media type will be application/yaml. This is not sufficient for the parse API to know if it should return a ItemXXXDTO or ThingXXXDTO.. Not sufficient to specify what kind of information you are requesting. |
Or you imagine to rather define text/vnd.openhab.yaml.item and text/vnd.openhab.yaml.thing ? |
I think it's important to differentiate between the existing ui yaml files and a possible new yaml format. |
There is no plan to create 2 different YAML formats. |
No, this never was my intention. Please re-read the pointed issue you apparently missed the general intention. My intention is to show DSL and new YAML file formats in Main UI code tab. Management of YAML would be moved from Main UI to core. Main UI would just call API to create/parse YAML. |
The UI YAML will disappear in my solution and be replaced by any file format. |
Then that was a misunderstanding. I thought additionaly to the new yaml file the plan is to provide a parse function for the existing ui yamls so the forum examples will still work. The new yaml format can contain both items and things at the same time. |
Because UI need is to work either on item or thing, depending on the configuration WEB page. One time again, we start discuss YAML in a PR which is not about YAML. Why not having this discussion rather in the issue itself? |
Because the way the format looks has implications and obviously we're not on the same page how the format looks. So please let's have this discussion (not here) otherwise it will be an endless source of confusion |
That was my thinking, but I am fine either way. You could then also have For multiple types of objects content, if you want some analogies in the UI, we currently support working with this on multiple levels in the UI in a few places:
I would not get stuck on the exact format in the UI. That is a later concern. For now, I fully agree with @lolodomo that the first target should be making DSL import work without the parser code in the UI, just by calling a REST endpoint.
I believe you can define multiple possible input MIME types as well in the
|
In you example, the type is the same in both cases, MyData. |
You can achieve that with something like this:
|
For create API, content type will be only JSON and output will accept text/vnd.openhab.dsl.item and text/vnd.openhab.dsl.thing. |
a3d16f8
to
351a1e7
Compare
For the errors, yes you have line and column. See in the current code: |
Yes - that's why I'd put it there, too.
That would require to return a json: {
"file": "FileText",
"warnings": ["SomeWarningDto"]
} I'm not really sure it it's a valid use case. |
We are talking about the other way. |
@lolodomo Is this still WIP as the title suggests? |
Yes, it is still in progress. |
Then maybe also convert it to a "draft" PR, that makes it more explicit. |
Finally I plan to add a unique new API: POST /file-format/convert |
Related to openhab#4585 This PR only supports management of things. It supports DSL and YAML file formats. A first new API (POST /file-format/create) allows to create a file format (DSL or YAML) from a JSON object. A second new API (POST /file-format/parse) allows to parse a file format (DSL or YAML) to a JSON object. These 2 APIs should help Main UI displaying DSL and YAML file formats for things. Signed-off-by: Laurent Garnier <[email protected]>
Signed-off-by: Laurent Garnier <[email protected]>
Is this now superseded by #4779? |
Yes, partially.. This one contains also stuff for DSL items that I will reuse later. |
8b62194
to
36d33e1
Compare
8d897e6
to
c2e499e
Compare
I tried this and noticed that item's yaml generator is not implemented yet. However, item DSL generator works! |
Yes, because PR for YAML items is not yet merged. |
is this what it needs: #4776 ? |
This PR does not require #4776 as it deals only with DSL items. |
c2e499e
to
b4e03c1
Compare
Related to openhab#4585 Signed-off-by: Laurent Garnier <[email protected]>
b4e03c1
to
dd13efd
Compare
I am closing this PR, a new PR #4793 covers its scope. |
Related to #4585