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

test(oas): reduce the amount of boilerplate #1472

Merged
merged 4 commits into from
Jan 13, 2021

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Jan 12, 2021

Extracted from #1470
Related to #1082

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

@P0lip P0lip added the chore label Jan 12, 2021
@P0lip P0lip self-assigned this Jan 12, 2021
@P0lip P0lip force-pushed the test/reduce-boilerplate-in-oas-tests branch from 1d772fa to a4e1c24 Compare January 12, 2021 19:00
@P0lip P0lip requested review from philsturgeon and a team January 12, 2021 19:00
@P0lip P0lip enabled auto-merge (squash) January 12, 2021 19:00
@P0lip P0lip force-pushed the test/reduce-boilerplate-in-oas-tests branch from 73d723b to 72b8cf0 Compare January 12, 2021 23:11
@P0lip P0lip mentioned this pull request Jan 12, 2021
4 tasks
Copy link
Contributor

@domagojk domagojk left a comment

Choose a reason for hiding this comment

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

Other than naming comment, seems good 👍

Btw is the reason for adding props like openapi: '3.0.2' requried so that isOpenApiv2/isOpenApiv3 can work?

import { isOpenApiv2, isOpenApiv3 } from '../../../../formats';
import * as ruleset from '../../index.json';

export async function loadRules(rules: (keyof typeof ruleset['rules'])[], opts?: IConstructorOpts): Promise<Spectral> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe call it createWithRules (or something similar) since it doesn't just load the rules?

@P0lip
Copy link
Contributor Author

P0lip commented Jan 13, 2021

Btw is the reason for adding props like openapi: '3.0.2' requried so that isOpenApiv2/isOpenApiv3 can work?

Yeah, isOpenApiv2 and isOpenApiv3 are used to determine whether given document is of particular format.
isOpenApiv2 looks for swagger: 2.0., while the latter searches for openapi.
This is similar to how spec works in Studio. We have a similar detection there.

@P0lip P0lip requested a review from domagojk January 13, 2021 16:10
@P0lip P0lip merged commit 85242a7 into develop Jan 13, 2021
@P0lip P0lip deleted the test/reduce-boilerplate-in-oas-tests branch January 13, 2021 17:28
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.

2 participants