api-elements.js icon indicating copy to clipboard operation
api-elements.js copied to clipboard

Prefer variable key from examples when possible

Open kylef opened this issue 4 years ago • 0 comments
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',
},

kylef avatar Feb 26 '21 22:02 kylef