I'm trying to build some documentation to my project with TypeDoc, Swagger and SwaggerJsDoc. Since TypeDoc and swagger have different annotation types and Swagger annotations are much more detailed I want TypeDoc to read my Swagger annotations. I've managed to tap into TypeDoc's comment parser and successfully created beautiful custom documentation for my code and API combined, like this for example:
I'm pretty exited with this but having a reeeal hard time parsing Swagger's schema definition into plain Javascript objects to show my response or Body examples. Swaggers definitions are too complex, in my opinion. They could be greatly simplified while keeping the same information. They come like this:
{
"type": "object",
"properties": {
"minStockProds": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sku": {
"type": "string"
},
"minStock": {
"type": "number"
},
"ref": {
"type": "string"
}
}
}
},
"ordersCount": {
"type": "number"
}
}
}
Or this!, to be extreme:
{
"type": "object",
"properties": {
"test": {
"type": "object",
"properties": {
"test1": {
"type": "string"
},
"test2": {
"type": "object",
"properties": {
"test3": {
"type": "number"
},
"test4": {
"type": "array",
"items": {
"type": "object",
"properties": {
"test5": {
"type":"string"
},
"test6": {
"type": "number"
}
}
}
}
}
}
}
},
"test7": {
"type":"array",
"items":{
"type": "object",
"properties": {
"name":{
"type": "string"
},
"value": {
"type": "number"
}
}
}
}
}
}
how can I parse it to this?
{
minStockProds: [
{
sku: "string",
minStock: "number",
ref: "string"
}
],
ordersCount: "number",
}
or, this?
{
test: {
test1: "string",
test2: {
test3: "number",
test4: [
{
test5: "string",
test6: "number",
}
]
}
},
test7: [
{
name: "string",
value: "number",
}
]
}
I have tried so many ways to adapt to all these types of object that my code now looks horrible and confusing to display here, it would be an effort to read through it.
Could anyone give a hint or tell a library that could facilitate this for me? no need to resolve this entirely, only looking for options. I've even tried to look into the Swagger-UI package to see how they do it, but still searching for the functions that do it.
Thank you very much!
