Skip to content
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

Prefer variable key from examples when possible #614

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kylef
Copy link
Member

@kylef kylef commented Feb 26, 2021

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 kylef added the openapi2 label Feb 26, 2021
@kylef kylef requested a review from opichals March 1, 2021 07:28
expect(variable).to.be.instanceof(MemberElement);
expect(variable.attributes.getValue('variable')).to.be.true;
expect(variable.value).to.be.instanceof(StringElement);
expect(variable.value.toValue()).to.be.undefined;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to see if we could "move" the example value here too, but it does get tricky quick due to the complexities when the schema for the additional properties could contain various constraints (fixed, fixedType, be a container, etc) which change what the "value" means.

I'll perhaps follow up with that when I get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant