Skip to content

Commit

Permalink
Merge pull request #29 from co-cddo/DM-726-update-json-schema-to-be-i…
Browse files Browse the repository at this point in the history
…nline-with-dm-dec-24

DM-726 Update JSON Schema to be inline with Data Marketplace
  • Loading branch information
RobNicholsGDS authored Dec 19, 2024
2 parents 05e8feb + 0103e05 commit 04e561d
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 565 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'json-schema'
643 changes: 87 additions & 556 deletions api_specification/metadata_management_api.yaml

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,23 @@ documentation making it easy for back end implementation and client side consump
A Swagger UI representation of the API Specification can be found at
[/swagger](https://co-cddo.github.io/data-catalogue-metadata/swagger/)
on this repositories Github pages.

#### Bundling the API specification into a single file

The API Specification uses references to the JSON schema files for definitions of most object. If you need to have
the specification represented in a single file without references to other files, the Swagger CLI bundle
command can be used to do this.

For example:

Assuming [Node](https://nodejs.org) is installed locally, Swagger CLI can be installed with:

```
npm install -g @apidevtools/swagger-cli
```

Then the following command run at the root of this app, will build a new api configuration at `api_specification/bundled_metadata_management_api.yaml`

```
swagger-cli bundle -o api_specification/bundled_metadata_management_api.yaml api_specification/metadata_management_api.yaml
```
4 changes: 2 additions & 2 deletions samples/data_service.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"leaving UK",
"entering UK"
],
"contactPoint": [
"contactPoint": [
{
"name": "Rob Nichols",
"email": "[email protected]"
}
],
"publisher": "academy-for-social-justice",
"securityClassification": "OFFICIAL",
"accessRights": "INTERNAL",
"accessRights": "OPEN",
"endpointDescription": "http://example.com/path/to/swagger",
"endpointURL": "http://example.com/api/v1",
"servesDataset": [
Expand Down
2 changes: 1 addition & 1 deletion samples/data_share.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"leaving UK",
"entering UK"
],
"contactPoint": [
"contactPoint": [
{
"name": "Rob Nichols",
"email": "[email protected]"
Expand Down
4 changes: 2 additions & 2 deletions samples/dataset.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"leaving UK",
"entering UK"
],
"contactPoint": [
"contactPoint": [
{
"name": "Rob Nichols",
"email": "[email protected]"
}
],
"publisher": "academy-for-social-justice",
"securityClassification": "OFFICIAL",
"accessRights": "INTERNAL",
"accessRights": "OPEN",
"distribution": [
{
"accessService": ["8d085327-21b6-4d8b-9705-88faad231d23"],
Expand Down
18 changes: 16 additions & 2 deletions schema/catalogued_resource_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"description": "A rights statement that concerns how the distribution is accessed.",
"type": "string",
"enum": [
"INTERNAL",
"RESTRICTED",
"OPEN",
"COMMERCIAL"
]
Expand All @@ -32,7 +32,8 @@
"type": "string",
"enum": [
"owner",
"contact"
"contact",
"approver"
]
}
},
Expand All @@ -42,6 +43,15 @@
]
}
},
"created": {
"description": "The date when the catalogued resource was first added to catalogue.",
"$ref": "https://co-cddo.github.io/data-catalogue-metadata/schema/shared_schema.json#/schemas/dateOrDateTime"
},
"creator": {
"description": "The organisation responsible for creating the catalogued resource.",
"type": "string",
"maxLength": 75
},
"description": {
"description": "A concise narrative of the content of an catalogued resource.",
"type": "string",
Expand All @@ -52,6 +62,10 @@
"type": "string",
"maxLength": 50
},
"issued": {
"description": "The date the catalogued resource was first made available.",
"$ref": "https://co-cddo.github.io/data-catalogue-metadata/schema/shared_schema.json#/schemas/dateOrDateTime"
},
"keyword": {
"description": "Uncontrolled terms (words or phrases) assigned to describe an information resource.",
"type": "array",
Expand Down
5 changes: 5 additions & 0 deletions schema/dataset_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
"maxLength": 50
}
},
"accessURL": {
"description": "The location from which the Dataset can be accessed",
"type": "string",
"maxLength": 250
},
"downloadURL": {
"description": "The location from which the Dataset can be downloaded",
"type": "string",
Expand Down
6 changes: 4 additions & 2 deletions schema_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require "json-schema"
require "json"
# frozen_string_literal: true

require 'json-schema'
require 'json'

def json_from(path)
JSON.parse(File.read(path))
Expand Down

0 comments on commit 04e561d

Please sign in to comment.