-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Add support for 'x-enum-values' extension as used by Bungie #1486
base: master
Are you sure you want to change the base?
Conversation
We have introduced In my opinion this extension make more sense, because the weather:
type: object
properties:
type:
type: integer
format: int32
enum:
- 1
- 2
- 3
x-enum-varnames:
- Sunny
- Cloudy
- Rainy |
@jmini Both are extensions that solve the same problem. Unfortunately Bungie will probably never implement the |
@wing328 Could you also take a look-see? |
Can you post here a small example how the YAML or JSON looks like, so that I can test it? |
@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 |
@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 |
What I do not get: Is the idea that both |
@jmini You would always need to declare The This is how @vthornheart-bng explains it in the Bungie.net API README:
|
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? |
Sounds like a good plan. |
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. |
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.sh
and./bin/security/{LANG}-petstore.sh
if 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...