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

"prefixItems" and "items" in 2020-12 dialect #362

Open
lyme65536 opened this issue Nov 7, 2024 · 0 comments
Open

"prefixItems" and "items" in 2020-12 dialect #362

lyme65536 opened this issue Nov 7, 2024 · 0 comments

Comments

@lyme65536
Copy link

In 2020-12 dialect JSchema.ToString(SchemaVersion.Draft2020_12) generate prefixItems keyword instead of items when generating an array. Even if JSchema.ItemsPositionValidation=false. What should be done to generate items when I want to validate array of arbitrary length? According to json-schema docs, prefixItems keyword is used to validate arrays by applying a schema to each corresponding index of the array.

Example of C# type and resulting schema below:

public class TestType
{
    public List<string> SomeObjects { get; set; }
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "SomeObjects": {
      "type": "array",
      "prefixItems": {
        "type": "string"
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant