Spring, NestJS, Express, and AWS Lambda support
What OpenAPI Guard understands in Spring Boot (Java and Kotlin), NestJS controllers, Express applications, and AWS Lambda route maps.
Documentation pages
Spring Boot (Java and Kotlin)
@RestControllerand@Controllerclasses, class-level@RequestMapping, and@GetMapping,@PostMapping,@PutMapping,@PatchMapping,@DeleteMapping, and@RequestMapping(method = …).- Inheritance: mappings and class-level paths inherited from API interfaces and
base classes in other files, as in openapi-generator’s interface-only and delegate
output. Generated sources under
build/generated,build/generate-resources, andtarget/generated-sourcesare read for this, even though build output is otherwise skipped. - Constants:
static final Stringfields, interface constants, and Kotlinconst val, from any file, joined with+. - Placeholders:
${key}and${key:default}fromapplication.propertiesandapplication.yml(default profile). - Base paths:
server.servlet.context-pathandspring.mvc.servlet.pathare aligned with the contract’sserversURL. - A
@RequestMappingwithoutmethodserves every method; it satisfies operations but is never reported as undocumented. Neither are view-rendering@Controllerhandlers.
NestJS
@Controller, @Get, @Post, @Put, @Patch, and @Delete imported from
@nestjs/common, with literal paths, path arrays, and :id parameters. If the
contract’s paths include a global prefix such as /api, set
stackblender.openApiGuard.implementationPathPrefix to it.
Express
Express applications and routers in TypeScript or JavaScript (ES modules or CommonJS). OpenAPI Guard composes each application with the routers it mounts, across files.
app.get,post,put,patch,delete, andall(every method, never reported as undocumented),router.route(path)chains, and path arrays.:idparameters, parameter patterns (:id(\d+)), optional parameters (:id?), and Express 5 optional groups ({/:id}).- Mounts with
use(path, router), nested routers, routers imported withimportorrequire, and router factories (app.use('/orders', ordersRouter(service))). Middleware such asexpress.json()orcors()is ignored. - A route or prefix computed at run time, or a router that no application in the
workspace mounts, is an analysis limitation. Wildcard (
*) and regular-expression routes are skipped.
JavaScript (.js, .mjs, .cjs) is read for Express, NestJS, and AWS Lambda.
Minified files, compiled output, and test files are skipped.
AWS Lambda (API Gateway)
TypeScript handlers behind an API Gateway HTTP API that dispatch on event.routeKey:
const routes = {
'GET /api/v1/inboxes': listInboxes,
'POST /api/v1/email/draft': createDraft,
};
const route = routes[canonicalRouteKey(event.routeKey)];
switch (canonicalRouteKey(event.routeKey)) {
case 'GET /api/v1/inboxes':
return listInboxes(event);
}
- Route maps: object literals and
new Map([...])keyed byMETHOD /path, including spreads and maps imported from other files of the project. - Dispatch:
switchcases and comparisons such asrouteKey === 'GET /health'. The route key is followed through variables,{ routeKey }, canonicalizer calls, and local dispatcher functions. Keys may be literals, templates, or+ofconststrings. - Aliases: a map from route key to route key, such as
{ 'GET /inboxes': 'GET /api/v1/inboxes' }, or acasethat only returns a route key, declares a legacy route. It is implemented when its target is. ANYroutes satisfy every method on their path and are never undocumented.$default,HEAD, andOPTIONSroutes are ignored, as are test files (*.test.ts,*.spec.ts,__tests__/).
For a router OpenAPI Guard cannot read, declare its routes in an
openapi-guard.routes.json file anywhere in the workspace:
{
"routes": [
"GET /api/v1/inboxes",
{ "route": "POST /api/v1/email/draft", "handler": "createDraft" }
],
"aliases": { "GET /inboxes": "GET /api/v1/inboxes" },
"complete": true
}
"complete": true states that the file lists every route the router serves, so
operations it does not list are reported missing. REST API (v1) payloads that
dispatch on httpMethod and resource are not supported.
Not guessed
Paths computed at run time, unknown placeholders, supertypes that are not in the workspace, and Lambda dispatch that cannot be read are skipped rather than guessed; the operations they could serve are shown as Could not verify, not reported missing. An information diagnostic marks each such place (an analysis limitation).