BaseOpenAPIRoute
BaseOpenAPIRoute exposes the OpenAPI specification that service-core builds automatically from your @Route/@Get/@Post/etc. decorated
classes and the @Summary/@Description/@Returns documentation decorators on them, as an interactive Swagger UI page, and as raw JSON or YAML.
import { BaseOpenAPIRoute, RouteDecorators } from "@rapidrest/service-core";
const { Route } = RouteDecorators;
@Route("/openapi")
export class OpenAPIRoute extends BaseOpenAPIRoute {}
The CLI scaffold generates exactly this at src/routes/OpenAPIRoute.ts, mounted at /openapi.
Endpoints
| Function | HTTP Method + Path | What it does |
|---|---|---|
getHTML | GET /openapi | Swagger UI, rendered from an inline HTML page that loads swagger-ui-dist from a CDN (no npm dependency required). |
getJSON | GET /openapi/json | The raw OpenAPI specification as JSON. |
getYAML | GET /openapi/yaml | The raw OpenAPI specification as YAML. |
None of the three endpoints requires authentication by default. Treat the specification as public unless your API itself is private, in which case
apply @Auth or @Protect to the subclass the same way you would for any other route.
What ends up in the spec
The specification is assembled from the same decorators you're already using to define routes. There's no separate schema to maintain:
@Route,@Get,@Post,@Put,@Delete, etc. determine the paths and HTTP methods.@Summaryand@Descriptionpopulate each operation's summary and description.@Returnsdocuments the response shape.@Modeland your persistence-layer model classes (see Models & Persistence) contribute the request/response schemas.
Because generation happens from live code rather than hand-maintained annotations, the spec /openapi serves is always in sync with the routes
actually registered on the running server.