Skip to content

feat(rulesets): add oas3_1-servers-in-webhook and oas3_1-callbacks-in…#2581

Merged
mnaumanali94 merged 8 commits into
developfrom
feat/rulesets/oas3_1-webhooks
May 3, 2024
Merged

feat(rulesets): add oas3_1-servers-in-webhook and oas3_1-callbacks-in…#2581
mnaumanali94 merged 8 commits into
developfrom
feat/rulesets/oas3_1-webhooks

Conversation

@kaylachun

@kaylachun kaylachun commented Jan 22, 2024

Copy link
Copy Markdown
Contributor

…-webhook rules

Fixes #[ISSUE_NUMBER].

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

If indicated yes above, please describe the breaking change(s).

Remove this quote before creating the PR.

Screenshots

If applicable, add screenshots or gifs to help demonstrate the changes. If not applicable, remove this screenshots section before creating the PR.

Additional context

Added two new spectral rules:

  • oas3_1-servers-in-webhook
    • warns if servers is defined in a webhook
  • oas3_1-callbacks-in-webhook
    • warns if callbacks is defined in webhook operation

@kaylachun kaylachun marked this pull request as ready for review January 22, 2024 19:34
@kaylachun kaylachun requested review from a team as code owners January 22, 2024 19:34
Comment thread packages/rulesets/src/oas/index.ts Outdated
message: 'Servers should not be defined in a webhook.',
formats: [oas3_1],
recommended: true,
given: ['$.webhooks.servers'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we want this inside of the webhook operation, not at the webhooks object

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh okay servers can be defined on both. Should the warning only be at the webhook operation level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reading through the oas docs and it seems like we should be showing a warning at both levels (the servers array at the path item object level would apply to all operations and servers at the operation level is for that operation only)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok added that here fb14f54

recommended: true,
given: ['$.webhooks[*][*].callbacks'],
then: {
function: undefined,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these required?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to the function: undefined part? That function is checking if callbacks is undefined and if it's not then it'll show the warning.

@kaylachun kaylachun force-pushed the feat/rulesets/oas3_1-webhooks branch from cea7030 to 0f2b9a4 Compare January 23, 2024 16:52
@P0lip P0lip force-pushed the develop branch 3 times, most recently from dc90b7a to c22f408 Compare April 4, 2024 13:29
@mnaumanali94 mnaumanali94 enabled auto-merge (squash) May 3, 2024 14:18
@mnaumanali94 mnaumanali94 merged commit 7a8cc0e into develop May 3, 2024
@mnaumanali94 mnaumanali94 deleted the feat/rulesets/oas3_1-webhooks branch May 3, 2024 14:44
@stoplight-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.19.0 🎉

The release is available on @stoplight/spectral-rulesets-1.19.0

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants