Registry / devops / serverless-aws-response-schema-plugin

serverless-aws-response-schema-plugin

JSON →
library1.1.1jsnpmunverified

Plugin for the Serverless Framework v2/v3 that adds response models to AWS API Gateway REST APIs, enabling automatic documentation generation with possible API responses. Stable version 1.1.1, low release cadence. Differentiators: simple YAML-based configuration within serverless.yml, supports multiple HTTP status codes and content types. Does NOT support HTTP API (only REST API), and does NOT validate responses at runtime. Built for internal use, may not work in all configurations.

npm install serverless-aws-response-schema-plugin
INSTALL
IMPORT
SIG · SERVERLESS-AWS-RES
S
serverless-aws-response-schema-plugin
devopsjavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Plugin
plugins: - serverless-aws-response-schema-plugin
plugins: - serverless-aws-response-schema-plugin - serverless-aws-response-schema-plugin: {}
Plugin is loaded via serverless.yml; no explicit import in code.
responseSchemas
- http: responseSchemas: 200: application/json: ${file(schema.json)}
- http: responseSchema: ...
The property is called responseSchemas (plural). It must be nested under http event.
N/A (no code import)
Not applicable; plugin is configured in serverless.yml
There is no JavaScript/TypeScript import path. All configuration is YAML-based.

Shows how to install the plugin and configure response schemas for API Gateway endpoints in serverless.yml.

// serverless.yml service: my-service plugins: - serverless-aws-response-schema-plugin provider: name: aws runtime: nodejs18.x functions: hello: handler: handler.hello events: - http: path: /hello method: GET responseSchemas: 200: application/json: ${file(schemas/success.json)} 400: application/json: ${file(schemas/error.json)} # schemas/success.json { "$schema": "http://json-schema.org/draft-04/schema#", "title": "SuccessResponse", "type": "object", "properties": { "message": { "type": "string" } } } # schemas/error.json { "$schema": "http://json-schema.org/draft-04/schema#", "title": "ErrorResponse", "type": "object", "properties": { "error": { "type": "string" } } }
Debug
Known issues
gotchaThe plugin only works with REST API provider, not HTTP API. If you're using serverless-http-api or httpApi events, the responseSchemas option will be ignored.
fix
Use REST API (provider:
  name: aws
  apiGateway: ...) or look for an alternative plugin compatible with HTTP API.
affects: all
breakingPlugin peer dependency requires serverless v2 or v3. It does not work with serverless v1 or v4.
fix
Ensure your Serverless Framework version is 2.x or 3.x.
affects: >=1.0.0
gotchaNode version requirement is >=10.0. May not work with older Lambda runtimes or Node 8.x.
fix
Use Node >=10.0 in your development environment and Lambda runtime.
affects: all
Errors
Common errors & fixes
Serverless: Configuration warning at 'functions.hello.events[0].http.responseSchemas': unrecognized property
Plugin not properly loaded in serverless.yml plugins section.
fix
Ensure the plugin is listed under plugins:
  - serverless-aws-response-schema-plugin
Error: The response schema file could not be found: ${file(schemas/schema.json)}
Incorrect file path for the JSON schema file.
fix
Verify the path relative to serverless.yml, e.g., ${file(./schemas/schema.json)} or absolute path.
TypeError: Cannot read property 'get' of undefined
Missing provider configuration or incorrect AWS provider type (HTTP API instead of REST).
fix
Set provider:
  name: aws
  runtime: ...
  apiGateway: ... (if needed).
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
serverlessrequiredpeer dependency required for plugin functionality
Agent activity
7 hits · last 30 days
node
6
Resources
serverless-aws-response-schema-plugin — npm install serverless-aws-response-schema-plugin · libregistry