﻿{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "http://e-coc.org/schema/V0.9/eCOC.json",
    "type": "object",
    "title": "eCoC",
    "description": "electronicCertificateOfConformity",
    "additionalProperties": false,
    "properties": {
        "Id": {
            "type": "string",
            "description": "Issuer's Identifier"
        },
        "Uuid": {
            "type": "string",
            "description": "UUID according RFC4122 for unique company independent COC reference"
        },
        "URL": {
            "type": "string",
            "Description": "URL for future usage (e.g Download-Link) or Link to public WebService"
        },
        "RefSchemaUrl": {
            "type": "string",
            "description": "Url-link to schema the json is based upon"
        },
        "ECocType": {
            "type": "string",
            "description": "Product: CoC acc. ISO17050 | Material: DIN EN 10204 | LabTest: Exchange of Lab-Certificates ",
            "enum": [
                "Product",
                "Material",
                "LabTest",
                "Stamping Certificate"
            ]
        },
        "DataLevel": {
            "type": "string",
            "description": "according to DINSPEC 9012",
            "enum": [
                "A-Header only",
                "B-Declaration of Object",
                "C-including Results"
            ]
        },
        "NormativeRef": {
            "$ref": "#/definitions/NormativeRef"
        },
        "BusinessRef": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "StandardReferences": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Reference"
                    }
                },
                "AdditionalReferences": {
                    "$ref": "#/definitions/AddProperties"
                }
            },
            "Description": "References to Business Case"
        },
        "Parties": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/Party"
            },
            "definition": "Parties and partners envolved in CoC",
            "minitems": 1
        },
        "ObjectOfDeclaration": {
            "type": "array",
            "description": "Designates the parts/material/labtest this document is assigned to",
            "items": {
                "$ref": "#/definitions/Object"
            },
            "minitems": 1
        },
        "Results": {
            "$ref": "#/definitions/Results"
        },
        "Declaration": {
            "type": "object",
            "properties": {
                "DateOfIssue": {
                    "type": "string"
                },
                "Concessions": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "remarks": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "ConformityStatus": {
                    "type": "string",
                    "enum": [
                        "True",
                        "False",
                        "WithConcessions"
                    ]
                },
                "Signature": {
                    "type": "object",
                    "properties": {
                        "SignerName": {
                            "type": "string"
                        },
                        "SignerPosition": {
                            "type": "string"
                        },
                        "PartyRefOfSigner": {
                            "type": "string"
                        },
                        "SignatureStamp": {
                            "type": "string"
                        },
                        "SignatureDate": {
                            "type": "string"
                        }
                    },
                    "required": []
                },
                "CocConfirmationText": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "minitems": 1
                }
            },
            "required": []
        },
        "Attachment": {
            "$ref": "#/definitions/Attachment"
        }
    },
    "required": [],
    "definitions": {
        "Party": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "PartyNo": {
                    "type": "integer",
                    "description": "For ease of reference in objecct of declaration"
                },
                "PartyName": {
                    "type": "string"
                },
                "Partyidentifier": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/CompanyIdentifier"
                    },
                    "minitems": 1
                },
                "PartyAddress": {
                    "$ref": "#/definitions/Address"
                },
                "PartyRole": {
                    "$ref": "#/definitions/PartyRole"
                },
                "AdditionalPartyProperties": {
                    "$ref": "#/definitions/AddProperties"
                }
            },
            "required": [
                "PartyName",
                "PartyAddress"
            ]
        },
        "CompanyIdentifier": {
            "type": "object",
            "description": "unique id for identifying party",
            "additionalProperties": false,
            "properties": {
                "NameOfIdentifier": {
                    "type": "string",
                    "enum": [
                        "DUNS",
                        "VATID",
                        "CageCode",
                        "CustomerNo",
                        "SupplierNo"
                    ]
                },
                "ValueOfIdentifier": {
                    "type": "string"
                }
            }
        },
        "Address": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "StreetAddress": {
                    "type": "string"
                },
                "City": {
                    "type": "string"
                },
                "State": {
                    "type": "string"
                },
                "PostalCode": {
                    "type": "string"
                },
                "CountryCode": {
                    "type": "string",
                    "$comment": "countryCode nach ISO3166-1"
                },
                "AddAddressLine": {
                    "type": "string"
                }
            },
            "required": [
                "StreetAddress",
                "City",
                "PostalCode",
                "CountryCode"
            ]
        },
        "Attachment": {
            "type": "object",
            "properties": {
                "FileName": {
                    "type": "string"
                },
                "FileType": {
                    "type": "string",
                    "description": "MimeType according to IETF's RFC 6838."
                },
                "Encoding": {
                    "type": "string",
                    "enum": [
                        "base64"
                    ]
                },
                "Data": {
                    "type": "string",
                    "description": "File content encoded according RFC 2548 - Base64"
                },
                "HashAlgorithm": {
                    "type": "string",
                    "description": "chacksum/Hash algorithm",
                    "enum": [
                        "SHA1",
                        "MD5"
                    ]
                },
                "HashValue": {
                    "type": "string"
                }
            },
            "required": []
        },
        "PartyRole": {
            "type": "string",
            "enum": [
                "Customer",
                "Recipient",
                "Manufacturer",
                "Processor",
                "Consignee"
            ]
        },
        "Object": {
            "type": "object",
            "description": "Defines a single part, process,...",
            "additionalProperties": false,
            "properties": {
                "ObjectID": {
                    "type": "string",
                    "description": "unique id for further reference purposes"
                },
                "ObjectName": {
                    "type": "string"
                },
                "ObjectType": {
                    "type": "string",
                    "enum": [
                        "Material",
                        "Part",
                        "RelatedPart",
                        "InternalProcess",
                        "ExternalProcess",
                        "Assembly",
                        "MaterialTest",
                        "StandardPart",
                        "Other"
                    ],
                    "Description": "Either Material, Part, Assembly, Test,.."
                },
                "Quantities": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Quantity"
                    }
                },
                "Dimensions": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Dimension"
                    }
                },
                "NormativeReference": {
                    "$ref": "#/definitions/NormativeRef"
                },
                "SerialNr": {
                    "$ref": "#/definitions/SNstructure"
                },
                "RefCoC": {
                    "type": "object",
                    "description": "UUID of CoC valid for this object",
                    "additionalProperties": false,
                    "properties": {
                        "RefCoCID": {
                            "type": "string"
                        },
                        "RefURL": {
                            "type": "string",
                            "Description": "Url to referenced Document (e.g. for Download)"
                        },
                        "SubDocument": {
                            "$ref": "#/definitions/Attachment"
                        }
                    },
                    "required": []
                },
                "PartyRefId": {
                    "type": "integer",
                    "declaration": "referenced to party in party-Structure"
                },
                "ReferencedObjects": {
                    "type": "array",
                    "description": "reference to ObjectId of related item",
                    "items": {
                        "type": "integer"
                    }
                },
                "ObjectProperties": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "Name": {
                                "type": "string",
                                "enum": [
                                    "PartNo",
                                    "BatchNo",
                                    "DrawingNo",
                                    "CastNo",
                                    "PackageNo",
                                    "OrderConfPosition",
                                    "Material",
                                    "Form",
                                    "Temper",
                                    "Other"
                                ]
                            },
                            "Value": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        },
                        "required": []
                    }
                },
                "AdditionalObjectProperties": {
                    "$ref": "#/definitions/TechnicalProperties"
                }
            },
            "required": [],
            "additionalObjects": {
                "$ref": "#/definitions/Object"
            }
        },
        "Results": {
            "type": "object",
            "properties": {
                "MaterialCertification": {
                    "$ref": "http://e-coc.org/schema/v0.9/MaterialCertification.json#/definitions/MaterialTest"
                }
            },
            "required": []
        },
        "Reference": {
            "type": "object",
            "properties": {
                "Name": {
                    "type": "string",
                    "description": "Name of business case reference",
                    "enum": [
                        "OrderNo",
                        "OrderPosition",
                        "DeliveryNote",
                        "OrderDate",
                        "DeliverDate",
                        "CustomerOrderNo",
                        "DeliveryDate"
                    ]
                },
                "Value": {
                    "type": "string",
                    "description": "Value of business case reference"
                }
            }
        },
        "NormativeRef": {
            "type": "array",
            "description": "List of applicable standards",
            "items": {
                "type": "string"
            }
        },
        "AddProperties": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "Name": {
                        "type": "string"
                    },
                    "Value": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "required": []
            },
            "Description": "Additional Properties Name/ValueArray not covered by standard references"
        },
        "SNstructure": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "FinishedCustSN": {
                        "type": "string"
                    },
                    "FinishedProdSN": {
                        "type": "string"
                    },
                    "MaterialSupplierSN": {
                        "type": "string"
                    },
                    "MaterialProdSN": {
                        "type": "string"
                    }
                }
            }
        },
        "TechnicalProperties": {
            "type": "array",
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "Name": {
                        "type": "string"
                    },
                    "Value": {
                        "additionalProperties": false,
                        "oneof": [
                            {
                                "type": "number"
                            },
                            {
                                "type": "string"
                            },
                            {
                                "type": "array",
                                "minItems": 2,
                                "maxItems": 2,
                                "items": {
                                    "type": "number"
                                }
                            }
                        ]
                    },
                    "Unit": {
                        "type": "string",
                        "description": "To be defined - this should be physical metric units which are typical in materials science, enum will be long"
                    },
                    "ValueType": {
                        "type": "string",
                        "description": "ValueType may be used by applications for further processing, validations",
                        "enum": [
                            "Integer",
                            "Float",
                            "Time",
                            "DateRange",
                            "NumberRange",
                            "TimeRange",
                            "String"
                        ]
                    }
                },
                "required": []
            },
            "Description": "Typically technical Properties Name/ValueArray not covered by standard references"
        },
        "Quantity": {
            "type": "object",
            "properties": {
                "Amount": {
                    "type": "number"
                },
                "Unit": {
                    "type": "string",
                    "description": "Abbreviation of Unit according to https://www.doa.la.gov/osp/Vendorcenter/publications/unitofmeasurecodes.pdf"
                }
            }
        },
        "Dimension": {
            "type": "object",
            "properties": {
                "Direction": {
                    "type": "string",
                    "enume": [
                        "Length",
                        "Width",
                        "Height"
                    ]
                },
                "DimValue": {
                    "type": "number"
                },
                "DimUnit": {
                    "type": "string"
                }
            },
            "required": []
        }
    }
}