api-elements.js
api-elements.js copied to clipboard
Prefer variable key from examples when possible
trafficstars
We can extract the key to use for variable member derived from Schema Object additionalProperties from an example, providing the key is not already used for a property (with different schema) or has different require-ness constraints.
The change makes it so that the example in the following OpenAPI 2 Schema Object is not discarded when it matches the appropriate type, it is instead in the parse result:
type: 'object',
additionalProperties: {
type: 'string',
},
example: {
'application/json': 'https://tools.ietf.org/html/rfc7159',
},