Azure / iot-plugandplay-models-tools

Tools to manage the device-models repo
MIT License
13 stars 17 forks source link

dmr-client tools to validate DTDL V3 Models #196

Closed chandra-rayaprol closed 1 year ago

chandra-rayaprol commented 1 year ago

I recently attempted to validate DTDL V3 models and received the following error:

"Model contains unrecognized @context specifier 'dtmi:dtdl:extension:quantitativeTypes;1'. Remove all @context specifiers other than those beginning with 'dtmi:dtdl:context;' or 'dtmi:iotcentral:context;' ".

I'm not sure whether I'm overlooking any options for model validation. Please advise. commad: dmr-client validate --directory ./dtdlv3 --repo ./dtdlv3

rido-min commented 1 year ago

The option is --max-dtdl-version as described in https://github.com/Azure/iot-plugandplay-models-tools/tree/dev/clients/dotnet/Microsoft.IoT.ModelsRepository.CommandLine#dmr-client-validate , uses 2 by default.

chandra-rayaprol commented 1 year ago

The files paths and the content are valid, but unfortunately the following commands fail .

dmr-client validate --model-file "/dtmi/aaeon/boxer_rk88-1.json" --max-dtdl-version 2 Errors: File does not exist: /dtmi/aaeon/boxer_rk88-1.json Unrecognized command or argument '--max-dtdl-version' Unrecognized command or argument '2' Valid fullpath: https://devicemodels.azure.com/dtmi/aaeon/boxer_rk88-1.json

// custom repo dmr-client validate --model-file "/dtmi/com/raysapps/androidapp/androidapp-1.json" --repo "https://raysapps.github.io/Dtdl" --max-dtdl-version 2 Errors: File does not exist: /dtmi/com/raysapps/androidapp/androidapp-1.json. Unrecognized command or argument '--max-dtdl-version' Unrecognized command or argument '2' vaild fullpath: https://raysapps.github.io/Dtdl/dtmi/com/raysapps/androidapp/androidapp-1.json.

Could you please help me?

rido-min commented 1 year ago

The purpose of the validate command is to verify a local file is valid, when you specify the --repo option, it's used to resolve external model dependencies, and this can be local or remote.

What's your use case to validate a file from a remote repo? (that is supposed to be already valid)

chandra-rayaprol commented 1 year ago

Thank you for clarifying. Unfortunately, I am unable to validate V3 models locally or use the --repo option. I've also noticed that the option —max-dtdl-version 3 isn't working. Please review the error information in the screenshots. https://github.com/Raysapps/DtdlV3/blob/main/localValidate.png https://github.com/Raysapps/DtdlV3/blob/main/repoValidate.png Could you please advise?

rido-min commented 1 year ago

what error do you see when using --max-dtdl-version ? image

chandra-rayaprol commented 1 year ago

I'm not sure why the command fails on my machine. The same command fails with the error :

C:\AzureDevOps\raysappsprojects\GitHub\raysapps\DtdlV3> dmr-client validate -m ".\dtmi\com\raysapps\clouddeviceapp\clouddeviceapp-1.json" --max-dtdl-version 3 '3' was not matched. Did you mean one of the following? -m -r -h Unrecognized command or argument '--max-dtdl-version' Unrecognized command or argument '3'

https://github.com/Raysapps/DtdlV3/blob/main/repoValidateV3command.png

rido-min commented 1 year ago

which version are you using? --max-dtdl-version was added in beta8

you might need to re-install

chandra-rayaprol commented 1 year ago

The problem was resolved by updating the dmr-client. Thank you very much.