Skip to content

A Set should generate attribute "uniqueItems": true #25

@sdelamo

Description

@sdelamo

I think for:

package example.micronaut;

import io.micronaut.jsonschema.JsonSchema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.Size;
import java.util.Set;

/**
 *
 * @param tags Tags for the product
 */
@JsonSchema(description = "A product from Acme's catalog")
public record Product(@Size(min = 1) Set<String> tags) {
}

It generates:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "http://localhost:8080/schemas/product.schema.json",
  "title": "Product",
  "description": "A product from Acme's catalog",
  "type": [
    "object"
  ],
  "properties": {
    "tags": {
      "description": "Tags for the product",
      "type": [
        "array"
      ],
      "items": {
        "type": [
          "string"
        ]
      },
      "minItems": 1
    }
  }
}

tags should add the attribute "uniqueItems": true:

 "tags": {
      "description": "Tags for the product",
      "type": "array",
      "items": {
        "type": "string"
      },
      "minItems": 1,
      "uniqueItems": true
    }

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions