Skip to content

Commit

Permalink
improve schema for Time object to generate better TS types
Browse files Browse the repository at this point in the history
  • Loading branch information
dandelany committed Feb 10, 2025
1 parent a86786f commit aa40c33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nasa-jpl/seq-json-schema",
"version": "1.3.0",
"version": "1.3.1",
"license": "MIT",
"type": "module",
"repository": {
Expand Down
42 changes: 22 additions & 20 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,30 +477,32 @@
"time": {
"additionalProperties": false,
"description": "Time object",
"properties": {
"tag": {
"description": "Relative or absolute time. Required for ABSOLUTE, BLOCK_RELATIVE, COMMAND_RELATIVE, and EPOCH_RELATIVE time types but not COMMAND_COMPLETE.",
"type": "string"
"oneOf": [
{
"additionalProperties": false,
"properties": {
"type": {
"description": "Allowed time types without a tag: COMMAND_COMPLETE",
"enum": ["COMMAND_COMPLETE"],
"type": "string"
}
},
"required": ["type"]
},
"type": {
"description": "Allowed time types: ABSOLUTE, BLOCK_RELATIVE, COMMAND_RELATIVE, EPOCH_RELATIVE, or COMMAND_COMPLETE.",
"enum": ["ABSOLUTE", "BLOCK_RELATIVE", "COMMAND_RELATIVE", "EPOCH_RELATIVE", "COMMAND_COMPLETE"],
"type": "string"
}
},
"required": ["type"],
"allOf": [
{
"if": {
"properties": {
"type": {
"enum": ["ABSOLUTE", "BLOCK_RELATIVE", "COMMAND_RELATIVE", "EPOCH_RELATIVE"]
}
"additionalProperties": false,
"properties": {
"type": {
"description": "Allowed time types with a tag: ABSOLUTE, BLOCK_RELATIVE, COMMAND_RELATIVE, EPOCH_RELATIVE.",
"enum": ["ABSOLUTE", "BLOCK_RELATIVE", "COMMAND_RELATIVE", "EPOCH_RELATIVE"],
"type": "string"
},
"tag": {
"description": "Relative or absolute time. Required for ABSOLUTE, BLOCK_RELATIVE, COMMAND_RELATIVE, and EPOCH_RELATIVE time types but not COMMAND_COMPLETE.",
"type": "string"
}
},
"then": {
"required": ["tag"]
}
"required": ["type", "tag"]
}
],
"type": "object"
Expand Down

0 comments on commit aa40c33

Please sign in to comment.