Include allowed string values in generated services.

This commit is contained in:
John Beisley
2023-03-09 18:23:18 +00:00
parent 1270e56d5f
commit e5bb4e5154
7 changed files with 251 additions and 72 deletions

View File

@ -140,6 +140,8 @@ func (arg *Argument) RelatedStateVariable() (*StateVariable, error) {
type StateVariable struct {
Name string
DataType string
AllowedValues []string
}
func stateVariableFromXML(xmlSV *xmlsrvdesc.StateVariable) (*StateVariable, error) {
@ -150,8 +152,13 @@ func stateVariableFromXML(xmlSV *xmlsrvdesc.StateVariable) (*StateVariable, erro
return nil, fmt.Errorf("%w: unsupported data type %q",
ErrUnsupportedDescription, xmlSV.DataType.Type)
}
if xmlSV.DataType.Name != "string" && len(xmlSV.AllowedValues) > 0 {
return nil, fmt.Errorf("%w: allowedValueList is currently unsupported for type %q",
ErrUnsupportedDescription, xmlSV.DataType.Name)
}
return &StateVariable{
Name: xmlSV.Name,
DataType: xmlSV.DataType.Name,
Name: xmlSV.Name,
DataType: xmlSV.DataType.Name,
AllowedValues: xmlSV.AllowedValues,
}, nil
}