eclipse-thingweb / td-tools

Utility libraries for W3C Thing Descriptions and Thing Models
https://thingweb.io
Other
4 stars 3 forks source link

Unit breaks OpenAPI conversion #36

Open egekorkan opened 1 year ago

egekorkan commented 1 year ago

A TD like below results in an error when trying to convert to Open API due to presence of unit. Removing unit fixes the transformation.

{
    "@context": "https://www.w3.org/2022/wot/td/v1.1",
    "title": "Coffee Machine",
    "securityDefinitions": {
        "nosec_sc": {
            "scheme": "nosec"
        }
    },
    "security": [
        "nosec_sc"
    ],
    "properties": {
        "resources": {
            "readOnly": true,
            "observable": true,
            "type": "object",
            "properties": {
                "water": {
                    "type": "integer",
                    "minimum": 10,
                    "maximum": 100,
                    "unit": "%"
                }
            },
            "forms": [
                {
                    "href": "http://192.168.1.112:8081/coffee-machine/properties/resources",
                    "contentType": "application/json",
                    "op": [
                        "readproperty"
                    ],
                    "htv:methodName": "GET"
                }
            ],
            "writeOnly": false
        }
    },
    "id": "urn:uuid:e8319e4c-ee5c-4a8b-a8f5-b2f255789431",
    "description": "A simple coffee machine that can be interacted over the Internet",
    "support": "https://github.com/eclipse-thingweb/node-wot/"
}
bw-hro commented 2 weeks ago

Same is true for action input specification when input type is object. When input type is a primitive like integer unit property is working. Also cf. listing below:

"fade":{
    "input": {
        "type":"object",
        "properties":{
            "brightness":{
                "type": "integer",
                "minimum": 0,
                "maximum": 100,
                "unit": "percent"
            },
            "duration":{
                "type": "integer",
                "unit": "milliseconds"
            }
        }
    },
    "forms": [{
        "href": "http://lamp.example.com/fade",
        "op": "invokeaction",
        "contentType": "application/json"
    }],
    "safe": false,
    "idempotent": false
}

Does this issue already have a priority and is there a chance that it will be fixed in not so far future?

danielpeintner commented 2 weeks ago

Minor (and just partly related to this issue): @egekorkan given that we have several tools in this repo it makes sense to create a dedicated label for each. Doing so we can more easily filter issues and PRs. Is this fine by you and others?

image

egekorkan commented 1 week ago

given that we have several tools in this repo it makes sense to create a dedicated label for each

I agree! I am going to create it :)