RapiDoc
RapiDoc copied to clipboard
RapiDoc 9.3.4 cannot render schema including nested `patternProperties`
In relation to the newly-introduced support to patternProperties (ref. #839), if a schema contains nested patternProperties declarations, a JS runtime exception occurs when trying to render the schema itself (regardless the picked style, table or tree).
Console error (Chrome):
rapidoc-min.js:2 Uncaught (in promise) RangeError: Maximum call stack size exceeded
at We (rapidoc-min.js:2:50316)
at ie.generateTree (schema-table.js:312:1)
at schema-table.js:242:1
at Array.map (<anonymous>)
at ie.generateTree (schema-table.js:241:1)
at schema-table.js:242:1
at Array.map (<anonymous>)
at ie.generateTree (schema-table.js:241:1)
at schema-table.js:242:1
at Array.map (<anonymous>)
Full HTML example code:
<!doctype html>
<html>
<head>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/rapidoc-min.js" charset="UTF-8"></script>
</head>
<body>
<rapi-doc render-style="read" schema-style="table" default-schema-tab="schema"></rapi-doc>
<script>
document.addEventListener('DOMContentLoaded', (event) => {
let docEl = document.querySelector('rapi-doc');
let objSpec = {
"openapi": "3.0.3",
"servers": [{
"url": "https://localhost:8080"
}],
"tags": [{
"name": "Test"
}],
"paths": {
"/test": {
"get": {
"summary": "Test",
"tags": [ "Test" ],
"operationId": "test",
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"props": {
"type": "object",
"patternProperties": {
"^[a-z0-9-_]+$": {
"type": "object",
"patternProperties": {
"^[a-z_]+$": {
"type": "string"
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
},
"required": ["props"],
"additionalProperties": false
},
"example": {
"props": {
"fruit_1": {
"apple": "Apples",
"pear": "Pears"
},
"vegetables_2": {
"salad": "Salad"
},
"herbs_3": {
"basil": "Basil"
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {},
"responses": {},
"parameters": {}
}
};
docEl.loadSpec(objSpec);
});
</script>
</body>
at the moment patternProperties can be applied to only basic data-types like string, integer etc and not to the complex type like object and array.
We will look into supporting it. But i am also open for a PR on this
Got it, thanks.
In the meantime, would it be possible to have this partial support to not compromise the rendering of the whole schema?
I'd say a "blank" would suffice (just like for versions up to 9.3.3, where no type is displayed), but so at least we could have all the latest features (e.g. support for const).
Hi I bumped into this myself…
I need it to display our OpenAPI schema which is indeed a bit complex.
@alexgarel @ilPittiz I'm curious, do other explorers work out of the box already for this, have you tried some of the other ones on openapi.tools or do they all suffer similar problems?