Skip to content

Commit

Permalink
fix(JSON Schemas): Fix source URL and apply category to union types
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Apr 28, 2021
1 parent a77879c commit 05aa171
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ts/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ID_BASE_URL = `${SCHEMA_DEST_URL}/v${versionMajor}`
/**
* The base URL for source files.
*/
const SOURCE_BASE_URL = `https://github.com/stencila/schema/blob/master`
const SOURCE_BASE_URL = `https://github.com/stencila/schema/blob/master/schema`

// Create a validation function for JSON Schema for use in `checkSchema`
const ajv = new Ajv()
Expand Down Expand Up @@ -455,13 +455,14 @@ const parentSchema = (
*/
const addTypesSchemas = (schemas: Map<string, JsonSchema>): void => {
for (const [title, schema] of schemas.entries()) {
const { descendants } = schema
const { descendants, category = 'other' } = schema
if (descendants !== undefined && descendants.length > 0) {
const typesTitle = title + 'Types'
schemas.set(typesTitle, {
$schema: 'http://json-schema.org/draft-07/schema#',
$id: `${ID_BASE_URL}/${typesTitle}.schema.json`,
title: typesTitle,
category,
description: `All type schemas that are derived from ${title}`,
anyOf: [title, ...descendants].map((descendant) => ({
$ref: `${descendant}.schema.json`,
Expand Down

0 comments on commit 05aa171

Please sign in to comment.