API Reference
Complete reference for all public classes, functions, and CLI options in the serverpod_swagger package.
Classes
SwaggerUIRoute
Extends Route. Serves the Swagger UI HTML page and the apispec.json file.
SwaggerUIRoute(
Directory projectRoot, {
String mountPath = '/swagger/',
String? customSpecPath,
})ApiSpecRoute
Extends Route. Serves only the apispec.json file. Useful when you want to serve the spec at a different path than the Swagger UI.
ApiSpecRoute(Directory projectRoot)ServerpodSwaggerVersion
Version information for the package.
| Property | Value |
|---|---|
version | '1.0.2' |
minServerpodVersion | '3.4.2' |
Data Models
These classes can be used with generateOpenApiMap for programmatic spec generation.
| Class | Description |
|---|---|
SwaggerSpec | Root object containing a map of endpoints |
SwaggerEndpoint | Named endpoint with a map of methods |
SwaggerMethod | Named method with parameters map and optional returnType |
SwaggerParameter | Parameter with name, type, and isNullable |
Functions
generateOpenApiMap
Map<String, dynamic> generateOpenApiMap(
SwaggerSpec spec, {
String? baseUrl,
Map<String, dynamic>? customInfo,
})Generates an OpenAPI 3.0 JSON map from a SwaggerSpec.
generateOpenApiJson
String generateOpenApiJson(
SwaggerSpec spec, {
String? baseUrl,
Map<String, dynamic>? customInfo,
})Same as above but returns a pretty-printed JSON string.
inferHttpMethod
String inferHttpMethod(String methodName)Returns 'get', 'post', 'patch', or 'delete' based on the method name prefix.
CLI Options
dart run serverpod_swagger:generate [options]See the full CLI options reference for all available flags including --base-url, --auth, --update, and more.