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
feat: allow for single example #1705
base: next
Are you sure you want to change the base?
Conversation
Co-authored-by: Dominik Moritz <domoritz@gmail.com>
@domoritz tests have been changed, I modified the current test as there is already one for multiple examples under it. I think now it covers both scenarios. Current next branch (without these changes) has tests failing. |
"example": { | ||
"nested": "hello" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this actually better? The old format is more predictable and easier to process since it's consistent.
Can you send a link to json schema spec about this tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, Examples does not pass validation under openapi spec, while example
does.
Here is the spec on examples: https://json-schema.org/draft/2020-12/json-schema-validation.html#name-examples it says nothing about example
There are instances of example being used in open api specs https://swagger.io/specification/ which is not a 1:1 with json schema.
There is a flag: discriminatorType: 'open-api'
in the config that could be used ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, then I would say this is an issue to raise with openapi and swagger. I don't really want to diverge from JSON schema.
I was somewhat reluctant to add the discriminatorType flag and would not like to support too many flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
would not like to support too many flags.
the open api flag seems to be already there
You might close this PR if you wish, I don't think there is anymore to be done here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we add one flag for openapi support and use that for all openapi related features?
resolves #1619
Allows for a single
@example
in comment tags.Previously the parser assumes that there might be multiple such tag in comments and add it to an array of example, transforming the original
@example
intoexample
. If there is only one of such tag, this make it so it returnexample
instead.This is important because
examples
is not valid in openapi for example.