Skip to content

Commit

Permalink
fix: dereference schema (#83)
Browse files Browse the repository at this point in the history
* fix: dereference schema

* fix: update ref

* fix: resolve conversation
  • Loading branch information
jjenscodee authored Dec 8, 2023
1 parent 2cd878f commit ba49aab
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 32 deletions.
16 changes: 2 additions & 14 deletions docs/static/schemas/1-0-0/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@
"$ref": "#/$defs/registration"
},
"inherits": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/$defs/registration"
}
]
"$ref": "#/$defs/registration"
},
"virtual": {
"title": "Virtual Component Class",
Expand All @@ -64,7 +57,6 @@
"type": "array",
"items": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/signals/schema/signal.schema.json",
"title": "Signal",
"description": "A continuous data signal in the AICA framework that can be an input or an output.",
"type": "object",
Expand Down Expand Up @@ -110,7 +102,6 @@
"type": "array",
"items": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/signals/schema/signal_type.schema.json",
"title": "Signal Type",
"description": "Supported signal value types as simple atomic types or encoded state types.",
"anyOf": [
Expand All @@ -127,7 +118,6 @@
},
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/parameters/schema/encoded_state_type.schema.json",
"title": "Encoded State Type",
"description": "The state type of an encoded value from a collection of supported types, as defined in clproto.",
"type": "string",
Expand Down Expand Up @@ -267,7 +257,6 @@
"type": "array",
"items": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/parameters/schema/parameter.schema.json",
"title": "Parameter",
"description": "A dynamic parameter that is publicly configurable.",
"type": "object",
Expand Down Expand Up @@ -295,7 +284,6 @@
"parameter_type": {
"description": "The parameter value type.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/parameters/schema/parameter_type.schema.json",
"title": "Parameter Type",
"type": "string",
"enum": [
Expand All @@ -314,7 +302,7 @@
},
"parameter_state_type": {
"description": "The state type of the parameter, if the value type is an encoded state.",
"$ref": "#/properties/inputs/items/properties/signal_type/anyOf/1"
"$ref": "#/properties/inputs/items/properties/signal_types/items"
},
"default_value": {
"description": "The string representation of the default parameter value, or null if the parameter has no valid default value.",
Expand Down
7 changes: 1 addition & 6 deletions docs/static/schemas/1-0-0/controller.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"type": "array",
"items": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/signals/schema/signal.schema.json",
"title": "Signal",
"description": "A continuous data signal in the AICA framework that can be an input or an output.",
"type": "object",
Expand Down Expand Up @@ -122,7 +121,6 @@
"type": "array",
"items": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/signals/schema/signal_type.schema.json",
"title": "Signal Type",
"description": "Supported signal value types as simple atomic types or encoded state types.",
"anyOf": [
Expand All @@ -139,7 +137,6 @@
},
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/parameters/schema/encoded_state_type.schema.json",
"title": "Encoded State Type",
"description": "The state type of an encoded value from a collection of supported types, as defined in clproto.",
"type": "string",
Expand Down Expand Up @@ -216,7 +213,6 @@
"type": "array",
"items": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/parameters/schema/parameter.schema.json",
"title": "Parameter",
"description": "A dynamic parameter that is publicly configurable.",
"type": "object",
Expand Down Expand Up @@ -244,7 +240,6 @@
"parameter_type": {
"description": "The parameter value type.",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://raw.githubusercontent.com/aica-technology/api/main/schemas/parameters/schema/parameter_type.schema.json",
"title": "Parameter Type",
"type": "string",
"enum": [
Expand All @@ -263,7 +258,7 @@
},
"parameter_state_type": {
"description": "The state type of the parameter, if the value type is an encoded state.",
"$ref": "#/properties/inputs/items/properties/signal_type/anyOf/1"
"$ref": "#/properties/inputs/items/properties/signal_types/items"
},
"default_value": {
"description": "The string representation of the default parameter value, or null if the parameter has no valid default value.",
Expand Down
9 changes: 1 addition & 8 deletions schemas/component-descriptions/schema/component.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,7 @@
"$ref": "#/$defs/registration"
},
"inherits": {
"oneOf": [
{
"$ref": "#"
},
{
"$ref": "#/$defs/registration"
}
]
"$ref": "#/$defs/registration"
},
"virtual": {
"title": "Virtual Component Class",
Expand Down
21 changes: 17 additions & 4 deletions utils/bundleHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,26 @@ import * as fs from "fs";

let filePath = process.argv[2];
let outputFileName = process.argv[3];

$RefParser.bundle(filePath).then(async (schema) => {

let jsonSchema = decodeURI(JSON.stringify(schema, null, 2));
jsonSchema = jsonSchema.replaceAll('%24', '$');
fs.writeFile(outputFileName, jsonSchema, 'utf8', (err) => {
if (err) throw err;
console.log('The file has been saved!');
});

if(outputFileName === "application.schema.json") {
fs.writeFile(outputFileName, jsonSchema, 'utf8', (err) => {
if (err) throw err;
console.log('The file has been saved!');
});
} else {
let jsonSchemaObject = JSON.parse(jsonSchema);
// Avoid nested reference (cannot be resolved by VSCode)
jsonSchemaObject['properties']['parameters']['items']['properties']['parameter_state_type']['$ref'] = '#/properties/inputs/items/properties/signal_types/items';
fs.writeFile(outputFileName, JSON.stringify(jsonSchemaObject, null, 2), 'utf8', (err) => {
if (err) throw err;
console.log('The file has been saved!');
});
}
});


0 comments on commit ba49aab

Please sign in to comment.