Defense Schemas
Defense Schemas let you ingest an OpenAPI 3.x or Swagger 2.0 specification for any proxy host. Aegis parses the spec and auto-generates a set of per-endpoint defense rules that define what is structurally allowed — valid paths, HTTP methods, content-types, parameter names and types, and JSON request body shape. Requests that don’t conform to the schema are blocked or logged depending on the enforcement mode. Defense schema rules are separate from WAF rules. WAF rules detect malicious payloads within requests. Defense schema rules define what a valid request looks like in the first place. Both systems run — defense schemas enforce structure, WAF rules enforce content.
How It Works
- You upload an OpenAPI or Swagger spec (file or URL)
- Aegis parses the spec, walks every endpoint, and generates a defense rule per path+method
- Rules are stored in SQLite and compiled into a fast lookup map during reload
- At request time, Aegis looks up the path in the map and validates the request against the matched rule
Supported Formats
Both JSON and YAML files are supported. Format is auto-detected by content.
Ingestion

From File
Upload a.json or .yaml spec file through the admin UI. Drag-and-drop or click-to-browse
From URL
Provide an HTTP/HTTPS URL to the spec. Aegis fetches, parses, and stores the spec. The URL is saved so you can refresh the schema later to pick up spec changes. Common spec URLs:/openapi.json/swagger.json/api-docs/v3/api-docs/.well-known/openapi.json
What Gets Extracted
For each endpoint (path + method) in the spec, Aegis generates a defense rule containing:Enforcement Modes
Each defense schema has its own mode, independent of the host’s WAF mode:What Gets Validated
When a request arrives and matches a defense schema endpoint:Options
When Block Undefined Paths is off, requests to paths not covered by the schema pass through to the normal WAF pipeline without defense schema evaluation.
When Strict Body is on, any JSON field in the request body that is not defined in the schema properties is rejected. This prevents attackers from injecting unexpected fields.
Multiple Schemas Per Host
A host can have multiple defense schemas — for example, one per API version or per microservice behind the same domain. When multiple schemas are attached to a host, they stack: the first schema that matches the request path wins. This allows versioned APIs (/api/v1/*, /api/v2/*) to each have their own spec.
Pipeline Position
Defense schema evaluation runs inside the WAF pipeline, after body size checks and before CORS validation:Lifecycle
Creation
- Navigate to the Defense Schemas page
- Click + New Schema
- Choose From URL or From File
- Select the target host and set the enforcement mode
- Upload or enter the URL — Aegis parses the spec and shows the generated rules
- Each endpoint rule can be individually enabled or disabled
Updates
- Refresh (URL sources only): Re-fetch the spec from the original URL, regenerate rules, and preserve per-rule enabled/disabled state
- Mode change: Switch between enforce, detect, and off at any time
- Rule toggle: Enable or disable individual endpoint rules without deleting the schema
Deletion
Deleting a defense schema removes all its rules. This is immediate — no confirmation beyond the delete dialog. Deleting a proxy host cascades to delete all its defense schemas.Relationship to WAF Rules
Both systems are complementary. Defense schemas say “this endpoint expects a POST with a JSON body containing a
name string and an age integer.” WAF rules say “this JSON body contains a SQL injection payload in the name field.” A properly protected host uses both.

