fix: change keywords priority for inferring example and try infer example from root in combined schemas #126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR fixes bugs described in #124 issue. I copied the description of bugs from mentioned issue:
const
should take precedence over other keywords. At the moment package infer examples in order:default
->const
->enum
->examples[0]
-> generate example using format, but I think thatconst
should take precedence over other keywords and we should change also whole order, so we should end with priority:const
- valid schema should have always value defined inconst
examples[0]
- if we don't have definedconst
thenexamples[0]
should have next priorityenum[0]
default
- it's a default value for valid schema, butconst
,examples[0]
andenum[0]
should have highter priorities -examples
andenum
in first index can have different value than is defined indefault
examples
,default
,const
withoneOf
like in schema above, package should infer examples from root schema, not from firstoneOf
item -> problem with this line. This problem should be also handled for other combined keywords likeallOf
.Changes:
const
,examples
,default
,enum
keywords