Add JsonSchema array support for unique
See original GitHub issueAccording to task comment https://github.com/kotest/kotest/issues/2961#issuecomment-1128122006 it should be possible to do
jsonSchema {
array(unique=true)) { string() }
}
Issue Analytics
- State:
- Created a year ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Make sure item property in array is unique in Json Schema?
So if you want to ensure uniqueness your only option is to have "name" as property keys instead of property values. Share. Share ......
Read more >array — Understanding JSON Schema 2020-12 documentation
A schema can ensure that each of the items in an array is unique. Simply set the uniqueItems keyword to true . {...
Read more >Key-based item uniqueness · Issue #22 · json-schema-org ...
This vocab adds the uniqueKeys keyword which is an array of JSON Pointers. Each pointer is applied to each item in an array...
Read more >How to make a field unique in JSON schema - Microsoft Q&A
Hello, I am studying JSON schema, and I would like to seek your help on how to make a field unique in JSON...
Read more >Array uniqueItems not able to describe object items with ...
I would like to describe that the objects have some unique (primary) keys (name and surname in this example) based on which the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here you can see usage with matchers:
https://github.com/kotest/kotest/blob/master/kotest-assertions/kotest-assertions-json/src/jvmTest/kotlin/io/kotest/assertions/json/schema/SchemaWithMatcherTest.kt#L34
And validation:
https://github.com/kotest/kotest/blob/master/kotest-assertions/kotest-assertions-json/src/commonMain/kotlin/io/kotest/assertions/json/schema/matchSchema.kt#L137
It’s perhaps not very clean right now, but if we keep using the same pattern it should be easier to refactor later 😄
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.