Skip to content

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

@lyme65536

Description

@lyme65536

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"
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions