{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://api.npolar.no/schema/publication-1",
    "title": "Publication data model",
    "description": "A publication reference",
    "type": "object",
    "additionalProperties": false,
    "required": [
        "title",
        "schema",
        "collection",
        "publication_type"
    ],
    "properties": {
        "id": {
            "description": "Identifier (UUID | URI)",
            "type": "string"
        },
        "schema": {
            "type": "string",
            "pattern": "^http(s)?://"
        },
        "collection": {
            "enum": [
                "publication"
            ]
        },
        "doi": {
            "type": [
                "string",
                "null"
            ],
            "pattern": "^10\\.[0-9]{2,}/.+$"
        },
        "draft": {
            "enum": [
                "yes",
                "no"
            ],
            "default": "no"
        },
        "title": {
            "description": "Title - exactly as published in the original language. Markdown accepted.",
            "type": "string"
        },
        "subtitle": {
            "type": [
                "string",
                "null"
            ]
        },
        "publication_lang": {
            "type": [
                "string",
                "null"
            ],
            "default": "en"
        },
        "abstract": {
            "_uniqueItems": true,
            "type": "array",
            "description": "Scientific abstract. Markdown accepted.",
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "@language": {
                        "type": "string",
                        "default": "en"
                    },
                    "@value": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            }
        },
        "overview": {
            "_uniqueItems": true,
            "type": "array",
            "description": "Summary for non-scientists. Markdown accepted",
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "@language": {
                        "type": "string",
                        "default": "en"
                    },
                    "@value": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            }
        },
        "programme": {
            "title": "Programmes",
            "description": "Select programmes affiliated with the publication",
            "type": "array",
            "additionalItems": false,
            "_uniqueItems": true,
            "items": {
                "type": "string",
                "enum": [
                    "Fram Strait",
                    "Biodiversity",
                    "Environmental management",
                    "Environmental pollutants",
                    "Geology and geophysics",
                    "Oceans and sea ice",
                    "Arctic ocean",
                    "Svalbard",
                    "Antarctic",
                    "Ny-\u00c5lesund"
                ]
            }
        },
        "publication_type": {
            "enum": [
                "peer-reviewed",
                "editorial",
                "review",
                "correction",
                "book",
                "in-book",
                "poster",
                "report",
                "in-report",
                "abstract",
                "phd",
                "master",
                "map",
                "proceedings",
                "popular",
                "other"
            ]
        },
        "type": {
            "enum": [
                "peer-reviewed",
                "editorial",
                "review",
                "correction",
                "book",
                "in-book",
                "poster",
                "report",
                "in-report",
                "abstract",
                "phd",
                "master",
                "map",
                "proceedings",
                "popular",
                "other"
            ]
        },
        "state": {
            "enum": [
                "submitted",
                "accepted",
                "published"
            ],
            "default": "published"
        },
        "locations": {
            "type": "array",
            "_uniqueItems": true,
            "additionalItems": true,
            "items": {
                "type": "object",
                "additionalProperties": true,
                "properties": {
                    "placename": {
                        "type": "string"
                    },
                    "area": {
                        "type": "string"
                    },
                    "country": {
                        "description": "[Country code](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2), use 'NO' for Norway, including Svalbard and Jan Mayen, Bouvet\u00f8ya, and Peter I \u00d8y. 'AQ' = Antarctica and 'XZ' = International waters",
                        "type": [
                            "string",
                            "null"
                        ],
                        "pattern": "^(([A-Z]|[a-z]){2})$"
                    },
                    "hemisphere": {
                        "description": "Hemisphere: N or S",
                        "type": [
                            "string",
                            "null"
                        ],
                        "pattern": "^[NSns]{1}$"
                    }
                }
            }
        },
        "published": {
            "type": [
                "string",
                "null"
            ],
            "format": "/^[0-9]{4}/"
        },
        "printed": {
            "type": [
                "string",
                "null"
            ],
            "format": "/^[0-9]{4}/"
        },
        "volume": {
            "type": [
                "string",
                "null"
            ]
        },
        "issue": {
            "type": [
                "string",
                "null"
            ]
        },
        "suppl": {
            "type": [
                "string",
                "null"
            ]
        },
        "art_no": {
            "type": [
                "string",
                "null"
            ]
        },
        "page_count": {
            "type": [
                "string",
                "null"
            ]
        },
        "journal": {
            "title": "Journal",
            "description": "Peer-reviewed journal",
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "np_series": {
                    "type": "string"
                },
                "series": {
                    "type": "string"
                },
                "series_no": {
                    "type": "string"
                }
            }
        },
        "conference": {
            "title": "Conference",
            "description": "For abstracts and proceedings",
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "place": {
                    "type": "string"
                },
                "country": {
                    "type": "string"
                },
                "dates": {
                    "type": "array",
                    "items": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    }
                }
            }
        },
        "pages": {
            "title": "Publication pages",
            "description": "Either to and from page or the total no of pages",
            "type": "array",
            "additionalItems": false,
            "items": {
                "type": [
                    "string",
                    "null"
                ]
            }
        },
        "people": {
            "description": "People involved in creating the publication",
            "type": "array",
            "_uniqueItems": true,
            "additionalItems": false,
            "required": [
                "first_name",
                "last_name",
                "roles"
            ],
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "id": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "first_name": {
                        "type": "string"
                    },
                    "last_name": {
                        "type": "string"
                    },
                    "email": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "homepage": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "roles": {
                        "type": "array",
                        "items": {
                            "enum": [
                                "author",
                                "editor",
                                "co-author",
                                "translator",
                                "advisor",
                                "correspondent"
                            ]
                        },
                        "default": [
                            "author"
                        ],
                        "minItems": 1,
                        "maxItems": 6,
                        "_uniqueItems": true
                    },
                    "organisation": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "affiliation": {
                        "description": "Affilated organisations ",
                        "type": "array",
                        "_uniqueItems": true,
                        "additionalItems": false,
                        "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                                "@id": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                },
                                "name": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        },
        "topics": {
            "title": "NPI topics",
            "description": "See https://github.com/npolar/api.npolar.no/blob/master/schema/dataset.json",
            "type": "array",
            "_uniqueItems": true,
            "additionalItems": false,
            "items": {
                "type": "string",
                "enum": [
                    "acidification",
                    "atmosphere",
                    "biology",
                    "biogeochemistry",
                    "chemistry",
                    "climate",
                    "conservation",
                    "ecology",
                    "ecotoxicology",
                    "environment",
                    "geophysics",
                    "geology",
                    "glaciology",
                    "history",
                    "human-dimension",
                    "management",
                    "marine",
                    "modelling",
                    "maps",
                    "oceanography",
                    "other",
                    "paleoclimate",
                    "remote-sensing",
                    "seaice",
                    "snow",
                    "terrestrial",
                    "topography",
                    "vegetation"
                ]
            }
        },
        "organisations": {
            "description": "Organisations involved",
            "type": "array",
            "_uniqueItems": true,
            "additionalItems": false,
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "location": {
                        "type": "string"
                    },
                    "roles": {
                        "type": "array",
                        "_uniqueItems": true,
                        "items": {
                            "enum": [
                                "publisher",
                                "originator",
                                "owner",
                                "resourceProvider",
                                "funder"
                            ]
                        }
                    }
                }
            }
        },
        "tags": {
            "additionalItems": false,
            "type": "array",
            "_uniqueItems": true,
            "items": {
                "type": "string"
            }
        },
        "isbn": {
            "additionalItems": false,
            "_uniqueItems": true,
            "type": "array",
            "items": {
                "type": "string"
            }
        },
        "issn": {
            "additionalItems": false,
            "type": "array",
            "_uniqueItems": true,
            "items": {
                "type": "string"
            }
        },
        "links": {
            "type": "array",
            "_uniqueItems": true,
            "additionalItems": false,
            "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                    "rel": {
                        "type": "string",
                        "default": "related"
                    },
                    "href": {
                        "type": "string",
                        "format": "uri"
                    },
                    "hreflang": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "title": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "type": {
                        "type": "string",
                        "default": "text/html"
                    }
                }
            }
        },
        "research_stations": {
            "title": "NP research stations",
            "description": "NPs research stations",
            "type": "array",
            "_uniqueItems": true,
            "additionalItems": false,
            "items": {
                "type": "string",
                "enum": [
                    "Troll",
                    "Ny-\u00c5lesund",
                    "Sverdrupstasjonen",
                    "Zeppelin",
                    "Bouvet\u00f8ya",
                    "Svarthamaren"
                ]
            }
        },
        "license": {
            "description": "License of the publication",
            "type": [
                "string",
                "null"
            ],
            "enum": [
                null,
                "https://creativecommons.org/licenses/by/4.0/",
                "https://creativecommons.org/licenses/by-nc-sa/4.0/",
                "https://creativecommons.org/licenses/by-nc-nd/4.0/",
                "https://creativecommons.org/publicdomain/zero/1.0/"
            ]
        },
        "comment": {
            "description": "Markdown accepted",
            "type": "string"
        },
        "files": {
            "type": "array",
            "_uniqueItems": true,
            "description": "",
            "items": {
                "type": "object",
                "properties": {
                    "uri": {
                        "type": "string",
                        "description": "URI of the attached file",
                        "format": "uri"
                    },
                    "filename": {
                        "type": "string",
                        "description": "File name"
                    },
                    "title": {
                        "type": "string",
                        "description": "Title"
                    },
                    "length": {
                        "type": "integer",
                        "description": "File size in bytes"
                    },
                    "type": {
                        "type": "string",
                        "description": "Media type (e.g. image/png)"
                    },
                    "hash": {
                        "type": "string",
                        "description": ""
                    }
                }
            }
        },
        "created": {
            "description": "Document was published",
            "type": "string",
            "format": "date-time"
        },
        "updated": {
            "description": "Document was updated",
            "type": "string",
            "format": "date-time"
        },
        "created_by": {
            "type": "string"
        },
        "updated_by": {
            "type": "string"
        },
        "_id": {
            "type": "string"
        },
        "_rev": {
            "type": "string"
        },
        "_attachments": {
            "type": "object"
        }
    }
}