From efd41161e2fa33d8a333bfc43df4372f3d656d17 Mon Sep 17 00:00:00 2001 From: Matatjahu Date: Fri, 8 Apr 2022 11:24:58 +0200 Subject: [PATCH] feat(rulesets): fix docs --- docs/reference/asyncapi-rules.md | 4 ++-- .../functions/asyncApi2ChannelParameters.ts | 10 +++++++++- .../asyncapi/functions/asyncApi2ServerVariables.ts | 13 ++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/reference/asyncapi-rules.md b/docs/reference/asyncapi-rules.md index 260d4c50c..768b9c4ae 100644 --- a/docs/reference/asyncapi-rules.md +++ b/docs/reference/asyncapi-rules.md @@ -24,7 +24,7 @@ Keep trailing slashes off of channel names, as it can cause some confusion. Most **Recommended:** Yes -### asyncapi-channel-parameters-defined +### asyncapi-channel-parameters All channel parameters should be defined in the `parameters` object of the channel. They should also not contain redundant parameters that do not exist in the channel address. @@ -294,7 +294,7 @@ Server URL should not point at example.com. **Recommended:** No -### asyncapi-server-variables-defined +### asyncapi-server-variables All server URL variables should be defined in the `variables` object of the server. They should also not contain redundant variables that do not exist in the server address. diff --git a/packages/rulesets/src/asyncapi/functions/asyncApi2ChannelParameters.ts b/packages/rulesets/src/asyncapi/functions/asyncApi2ChannelParameters.ts index 24897fc64..4302b33a3 100644 --- a/packages/rulesets/src/asyncapi/functions/asyncApi2ChannelParameters.ts +++ b/packages/rulesets/src/asyncapi/functions/asyncApi2ChannelParameters.ts @@ -8,7 +8,15 @@ import type { IFunctionResult } from '@stoplight/spectral-core'; export default createRulesetFunction<{ parameters: Record }, null>( { - input: null, + input: { + type: 'object', + properties: { + parameters: { + type: 'object', + } + }, + required: ['parameters'], + }, options: null, }, function asyncApi2ChannelParameters(targetVal, _, ctx) { diff --git a/packages/rulesets/src/asyncapi/functions/asyncApi2ServerVariables.ts b/packages/rulesets/src/asyncapi/functions/asyncApi2ServerVariables.ts index 2d7023a9d..e876cced5 100644 --- a/packages/rulesets/src/asyncapi/functions/asyncApi2ServerVariables.ts +++ b/packages/rulesets/src/asyncapi/functions/asyncApi2ServerVariables.ts @@ -8,7 +8,18 @@ import type { IFunctionResult } from '@stoplight/spectral-core'; export default createRulesetFunction<{ url: string; variables: Record }, null>( { - input: null, + input: { + type: 'object', + properties: { + url: { + type: 'string', + }, + variables: { + type: 'object', + } + }, + required: ['url', 'variables'], + }, options: null, }, function asyncApi2ServerVariables(targetVal, _, ctx) {