Large Specs
RapiDoc renders specs with over a thousand operations, but large specs need the right settings. In order of impact:
1. Use view or focused mode
Section titled “1. Use view or focused mode”read mode renders every operation at once. On an 8 MB spec with 1,128 operations it takes about 6 seconds, against about 1 second in view or focused mode (see Render Modes).
<rapi-doc spec-url="/openapi.json" render-style="focused"></rapi-doc>2. Convert Swagger 2.0 ahead of time
Section titled “2. Convert Swagger 2.0 ahead of time”A Swagger 2.0 spec is upgraded to OpenAPI 3.x in the reader’s browser on every page load. For a large spec, convert it once in your build instead:
-
Convert the spec:
npx swagger2openapi swagger.json --outfile openapi.json -
Point RapiDoc at the converted file:
<rapi-doc spec-url="/openapi.json"></rapi-doc>
3. Collapse schemas
Section titled “3. Collapse schemas”By default, schemas start fully expanded. Large, deeply nested schemas render faster when they start collapsed:
<rapi-doc spec-url="/openapi.json" render-style="focused" schema-expand-level="1" default-schema-tab="schema"></rapi-doc>schema-expand-level="1": only the first level of each schema is open; readers expand the rest.default-schema-tab="schema": request and response bodies open on the schema tab instead of the example tab, so example blocks aren’t drawn until a reader opens them.
4. Mind the structure, not just the size
Section titled “4. Mind the structure, not just the size”File size matters less than structure. Long Markdown descriptions cost little; what slows rendering is the number of operations and how large and deeply nested their schemas are once $refs are resolved. A schema referenced by hundreds of operations is rendered once for each of them.