Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket event schema #8218

Merged
merged 14 commits into from Sep 18, 2020
Merged
40 changes: 38 additions & 2 deletions lib/plugins/aws/package/compile/events/websockets/index.js
Expand Up @@ -51,9 +51,45 @@ class AwsCompileWebsockets {
},
};

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8019
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'websocket', {
anyOf: [{ type: 'string' }, { type: 'object' }],
anyOf: [
{ type: 'string' },
{
type: 'object',
properties: {
route: { type: 'string' },
routeResponseSelectionExpression: {
type: 'string',
regexp: /^(?:\$default)$/.toString(),
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
},
authorizer: {
anyOf: [
{ type: 'string' },
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
{
type: 'object',
properties: {
name: { type: 'string' },
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
identitySource: { type: 'array', items: { type: 'string' } },
},
required: ['name'],
additionalProperties: false,
},
{
type: 'object',
properties: {
arn: { type: 'string' },
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
identitySource: { type: 'array', items: { type: 'string' } },
},
required: ['arn'],
additionalProperties: false,
},
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
],
},
},
required: ['route'],
additionalProperties: false,
},
],
});
}
}
Expand Down
14 changes: 14 additions & 0 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -313,6 +313,17 @@ class AwsProvider {
},
],
},
websocket: {
oneOf: [
{ type: 'boolean' },
{
type: 'object',
properties: {
level: { enum: ['INFO', 'ERROR'] },
},
},
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
],
},
},
},
resourcePolicy: {
Expand All @@ -321,6 +332,9 @@ class AwsProvider {
type: 'object',
},
},
websocketsApiName: { type: 'string' },
websocketsApiRouteSelectionExpression: { type: 'string' },
medikoo marked this conversation as resolved.
Show resolved Hide resolved
apiGateway: { type: 'object', properties: { websocketApiId: { type: 'string' } } },
},
},
function: {
Expand Down