{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Digital Credential Metadata Type Schema",
    "description": "An object defining a Digital Credential Metadata Type",
    "type": "object",
    "required": [
        "name",
        "description",
        "schema_uri",
        "schema_uri#integrity",
        "data_source",
        "display",
        "claims"
    ],
    "properties": {
        "name": {
            "type": "string",
            "description": "Human-readable name for the Verifiable Credential Type",
            "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
        },
        "description": {
            "type": "string",
            "description": "A human-readable description for the Verifiable Credential Type",
            "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
        },
        "extends": {
            "type": "string",
            "description": "A URL pointing to a Metadata document of another Verifiable Credential Type that this type extends",
            "format": "uri"
        },
        "extends#integrity": {
            "type": "string",
            "description": "A String representing an integrity metadata for ensuring the integrity of the resource referred to by the extends"
        },
        "schema_uri": {
            "type": "string",
            "description": "A URL pointing to a JSON Schema document describing the structure of the Verifiable Credential of this Verifiable Credential type",
            "format": "uri"
        },
        "schema_uri#integrity": {
            "type": "string",
            "description": "A String representing an integrity metadata for ensuring the integrity of the resource referred to by the schema_uri"
        },
        "data_source": {
            "type": "object",
            "description": "Object containing information about the data origin for this Verifiable Credential type",
            "required": [
                "verification"
            ],
            "properties": {
                "verification": {
                    "type": "object",
                    "required": [
                        "trust_framework",
                        "authentic_source"
                    ],
                    "properties": {
                        "trust_framework": {
                            "type": "string",
                            "description": "The trust framework used for digital authentication towards Authentic Source system",
                            "enum": [
                                "pdnd",
                                "none"
                            ]
                        },
                        "authentic_source": {
                            "$ref": "#/$defs/authentic_source_properties"
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "display": {
            "description": "Array of objects containing display information for this Verifiable Credential type for each language supported",
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "description": "An object defining display properties for a certain supported language",
                "required": [
                    "name",
                    "lang",
                    "description"
                ],
                "properties": {
                    "lang": {
                        "type": "string",
                        "description": "String value that identifies the language of the Verifiable Credential Type represented as a language tag taken from values defined in RFC 5646 Section 2",
                        "enum": [
                            "it-IT",
                            "en-US"
                        ]
                    },
                    "name": {
                        "type": "string",
                        "description": "String value that identifies the name of the Verifiable Credential Type",
                        "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
                    },
                    "description": {
                        "type": "string",
                        "description": "String value that identifies a description of the Verifiable Credential Type",
                        "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
                    },
                    "rendering": {
                        "type": "object",
                        "description": "An object containing information about rendering methods supported by the Verifiable Credential Type; each Verifiable Credential Type MUST supports at least one of this rendering methods: simple and svg_templates (the simple rendering method is intended for use in applications that do not support SVG rendering; the svg_templates rendering method is intended for use in applications that support SVG rendering)",
                        "properties": {
                            "simple": {
                                "$ref": "#/$defs/no_svg_logo_image_display_properties"
                            },
                            "svg_templates": {
                                "type": "array",
                                "minItems": 1,
                                "items": {
                                    "$ref": "#/$defs/svg_logo_image_display_properties"
                                }
                            }
                        },
                        "anyOf": [
                            {
                                "required": [
                                    "simple"
                                ]
                            },
                            {
                                "required": [
                                    "svg_templates"
                                ]
                            }
                        ],
                        "additionalProperties": false
                    }
                }
            }
        },
        "claims": {
            "description": "Array of objects containing information for displaying and validating Verifiable Credential claims of this Verifiable Credential type",
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "required": [
                    "path",
                    "display"
                ],
                "properties": {
                    "path": {
                        "type": "array",
                        "description": "Array indicating the path of a specific claim within the Verifiable Credential as defined in Appendix C of OpenID4VCI",
                        "minItems": 1,
                        "items": {
                            "type": "string",
                            "pattern": "^[^\\s]+$"
                        }
                    },
                    "display": {
                        "type": "array",
                        "description": "Array containing display information about the claim indicated in the path; the array contains an object for each language supported by the Verifiable Credential Type",
                        "minItems": 1,
                        "items": {
                            "type": "object",
                            "description": "An object defining display information about the claim indicated in the path for a certain supported language",
                            "required": [
                                "label",
                                "lang"
                            ],
                            "properties": {
                                "label": {
                                    "type": "string",
                                    "description": "human-readable label for the claim",
                                    "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
                                },
                                "lang": {
                                    "type": "string",
                                    "description": "String value that identifies the language for the label of the claim as a language tag taken from values defined in RFC 5646 Section 2",
                                    "enum": [
                                        "it-IT",
                                        "en-US"
                                    ]
                                },
                                "description": {
                                    "type": "string",
                                    "description": "human-readable description for the claim",
                                    "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
                                }
                            },
                            "additionalProperties": false
                        }
                    },
                    "sd": {
                        "type": "string",
                        "description": "A string indicating whether the claim is selectively disclosable (if omitted, the default value is allowed)",
                        "enum": [
                            "always",
                            "allowed",
                            "never"
                        ]
                    },
                    "svg_id" : {
                        "type": "string",
                        "description": "A string defining the ID of the claim for reference in the SVG template; the ID MUST be unique within the type metadata; It MUST consist of only alphanumeric characters and underscores and MUST NOT start with a digit",
                        "pattern": "^[a-zA-Z_][\\w]*$"
                    }
                },
                "additionalProperties": false
            }
        }
    },
    "additionalProperties": false,
    "$defs": {
        "authentic_source_properties": {
            "type": "object",
            "description": "Information about an Authentic Source",
            "required": [
                "organization_name",
                "organization_code",
                "homepage_uri",
                "contacts"
            ],
            "properties": {
                "organization_name": {
                    "type": "string",
                    "description": "Name of the Authentic Source",
                    "pattern": "^(?!\\s)(?!.*\\s\\s)(?!.*\\s$).+$"
                },
                "organization_code": {
                    "type": "string",
                    "description": "Code identifier of the Verifiable Credential type",
                    "pattern": "^[^\\s]+$"
                },
                "homepage_uri": {
                    "type": "string",
                    "description": "URI pointing to the Authentic Source's homepage",
                    "format": "uri"
                },
                "logo_uri": {
                    "type": "string",
                    "description": "URI pointing to the Authentic Source's logo imaage",
                    "pattern": "^(http|https):\\/\\/(?!(w{1,2}|w{4,})\\.)(www\\.)?[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)+(\\.[a-zA-Z]{2,})(:[0-9]+)?(\\/.*)?\\.svg$"
                },
                "contacts": {
                    "type": "array",
                    "description": "Contact e-mails for info and assistance",
                    "items": {
                        "type": "string",
                        "pattern": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
                    }
                }
            },
            "additionalProperties": false
        },
        "no_svg_logo_image_display_properties": {
            "type": "object",
            "description": "An object defining information about displaying a logo image in non-SVG format",
            "required": [
                "logo"
            ],
            "properties": {
                "logo": {
                    "type": "object",
                    "description": "Object with information about the logo image to be displayed for the Verifiable Credential Type",
                    "required": [
                        "uri"
                    ],
                    "properties": {
                        "uri": {
                            "type": "string",
                            "description": "String value that contains a URI where obtaining the logo image",
                            "pattern": "^(http|https):\\/\\/(?!(w{1,2}|w{4,})\\.)(www\\.)?[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)+(\\.[a-zA-Z]{2,})(:[0-9]+)?(\\/.*)?\\.png$"
                        },
                        "uri#integrity": {
                            "type": "string",
                            "description": "A String representing an integrity metadata for ensuring the integrity of the logo image referred to by the uri"
                        },
                        "alt_text": {
                            "type": "string",
                            "description": "String value of the alternative text to display instead of the logo image"
                        }
                    },
                    "additionalProperties": false
                },
                "background_color": {
                    "type": "string",
                    "description": "RGB color value as defined in W3C.CSS-COLOR for the background of the Verifiable Credential Type"
                },
                "text_color": {
                    "type": "string",
                    "description": "RGB color value as defined in W3C.CSS-COLOR for the text of the Verifiable Credential Type"
                }
            },
            "additionalProperties": false
        },
        "svg_logo_image_display_properties": {
            "type": "object",
            "description": "An object defining information about displaying a logo image in SVG format",
            "required": [
                "uri"
            ],
            "properties": {
                "uri": {
                    "type": "string",
                    "description": "String value that contains a URI where obtaining the SVG logo image",
                    "pattern": "^(http|https):\\/\\/(?!(w{1,2}|w{4,})\\.)(www\\.)?[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)+(\\.[a-zA-Z]{2,})(:[0-9]+)?(\\/.*)?\\.svg$"
                },
                "uri#integrity": {
                    "type": "string",
                    "description": "A String representing an integrity metadata for ensuring the integrity of the svg logo image referred to by the uri"
                },
                "alt_text": {
                    "type": "string",
                    "description": "String value of the alternative text to display instead of the svg logo image"
                },
                "properties": {
                    "type": "object",
                    "description": "An object defining display properties about the SVG logo image (The object MUST contain at least one of this properties: orientation, color_scheme, contrast)",
                    "properties": {
                        "orientation": {
                            "type": "string",
                            "description": "The orientation for which the SVG template is optimized",
                            "enum": [
                                "portrait",
                                "landscape"
                            ]
                        },
                        "color_scheme": {
                            "type": "string",
                            "description": "The color scheme for which the SVG template is optimized",
                            "enum": [
                                "light",
                                "dark"
                            ]
                        },
                        "contrast": {
                            "type": "string",
                            "description": "The contrast for which the SVG template is optimized",
                            "enum": [
                                "normal",
                                "high"
                            ]
                        }
                    },
                    "anyOf": [
                        {
                            "required": [
                                "orientation"
                            ]
                        },
                        {
                            "required": [
                                "color_scheme"
                            ]
                        },
                        {
                            "required": [
                                "contrast"
                            ]
                        }
                    ],
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        }
    }
}