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
Feature Request: SDF Enum Type #2
Comments
actually I am against that. |
How can you create gaps to have specified ranges? |
The whole issue is that one should not do these things. if this is something that an org needs, then they should capture that in a mapping file. the only thing interesting in the example above are |
The problem I would like to solve with SDF enums requires a good semantic anchor (URI) for each defined element of an enum, with a description and other potential extension points, including numeric code mappings. For number code mapping we propose an external mapping file that adds additional qualities to an element in the SDF file, but there may also be extension points added in the SDF file itself. Elements may also contain value constraints but the better practice is probably to use a mapping file. Default with override is another design option. I propose a pattern of identifier definition similar to the one we already use for sdfAction, sdfProperty, sdfEvent, etc.
The URI fragment identifier looks like:
and a mapping file entry would look like:
Of course, the extension point might be in the SDF file with some specific constraints, but some generality is lost this way:
|
the current JSON schema mechanism is: "sdfProperty" hence a URI to a value can be #/sdfProperty/myname/value1 not sure if we need to have extensive descriptions for each enum value. the context of the enum values itself should be clear from the description of the property (e.g. the description of "myname") |
I am very much against mixing and matching integers, numbers and strings in a single enumeration, e.g. a enumeration can be only of a single type. |
Being able to attach a detailed description is a must so the JSON schema enum is not sufficient here. Label could be omitted if it's identical to the identifier (but that doesn't always work due to special characters). The on-the-wire value is up to the ecosystem but I think it would be highly useful to provide Integer values for each enum to assist automating the mapping. Otherwise every ecosystem that has integer-like mapping would need to define that individually. Ecosystems that don't have use for the integer can simply ignore that. |
I have assumed that issues we discovered in assigning ID numbers within OneDM extended to every definition point, including enum elements. I think the elevator version is: ecosystems that use ID numbers have their schemes that we can't pre-define compatibility with all of them, and ecosystems that don't use ID numbers prefer to not be required to generate them. Hence mapping files, and the reason I included a mapping file example above in my comments. |
For the objects and resources the IDs are not likely to be identical across ecosystems so there the "oneDM IDs" would be less useful, but for enums I think the case is quite different. Because the scope is smaller and there aren't many sensible numbering schemes, there's a good chance all ecosystems with numeric enums would use the same number. And ecosystems would not need to generate any of the IDs, those can be auto-assigned. Perhaps, if the enum construct is an array, that's all we need since the array index would provide that number in a consistent way. |
Enum items have the mapping issue; they have already assigned numeric codes to enum items in various SDOs. |
I just refactored a number of enums and it seems easy to convert to/from regular JSON schema enums:
If we want to add default ID numbers to enums we could
We can always override the default in a mapping file:
|
Here is what I will propose later today:
and
I'm not sure why we need a "default" -- we can set values at the information model level and map to different values at the mapping level. |
The point here is that there is no difference between enum and anyOf -- both should have labels (that can replace the enum text strings) plus any description, semantic tag, value ranges, etc. as needed. |
Yes, the multiple choice pattern works for both use cases. |
frankly, I do not like both solutions. enum "blah" : "value1, value2" sdEnum "blah:value1" : { "my additional quality1": "x", } |
Here is where the asdf mailing list email discussion on this topic is currently, proposing to use "sdfAny" as a way to create semantically stable JSON pointers to enum items that map 1-1 to the JSON-schema.org simple enum items. If we can agree on this pattern, I believe we could meet everyone's needs :
|
User-defined enumerated data type is a beneficial feature. SDF should provide the ability for a user to define a mapping between a supported fundamental data type (integer, string, etc) and an associated value.
For example, Operational Mode for my object:
0 => "Off"
1 => "On"
2 => "Power-Save"
3 => "Suspended"
4 => "Automatic"
The text was updated successfully, but these errors were encountered: