From 1877219eb5e3a753339a57c2d35c76985878fdbd Mon Sep 17 00:00:00 2001 From: Chris Camargo Date: Mon, 12 Jun 2023 16:03:11 -0700 Subject: [PATCH] Add $id field to schema with versioned URL --- .github/pull_request_template.md | 2 ++ package-lock.json | 18 +++++++++--------- package.json | 4 ++-- schema.json | 2 +- scripts/generate-types.js | 8 +++++++- setup.py | 8 +++++++- 6 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..dd3fae3 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,2 @@ + + diff --git a/package-lock.json b/package-lock.json index ba2fab5..8a52843 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@nasa-jpl/seq-json-schema", - "version": "1.0.19", + "version": "1.0.20", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@nasa-jpl/seq-json-schema", - "version": "1.0.19", + "version": "1.0.20", "license": "MIT", "devDependencies": { "ajv": "^8.12.0", - "json-schema-to-typescript": "^13.0.1", + "json-schema-to-typescript": "^13.0.2", "prettier": "^2.8.8" } }, @@ -352,9 +352,9 @@ } }, "node_modules/json-schema-to-typescript": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.1.tgz", - "integrity": "sha512-VU+Spn84eLJyt8R0Bmg2soTwHQFgvrGrU7V8mXbhqWFdEYCFekSYk4JcpCzx0i/WzjEVJKAU7r0y0PVYT14E6Q==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", + "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", "dev": true, "dependencies": { "@bcherny/json-schema-ref-parser": "10.0.5-fork", @@ -872,9 +872,9 @@ } }, "json-schema-to-typescript": { - "version": "13.0.1", - "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.1.tgz", - "integrity": "sha512-VU+Spn84eLJyt8R0Bmg2soTwHQFgvrGrU7V8mXbhqWFdEYCFekSYk4JcpCzx0i/WzjEVJKAU7r0y0PVYT14E6Q==", + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/json-schema-to-typescript/-/json-schema-to-typescript-13.0.2.tgz", + "integrity": "sha512-TCaEVW4aI2FmMQe7f98mvr3/oiVmXEC1xZjkTZ9L/BSoTXFlC7p64mD5AD2d8XWycNBQZUnHwXL5iVXt1HWwNQ==", "dev": true, "requires": { "@bcherny/json-schema-ref-parser": "10.0.5-fork", diff --git a/package.json b/package.json index f2e1119..054131a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nasa-jpl/seq-json-schema", - "version": "1.0.19", + "version": "1.0.20", "license": "MIT", "type": "module", "repository": { @@ -19,7 +19,7 @@ }, "devDependencies": { "ajv": "^8.12.0", - "json-schema-to-typescript": "^13.0.1", + "json-schema-to-typescript": "^13.0.2", "prettier": "^2.8.8" } } diff --git a/schema.json b/schema.json index f65a4a1..e26fb3c 100644 --- a/schema.json +++ b/schema.json @@ -1,5 +1,5 @@ { - "$id": "SeqJson", + "$id": "https://github.com/NASA-AMMOS/seq-json-schema/tree/v1.0.20", "$schema": "https://json-schema.org/draft/2020-12/schema", "$defs": { "activate": { diff --git a/scripts/generate-types.js b/scripts/generate-types.js index 2c845d1..f9aca3e 100644 --- a/scripts/generate-types.js +++ b/scripts/generate-types.js @@ -7,7 +7,7 @@ import { writeFileSync } from 'fs'; * @return {string} */ function patchTypes(types) { - // Remove the 'Request1' object since the library does not generate the + // Remove the 'Request1' object since the library does not generate the // correct type for the request 'oneOf' in the schema. // See: https://github.com/bcherny/json-schema-to-typescript/issues/381 types = types.replace(/ \& Request1/, ''); @@ -15,6 +15,12 @@ function patchTypes(types) { `export type Request1 =\n | {\n [k: string]: unknown;\n }\n | {\n [k: string]: unknown;\n };\n`, '', ); + + // Update the main interface so the base type is named 'SeqJson'. + // This is needed because there is no other way to configure the + // base type name as the library pulls it from the $id field. + types = types.replace(/export interface HttpsGithubComNASAAMMOSSeqJsonSchemaTree.* {/, 'export interface SeqJson {'); + return types; } diff --git a/setup.py b/setup.py index 7b1fe21..addd17e 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,15 @@ +from json import loads from pathlib import Path from setuptools import setup this_directory = Path(__file__).parent long_description = (this_directory / 'README.md').read_text() +with open(this_directory / 'package.json', 'r') as f: + package_json = f.read() + +version = loads(package_json).get('version') + setup( author='camargo', author_email='Christopher.A.Camargo@jpl.nasa.gov', @@ -14,5 +20,5 @@ name='seq-json-schema', packages=['seq-json-schema'], url='https://github.com/NASA-AMMOS/seq-json-schema', - version='1.0.19' + version=version )