apiaryio / api-elements.js

Library for consuming API Elements in JavaScript
https://apielements.org/
MIT License
76 stars 18 forks source link

Prefer variable key from examples when possible #614

Open kylef opened 3 years ago

kylef commented 3 years ago

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',
},