You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following up on swagger-api/swagger-core#1012 I'd like a service to return an Enum type and then document enum values by providing a separate annotation per value. I expect Swagger to aggregate these annotations so that all values and their descriptions are listed in the resulting documentation.
@fehguy@cowwoc Or there could be a separate enumDescriptions array (keeping backwards compatibility) where the amount of descriptions should match the amount of enums. Perhaps it's not very pretty but it would be a way forward.
I would love to be able to use an object/hash for enums. For example I've got an app with credit card transactions that use rather cryptic values for the CVV checks. Here's what I'm forced to do to document it:
cvv_check:
type: stringtitle: CVV checkdescription: | When processed, result from checking the CVV/CVC value on the transaction. * `D` - Suspicious transaction * `I` - Failed data validation check * `M` - Match * `N` - No Match * `P` - Not Processed * `S` - Should have been present * `U` - Issuer unable to process request * `X` - Card does not support verificationenum:
- D
- I
- M
- N
- P
- S
- U
- XmaxLength: 1
It would be much nicer to just have:
cvv_check:
type: stringtitle: CVV checkdescription: When processed, result from checking the CVV/CVC value on the transaction.enum:
D: Suspicious transactionI: Failed data validation checkM: MatchN: No MatchP: Not ProcessedS: Should have been presentU: Issuer unable to process requestX: Card does not support verificationmaxLength: 1
Clients could either just use the keys and ignore the values, or show both in a <select> HTML element.
Reacted by Tom Howard, Issac Lisbon, Hovsep, Daniele Orler, anthony-capozzi-libertymutual-com, Lucas Santos, Matthew Christopher, Reece Hart, Timur Nurutdinov, Johan Svensson and 151 more
Currently the enum feature allows any kind of JSON thing in it – objects, arrays, strings, numbers, even mixed (though I'm not sure if things other than strings are supported by various toolings).
With the map variant proposed by @drewish we would be limited to strings. (This is not necessarily a problem for most cases, I just wanted to point it out.)
A more flexible version (though more verbose) would be to have an array of value/description pairs:
cvv_check:
type: stringtitle: CVV checkdescription: When processed, result from checking the CVV/CVC value on the transaction.enum:
- value: Ddescription: Suspicious transaction
- value: Idescription: Failed data validation check
- value: M:description: Match
- value: Ndescription: No Match
- value: Pdescription: Not Processed
- value: Sdescription: Should have been present
- value: Udescription: Issuer unable to process request
- value: Xdescription: Card does not support verification
I guess this corresponds to what @cowwoc proposed.
Reacted by Dmitry Patsura, Václav Votípka, Ricardo Freitas, Lucas Santos, Timur Nurutdinov, Reece Hart, Patrick Bateman, Anuj Kumar, Giri G, Peter Tiedemann and 63 more
@lornajane it's definitely a real problem, but should we hold onto this or declare it to be a JSON Schema issue and not one that we will address? We could consider adding another JSON Schema extension keyword to 3.2, but that just starts widening the gap with standard JSON Schema again.
I vote we hold onto this for now, it's not obvious what the best answer is, but I think it would be a good addition to have at some point - for docs tools particularly where the extra context can really help users.
Reacted by Henry Andrews, Ralf Handl and Oscar Pinilla
@ralfhandl I've tagged this and other issues with schema-object so that we can get a general ruling on how much, if any, schema work we want to keep in this project. I've put it on the agenda for this week's TDC call.
Activity
bgrant0607 commentedon Aug 18, 2015
+1. (Yes, github should have a voting button.)
fehguy commentedon Aug 18, 2015
@cowwoc @bgrant0607 how would you propose this is represented in the description? For example, the current enum system uses primitive arrays:
I suppose these could be objects, but we'll have to be prescriptive of the structure.
cowwoc commentedon Aug 18, 2015
Each enum entry could be an object with
nameanddocumentationproperties (or however you want to call it).henkosch commentedon Oct 1, 2015
+1
jontejj commentedon Nov 6, 2015
@fehguy @cowwoc Or there could be a separate enumDescriptions array (keeping backwards compatibility) where the amount of descriptions should match the amount of enums. Perhaps it's not very pretty but it would be a way forward.
drewish commentedon Jan 20, 2016
I would love to be able to use an object/hash for enums. For example I've got an app with credit card transactions that use rather cryptic values for the CVV checks. Here's what I'm forced to do to document it:
It would be much nicer to just have:
Clients could either just use the keys and ignore the values, or show both in a
<select>HTML element.ralfhandl commentedon Feb 3, 2016
+1
webron commentedon Feb 24, 2016
I think there's a similar proposal for this for draft 5 of JSON Schema, will look for it.
webron commentedon Feb 24, 2016
Parent issue: json-schema-org/json-schema-spec#579
cabbonizio commentedon Feb 25, 2016
+1
ePaul commentedon Feb 28, 2016
Currently the enum feature allows any kind of JSON thing in it – objects, arrays, strings, numbers, even mixed (though I'm not sure if things other than strings are supported by various toolings).
With the map variant proposed by @drewish we would be limited to strings. (This is not necessarily a problem for most cases, I just wanted to point it out.)
A more flexible version (though more verbose) would be to have an array of value/description pairs:
I guess this corresponds to what @cowwoc proposed.
webron commentedon Jul 21, 2016
Tackling PR: json-schema-org/json-schema-spec#741
giuliopulina commentedon Oct 12, 2017
I would be interested in this feature: I know it's not supported, are there any plans to introduce this in the future?
14 remaining items
lornajane commentedon Nov 22, 2023
This is a real problem, at Redocly we have this extension
x-enumDescriptionsto try to help the situation, but it's not great since it only supports simple types - sharing it as an example of usage "in the wild" https://redocly.com/docs/api-reference-docs/specification-extensions/x-enum-descriptions/handrews commentedon Jan 26, 2024
@lornajane it's definitely a real problem, but should we hold onto this or declare it to be a JSON Schema issue and not one that we will address? We could consider adding another JSON Schema extension keyword to 3.2, but that just starts widening the gap with standard JSON Schema again.
lornajane commentedon Jan 28, 2024
I vote we hold onto this for now, it's not obvious what the best answer is, but I think it would be a good addition to have at some point - for docs tools particularly where the extra context can really help users.
ralfhandl commentedon Jan 29, 2024
And once we know the answer this is a good place for pointing to it.
handrews commentedon Jan 29, 2024
@ralfhandl I've tagged this and other issues with
schema-objectso that we can get a general ruling on how much, if any, schema work we want to keep in this project. I've put it on the agenda for this week's TDC call.dabaus commentedon Jan 17, 2025
+1
itbencn commentedon May 28, 2025
+1
mnemitz commentedon Jul 25, 2025
+1
Add description table for RT errors (#56)
karenetheridge commentedon Aug 16, 2025
As enums are part of the JSON Schema specification, whenever JSON Schema gets this feature, OpenAPI will pick it up too.