diff --git a/src/schema/skeleton.ts b/src/schema/skeleton.ts index 1d654d3..2e85583 100644 --- a/src/schema/skeleton.ts +++ b/src/schema/skeleton.ts @@ -7,6 +7,12 @@ export default { ...meta, type: "object", properties: { + id: { + type: "string", + description: "A unique identifier for your tutorial. Currently no system to create this, so create your own for now", + examples: ["fcc-learn-npm"] + }, + version: { $ref: "#/definitions/semantic_version", description: "The tutorial version. Must be unique for the tutorial.", @@ -253,5 +259,5 @@ export default { }, }, additionalProperties: false, - required: ["version", "config", "levels"], + required: ["id", "version", "config", "levels"], }; diff --git a/src/schema/tutorial.ts b/src/schema/tutorial.ts index 035d164..75ed211 100644 --- a/src/schema/tutorial.ts +++ b/src/schema/tutorial.ts @@ -7,6 +7,12 @@ export default { ...meta, type: "object", properties: { + id: { + type: "string", + description: "A unique identifier for your tutorial. Currently no system to create this, so create your own for now", + examples: ["fcc-learn-npm"] + }, + version: { $ref: "#/definitions/semantic_version", description: "The tutorial version. Must be unique for the tutorial.", diff --git a/tests/skeleton.test.ts b/tests/skeleton.test.ts index 01f4ad1..10ad942 100644 --- a/tests/skeleton.test.ts +++ b/tests/skeleton.test.ts @@ -4,6 +4,7 @@ import skeletonSchema from '../src/schema/skeleton' const validateSkeleton = (json: any) => validateSchema(skeletonSchema, json) const validJson = { + id: 'coderoad-test', version: '0.1.0', config: { testRunner: { @@ -95,6 +96,13 @@ describe('validate skeleton', () => { const valid = validateSkeleton(json) expect(valid).toBe(true) }) + it('should fail if id is missing', () => { + const json = { ...validJson, id: undefined } + + const valid = validateSkeleton(json) + expect(valid).toBe(false) + }) + it('should fail if version is invalid', () => { const json = { ...validJson, version: 'NOT A VERSION' } diff --git a/tests/tutorial.test.ts b/tests/tutorial.test.ts index c78001c..1b5a0cf 100644 --- a/tests/tutorial.test.ts +++ b/tests/tutorial.test.ts @@ -3,6 +3,7 @@ import tutorialSchema from '../src/schema/tutorial' import { validateSchema } from '../src/utils/validateSchema' const validJson: Partial = { + id: 'coderoad-test', version: '0.1.0', summary: { title: 'Title', description: 'Description' }, config: {