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

Lifecycle rules #112

Merged
merged 4 commits into from
Dec 10, 2021
Merged

Lifecycle rules #112

merged 4 commits into from
Dec 10, 2021

Conversation

smizell
Copy link
Contributor

@smizell smizell commented Dec 8, 2021

This adds a rule for ensuring the sunset rules are followed.

  • If there is no deprecatedBy, then it fails saying it should be deprecated first
  • If there is a deprecatedBy, it will check the dates to make sure it's been long enough

@smizell smizell requested a review from a team as a code owner December 8, 2021 21:58
src/rulesets/api-lifeycle.ts Show resolved Hide resolved
src/dsl.ts Show resolved Hide resolved
it("fails when the schedule isn't met", async () => {
const result = await compare(baseOpenAPI)
.to((spec) => {
spec.info.title = "Empty";
Copy link
Contributor

Choose a reason for hiding this comment

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

What if I compare a non-empty OpenAPI spec that happens to have the info.title "Empty"? Is there a more robust way to express this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Per side-channel discussion, a special-use extension would be best here, to make a precise distinction between content and processing metadata. So maybe spec.extensions['x-optic-ci-empty-spec'] = true or something to that effect? We can then lay claim to all extensions x-optic-ci-*.

While I'll admit an API called "Empty" is really unlikely (or is it... maybe it's a placeholder name used for a generated template OpenAPI, a mock, or "empty.io", the service that stares back when you stare into the void for too long!), for me it's more about providing a precise contract & behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm all for it, @smizell gave me write permissions on this PR, I'll make the change today

Copy link
Contributor

Choose a reason for hiding this comment

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

waiting on a library release to get this out. We're also bundling some performance fixes for bulk-mode and compare.

@acunniffe
Copy link
Contributor

Resolved conflicts (sorry hadn't seen that pop up).

We're going to fix the spec.extensions['x-optic-ci-empty-spec'] = true w/ the next library rollout. This should be good to go

@cmars cmars merged commit 8e07a0b into snyk:optic-main Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants