Uh oh!
There was an error while loading. Please reload this page.
Add support for 'x-enum-values' extension as used by Bungie - #1486
Add support for 'x-enum-values' extension as used by Bungie#1486AlwinGarside wants to merge 4 commits into
Conversation
We have introduced In my opinion this extension make more sense, because the weather:
type: objectproperties:
type:
type: integerformat: int32enum:
- 1
- 2
- 3x-enum-varnames:
- Sunny
- Cloudy
- Rainy |
AlwinGarside
commented
Dec 17, 2018
@jmini Both are extensions that solve the same problem. Unfortunately Bungie will probably never implement the |
AlwinGarside
commented
Dec 17, 2018
@wing328 Could you also take a look-see? |
jmini
commented
Dec 18, 2018
Can you post here a small example how the YAML or JSON looks like, so that I can test it? |
AlwinGarside
commented
Dec 18, 2018
@jmini This is from the Bungie OpenAPI spec: "x-enum-values": [
{
"numericValue": "1",
"identifier": "ReadBasicUserProfile",
"description": "Read basic user profile information such as the user's handle, avatar icon, etc."
},
{
"numericValue": "2",
"identifier": "ReadGroups",
"description": "Read Group/Clan Forums, Wall, and Members for groups and clans that the user has joined."
},
{
"numericValue": "4",
"identifier": "WriteGroups",
"description": "Write Group/Clan Forums, Wall, and Members for groups and clans that the user has joined."
},
{
"numericValue": "8",
"identifier": "AdminGroups",
"description": "Administer Group/Clan Forums, Wall, and Members for groups and clans that the user is a founder or an administrator."
},
{
"numericValue": "16",
"identifier": "BnetWrite",
"description": "Create new groups, clans, and forum posts."
},
{
"numericValue": "32",
"identifier": "MoveEquipDestinyItems",
"description": "Move or equip Destiny items"
},
{
"numericValue": "64",
"identifier": "ReadDestinyInventoryAndVault",
"description": "Read Destiny 1 Inventory and Vault contents. For Destiny 2, this scope is needed to read anything regarded as private. This is the only scope a Destiny 2 app needs for read operations against Destiny 2 data such as inventory, vault, currency, vendors, milestones, progression, etc."
},
{
"numericValue": "128",
"identifier": "ReadUserData",
"description": "Read user data such as who they are web notifications, clan/group memberships, recent activity, muted users."
},
{
"numericValue": "256",
"identifier": "EditUserData",
"description": "Edit user data such as preferred language, status, motto, avatar selection and theme."
},
{
"numericValue": "512",
"identifier": "ReadDestinyVendorsAndAdvisors",
"description": "Access vendor and advisor data specific to a user. OBSOLETE. This scope is only used on the Destiny 1 API."
},
{
"numericValue": "1024",
"identifier": "ReadAndApplyTokens",
"description": "Read offer history and claim and apply tokens for the user."
},
{
"numericValue": "2048",
"identifier": "AdvancedWriteActions",
"description": "Can perform actions that will result in a prompt to the user via the Destiny app."
}
]
}}https://raw.githubusercontent.com/Bungie-net/api/master/openapi.json |
jmini
commented
Dec 18, 2018
@Yogarine thank you a lot, I will try to have a look. As discussed earlier: using the regular I agree with your comment that we can also support this |
jmini
commented
Dec 19, 2018
What I do not get: Is the idea that both |
AlwinGarside
commented
Dec 22, 2018
@jmini You would always need to declare The This is how @vthornheart-bng explains it in the Bungie.net API README:
|
jmini
commented
Dec 24, 2018
I think there is some consent around the fact that "Weather":{
"type":"object",
"properties":{
"type":{
"type":"integer",
"format":"int32",
"enum":[
1,
2,
3
],
"x-enum-values":[
{
"numericValue":"1",
"identifier":"Sunny",
"description":"Blue sky"
},
{
"numericValue":"2",
"identifier":"Cloudy",
"description":"Slightly overcast"
},
{
"numericValue":"3",
"identifier":"Rainy",
"description":"Take an umbrella with you"
}
]
}
}
}When we have solved #1693 we will also have support for descriptions: "Weather" : {
"type" : "object",
"properties" : {
"type" : {
"type" : "integer",
"format" : "int32",
"enum" : [ 1, 2, 3 ],
"x-enum-descriptions" : [ "Blue sky", "Slightly overcast", "Take an umbrella with you" ],
"x-enum-varnames" : [ "Sunny", "Cloudy", "Rainy" ]
}
}
}With the advantage that you do not not have to redeclare that enum values twice (in the Of course as you have suggested earlier, we can decide to support both approaches. My opinion is that supporting both constructs is OK with following additions for this PR:
What do you think? |
AlwinGarside
commented
Dec 24, 2018
Sounds like a good plan. |
jimschubert
commented
Dec 26, 2018
I think this should throw an error on spec validation by default. We allow for skipping validation, in which case I think a warning should be logged. But, we have no way to know whether the user considers the x-enum-values or the enum array as the source of truth. Most likely, an imbalance between the two is a programming or spec authoring error. |
FearlessHyena
commented
May 21, 2019
Would really like to have this too. Any plans when this will get released? |
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,3.4.x,4.0.x. Default:master.Description of the PR
This PR adds support for the 'x-enum-values' extensions as proposed by the Bungie.net API spec. See: https://github.com/Bungie-net/api#extension-properties-on-openapi-specs...