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
4 changes: 4 additions & 0 deletions lib/configSchema.js
Expand Up @@ -116,6 +116,10 @@ const schema = {
type: 'string',
pattern: '^[A-Z0-9_]+$',
},
functionName: {
type: 'string',
pattern: functionNamePattern,
},
},
};

Expand Down
32 changes: 30 additions & 2 deletions lib/plugins/aws/package/compile/events/websockets/index.js
Expand Up @@ -51,9 +51,37 @@ 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',
},
authorizer: {
anyOf: [
{ $ref: '#/definitions/awsArnString' },
{ $ref: '#/definitions/functionName' },
{
type: 'object',
properties: {
name: { $ref: '#/definitions/functionName' },
arn: { $ref: '#/definitions/awsArnString' },
identitySource: { type: 'array', items: { type: 'string' } },
},
oneOf: [{ required: ['name'] }, { required: ['arn'] }],
additionalProperties: false,
},
],
},
},
required: ['route'],
additionalProperties: false,
},
],
});
}
}
Expand Down
15 changes: 15 additions & 0 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -313,6 +313,18 @@ class AwsProvider {
},
],
},
websocket: {
oneOf: [
{ type: 'boolean' },
{
type: 'object',
properties: {
level: { enum: ['INFO', 'ERROR'] },
},
additionalProperties: false,
},
rzaldana marked this conversation as resolved.
Show resolved Hide resolved
],
},
},
},
resourcePolicy: {
Expand All @@ -321,6 +333,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