Closed guillett closed 7 years ago
Same problem for allegement_fillon_mode_recouvrement
Thanks for this suggestion @guillett! However, it is not very clear to me what you're suggesting, since this issue is opened in legislation-explorer
but mentions the API. What is the most important for you: machine access of enum members through the API (and in this case, on which endpoint?), or listing these members in the legislation explorer? 🙂
For me it is listing these members in the legislation explorer
@MattiSG, the most important for me is the machine access via the API. That is why I created an new issue in openfisca-web-api
.
Having said that once it is available via the API, I would love to see it in the legislation explorer. 🙂
enum
type and its usage: “Elle ne peut prendre qu'une valeur chiffrée parmi la liste ci-dessous.”To implement this, we'll need to expose the values of the enum elements in the API.
{
"defaultValue": 0,
"description": "Activité",
"id": "activite",
"valueType": "Enum",
"possibleValues": {
"Actif occupé": 0,
"Autre inactif": 4,
"ChĂ´meur": 1,
"Étudiant, élève": 2,
"Retraité": 3
}
}
{
"defaultValue": 0,
"description": "Activité",
"id": "activite",
"valueType": "Enum",
"possibleValues": {
"0": "Actif occupé",
"1": "ChĂ´meur",
"2": "Étudiant, élève",
"3": "Retraité",
"4": "Autre inactif"
}
}
Suggestion A: possibleValues
Suggestion B: values
Suggestion C: elements
@guillett @benjello @MattiSG @Anna-Livia @sandcha @Morendil thoughts ?
EDIT: I forgot @michelbl
Suggestion D: members
?
2 - D
members
is already used in another context in OpenFisca (the members of an entity).
Plus, is it clear what the members of a variable are ?
Or, following swagger style:
{
"defaultValue": "Actif occupé",
"description": "Activité",
"id": "activite",
"valueType": "String",
"enum": [
"Actif occupé",
"Autre inactif",
"ChĂ´meur",
"Étudiant, élève",
"Retraité"
]
}
But that notation totally omits the indexes. We can make sure the API accepts strings as inputs for enums (instead of ints) but inside OpenFisca, enums values are integers 🤔 .
For instance, this code doesn't work as expected:
person('activite', period) == u'ChĂ´meur' # False, as person('activite', period) is an integer
Note for suggestion 3: It can contain null
for enum like statut_marital
that start at 1
suggestion 3 for the structure, "possibleValues" for the key :)
3 - B
I favor the array representation over the other ones because it communicates an intention of doing the simplest thing, labeling enum values like array indexes - starting at 0, in order and without skipping any values.
2-B
Some variables are EnumCol (cf. rsa_non_calculable in legislation explorer and rsa_non_calculable code).
As a user/consumer:
Currently, I would use those details to validate a structure in a client application - MesAides that add metadata to openfisca variables.