I am parsing a api.json with some schemas will be shown after. this is the basic structure:
{
"paths": {
"/users": {
"response": {
"$ref": "UserResponse"
}
},
...
},
"components": {
"schemas": {
"UserResponse": {
... // structure
},
...
}
}
}
structure simplified for explaining here
At the bottom part of the document there will be a place with all the schemas labeled:
#for schema in api.components.schemas [
== #schema.at(0) #label(schema.at(0))
#schema.at(1) \ // will be formatted later
]
And I am trying to make this work by using a ref on the type, but it still does not work:
#let read_json_type(typ) = {
if "type" in typ [ // it is an actual type and not a ref
TODO:
#typ
] else {
let name = typ.at("$ref").split("/").last() // "$ref" stores the whole path, so i get the last one
ref(label(name))
}
}
there is an error on ref(label(name)):
is there a way of doing this? is it just not allowed?
Project link: Typst
