-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Labels
enhancementNew feature or requestNew feature or request
Description
JSON schemas generated from Sury schemas are unnecessarily large because type definitions are duplicated to every place the type is used.
Simple example:
@schema
type url = @s.matches(S.string->S.url) string
@schema
type icon = {
url: url,
width: int,
height: int,
}
@schema
type icons = {
iconA: icon,
iconB: icon,
iconC: icon,
}results into
{
"type": "object",
"properties": {
"iconA": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"width": {
"type": "integer"
},
"height": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"url",
"width",
"height"
]
},
"iconB": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"width": {
"type": "integer"
},
"height": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"url",
"width",
"height"
]
},
"iconC": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"width": {
"type": "integer"
},
"height": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"url",
"width",
"height"
]
}
},
"additionalProperties": false,
"required": [
"iconA",
"iconB",
"iconC"
]
}which could instead be
{
"type": "object",
"properties": {
"iconA": {
"$ref": "#/$defs/icon"
},
"iconB": {
"$ref": "#/$defs/icon"
},
"iconC": {
"$ref": "#/$defs/icon"
}
},
"required": [
"iconA",
"iconB",
"iconC"
],
"additionalProperties": false,
"$defs": {
"icon": {
"type": "object",
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"width": {
"type": "integer"
},
"height": {
"type": "integer"
}
},
"required": [
"url",
"width",
"height"
],
"additionalProperties": false
}
}
}DZakh
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request