-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: CD maasglobal-reference-schemas | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'maasglobal-reference-schemas/package.json' | ||
- '.github/workflows/cd-maasglobal-reference-schemas.yml' | ||
|
||
defaults: | ||
run: | ||
working-directory: maasglobal-reference-schemas | ||
|
||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.PUBLIC_NPM_TOKEN }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 15 | ||
name: publish | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "14" | ||
registry-url: "https://registry.npmjs.org" | ||
- name: Install Dependencies | ||
run: | | ||
yarn | ||
- name: Deploy to Registry | ||
run: | | ||
yarn deploy-npm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# IDE Stuff | ||
**/.idea | ||
.vscode/launch.json | ||
*.swp | ||
|
||
# OS STUFF | ||
.DS_Store | ||
.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
package-lock.json | ||
|
||
# IDE Stuff | ||
**/.idea | ||
.vscode/launch.json | ||
*.swp | ||
|
||
# OS STUFF | ||
.DS_Store | ||
.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('eslint-config-maasglobal-ts/prettierrc.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# MaaS Global Reference Schemas | ||
|
||
This repository contains definitions and examples for the JSON Schema format used by MaaS Global. | ||
The format is currently a subset of `http://json-schema.org/draft-07/schema#` and | ||
`https://json-schema.org/draft/2019-09/vocab/hyper-schema`. | ||
|
||
The way we describe tuples seem to be from some earlier version of the specification. | ||
|
||
Also, our schemas contain a custom keyword `invalid` with negative test cases. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "maasglobal-reference-schemas", | ||
"version": "0.0.1", | ||
"description": "Test suite for JSON schema features used by MaaS Global", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/maasglobal/maas-schemas.git" | ||
}, | ||
"keywords": [ | ||
"schemas", | ||
"maas", | ||
"JSON" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/maasglobal/maas-schemas/issues" | ||
}, | ||
"homepage": "https://github.com/maasglobal/maas-schemas/", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"eslint-config-maasglobal-ts": "^0.0.14", | ||
"prettier": "^2.8.1" | ||
}, | ||
"scripts": { | ||
"prettier-check": "yarn prettier --check '**/*.{css,html,js,ts,json,md,yaml,yml}'", | ||
"prettier-fix": "yarn prettier-check --write", | ||
"prettify": "yarn prettier-fix", | ||
"lint": "yarn prettier-check", | ||
"ci": "yarn lint", | ||
"deploy-npm": "yarn ci && yarn publish --non-interactive", | ||
"deploy-alpha": "yarn deploy-npm --tag alpha" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/array.json", | ||
"title": "Array", | ||
"description": "An ordered collection of homogenous values, with duplicates allowed. See Set and Tuple for other array based structures.", | ||
"definitions": { | ||
"exampleArray": { | ||
"type": "array", | ||
"items": { "type": "string" }, | ||
"contains": { "type": "string", "const": "foo" }, | ||
"minItems": 1, | ||
"maxItems": 10, | ||
"examples": [["asdf", "foo", "qwer"]] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/combinator.json", | ||
"title": "Combinator Reference Schemas", | ||
"description": "Keywords that combine several schemas into one.", | ||
"definitions": { | ||
"nonNegative": { | ||
"type": "number", | ||
"minimum": 0 | ||
}, | ||
"integer": { | ||
"type": "integer" | ||
}, | ||
"nonNegativeInteger": { | ||
"allOf": [ | ||
{ "$ref": "#/definitions/nonNegative" }, | ||
{ "$ref": "#/definitions/integer" } | ||
] | ||
}, | ||
|
||
"email": { | ||
"type": "string" | ||
}, | ||
"username": { | ||
"type": "string" | ||
}, | ||
"login": { | ||
"anyOf": [{ "$ref": "#/definitions/email" }, { "$ref": "#/definitions/username" }] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/comment.json", | ||
"$comment": "This is a toplevel comment", | ||
"definitions": { | ||
"exampleDefinition": { | ||
"$comment": "This is a definition comment" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/enum.json", | ||
"title": "Enum Reference Schemas", | ||
"description": "Basic enum definitions should work as expected. Separate accessors can be defined for each value.", | ||
"definitions": { | ||
"timeOfDay": { | ||
"type": "string", | ||
"enum": ["night", "day"], | ||
"examples": ["night", "day"] | ||
}, | ||
"timeOfDayNIGHT": { | ||
"$comment": "Example accessor", | ||
"default": "night", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/timeOfDay" | ||
}, | ||
{ "const": "night" } | ||
] | ||
}, | ||
"timeOfDayDAY": { | ||
"$comment": "Another example accessor", | ||
"default": "day", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/timeOfDay" | ||
}, | ||
{ "const": "day" } | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/hyper.json", | ||
"title": "Hyper Schema Reference", | ||
"description": "Example endpoint", | ||
"definitions": { | ||
"pizzaId": { "type": "string" }, | ||
"recipe": { | ||
"type": "object", | ||
"properties": { | ||
"pizza": { "$ref": "#/definitions/pizzaId" }, | ||
"ingredients": { "type": "object" }, | ||
"steps": { "type": "array" } | ||
}, | ||
"additionalProperties": false | ||
}, | ||
"unknownPizza": { | ||
"type": "null", | ||
"default": null | ||
}, | ||
"withGarlic": { | ||
"type": "boolean" | ||
}, | ||
"request": { | ||
"type": "object", | ||
"properties": { | ||
"garlic": { "$ref": "#/definitions/withGarlic" } | ||
}, | ||
"required": ["garlic"], | ||
"additionalProperties": false | ||
}, | ||
"response": { | ||
"anyOf": [ | ||
{ "$ref": "#/definitions/unknownPizza" }, | ||
{ "$ref": "#/definitions/recipe" } | ||
] | ||
} | ||
}, | ||
"links": [ | ||
{ | ||
"rel": "implementation", | ||
|
||
"href": "{+api}pizza/{pizzaId}/recipe", | ||
"hrefSchema": { | ||
"type": "object", | ||
"properties": { | ||
"api": { | ||
"type": "string", | ||
"const": "https://example.com/" | ||
}, | ||
"pizzaId": { | ||
"$ref": "#/definitions/pizzaId" | ||
} | ||
}, | ||
"required": ["api", "pizzaId"], | ||
"additionalProperties": false | ||
}, | ||
|
||
"headerSchema": { | ||
"content-type": { | ||
"type": "string", | ||
"const": "application/json" | ||
} | ||
}, | ||
"submissionSchema": { | ||
"$ref": "#/definitions/request" | ||
}, | ||
|
||
"targetHints": { | ||
"content-type": ["application/json"], | ||
"allow": ["POST"] | ||
}, | ||
"targetSchema": { | ||
"$ref": "#/definitions/response" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/literal.json", | ||
"title": "Literal Reference Schemas", | ||
"description": "Literals can define any JSON structure, and the input needs to match that structure", | ||
"definitions": { | ||
"stringLiteral": { | ||
"type": "string", | ||
"const": "foo", | ||
"default": "foo" | ||
}, | ||
|
||
"numberLiteral": { | ||
"type": "number", | ||
"const": 123, | ||
"default": 123 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/nominal.json", | ||
"title": "Nominal Typing", | ||
"description": "Naming basic types is useful as documentation. In addition the TypeScript we generate has nominal typing to prevent assigning unrelated basic types to each other.", | ||
"definitions": { | ||
"customerId": { | ||
"type": "string" | ||
}, | ||
"age": { | ||
"type": "integer" | ||
}, | ||
"distance": { | ||
"type": "number" | ||
}, | ||
"membership": { | ||
"type": "boolean" | ||
}, | ||
"metadata": { | ||
"type": "object" | ||
}, | ||
"unknownCustomer": { | ||
"type": "null", | ||
"default": null | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://reference-schemas.maas.global/number.json", | ||
"title": "Number Reference Schemas", | ||
"description": "We use several keywords to limit numbers to a specific form", | ||
"definitions": { | ||
"integer": { | ||
"type": "integer" | ||
}, | ||
"positiveNumber": { | ||
"type": "number", | ||
"minimum": 1, | ||
"examples": [1, 2], | ||
"invalid": { | ||
"negative number": "LTE=", | ||
"zero": "MA==" | ||
} | ||
}, | ||
"evenNumber": { | ||
"type": "number", | ||
"multipleOf": 2, | ||
"examples": [2, 4], | ||
"invalid": { | ||
"odd number": "Mw==" | ||
} | ||
}, | ||
"portNumber": { | ||
"type": "number", | ||
"minimum": 0, | ||
"maximum": 65535 | ||
} | ||
} | ||
} |
Oops, something went wrong.