-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support for reusable pathItems definitions in components for OAS 3.1 #30
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c9168f1
feat: Added pathItems tests
makeev-pavel 904e5de
feat: Added rules and tests
makeev-pavel 133ee67
feat: Updated tests
makeev-pavel 5331172
feat: Updated tests
makeev-pavel 71a64ab
Merge branch 'develop' into feature/pathItems
makeev-pavel adafe65
feat: updated pathItem rules
makeev-pavel 32ae238
feat: Code review
makeev-pavel 0fb4b4e
feat: Refactoring and added new test
makeev-pavel 74d7d55
feat: Clean
makeev-pavel 911cf93
chore: set dev versions for dependencies
b41ex 9e36d11
chore: merge branch 'develop' into feature/pathItems
b41ex 27888b6
chore: set dev version for dependencies
b41ex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { compareFiles } from '../utils' | ||
| import { diffsMatcher } from '../../helper/matchers' | ||
| import { breaking, DiffAction, nonBreaking } from '../../../src' | ||
|
|
||
| const SUITE_ID = 'path-item' | ||
|
|
||
| const PATH_ITEM_PATH = [ | ||
| 'components', | ||
| 'pathItems', | ||
| 'UserOps', | ||
| ] | ||
|
|
||
| describe('Openapi3.1 PathItems', () => { | ||
|
|
||
| test('Add method in path item', async () => { | ||
| const testId = 'add-method-in-path-item' | ||
| const result = await compareFiles(SUITE_ID, testId) | ||
| expect(result).toEqual(diffsMatcher([ | ||
| expect.objectContaining({ | ||
| action: DiffAction.add, | ||
| afterDeclarationPaths: [[...PATH_ITEM_PATH, 'post']], | ||
| type: nonBreaking, | ||
| }), | ||
| ])) | ||
| }) | ||
|
|
||
| test('Add unused method in path item', async () => { | ||
b41ex marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const testId = 'add-unused-method-in-path-item' | ||
| const result = await compareFiles(SUITE_ID, testId) | ||
| expect(result).toEqual([]) | ||
| }) | ||
|
|
||
| test('Remove method in path item', async () => { | ||
| const testId = 'remove-method-in-path-item' | ||
| const result = await compareFiles(SUITE_ID, testId) | ||
| expect(result).toEqual(diffsMatcher([ | ||
| expect.objectContaining({ | ||
| action: DiffAction.remove, | ||
| beforeDeclarationPaths: [[...PATH_ITEM_PATH, 'post']], | ||
| type: breaking, | ||
| }), | ||
| ])) | ||
| }) | ||
|
|
||
| test('Replace inline path item to ref', async () => { | ||
| const testId = 'replace-inline-path-item-to-ref' | ||
| const result = await compareFiles(SUITE_ID, testId) | ||
| expect(result).toEqual([]) | ||
| }) | ||
|
|
||
| test('Replace ref path item to inline', async () => { | ||
| const testId = 'replace-ref-path-item-to-inline' | ||
| const result = await compareFiles(SUITE_ID, testId) | ||
| expect(result).toEqual([]) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| import { apiDiff, ClassifierType, DiffAction } from '../src' | ||
| import { diffsMatcher } from './helper/matchers' | ||
|
|
||
| const COMPONENTS_RESPONSE_PATH = [ | ||
| 'components', | ||
| 'pathItems', | ||
| 'componentsPathItem', | ||
| 'post', | ||
| 'responses', | ||
| '200', | ||
| ] | ||
|
|
||
| describe('Openapi3.1 Components PathItems Rules', () => { | ||
| test('could be a replace annotation', async () => { | ||
b41ex marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const before = { | ||
| 'openapi': '3.1.0', | ||
| 'paths': { | ||
| '/path1': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 'components': { | ||
| 'pathItems': { | ||
| 'componentsPathItem': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': { | ||
| 'description': 'Pet successfully added', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const after = { | ||
| 'openapi': '3.1.0', | ||
| 'paths': { | ||
| '/path1': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 'components': { | ||
| 'pathItems': { | ||
| 'componentsPathItem': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': { | ||
| 'description': 'new value', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const result = apiDiff(before, after) | ||
| expect(result.diffs).toEqual(diffsMatcher([ | ||
| expect.objectContaining({ | ||
| action: DiffAction.replace, | ||
| beforeValue: 'Pet successfully added', | ||
| afterValue: 'new value', | ||
| beforeDeclarationPaths: [[ | ||
| ...COMPONENTS_RESPONSE_PATH, | ||
| 'description', | ||
| ]], | ||
| afterDeclarationPaths: [[ | ||
| ...COMPONENTS_RESPONSE_PATH, | ||
| 'description', | ||
| ]], | ||
| type: ClassifierType.annotation, | ||
| }), | ||
| ])) | ||
| }) | ||
|
|
||
| test('could be a remove annotation', async () => { | ||
| const before = { | ||
| 'openapi': '3.1.0', | ||
| 'paths': { | ||
| '/path1': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 'components': { | ||
| 'pathItems': { | ||
| 'componentsPathItem': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': { | ||
| 'description': 'Pet successfully added', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const after = { | ||
| 'openapi': '3.1.0', | ||
| 'paths': { | ||
| '/path1': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 'components': { | ||
| 'pathItems': { | ||
| 'componentsPathItem': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': { | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const result = apiDiff(before, after) | ||
| expect(result.diffs).toEqual(diffsMatcher([ | ||
| expect.objectContaining({ | ||
| action: DiffAction.remove, | ||
| beforeValue: 'Pet successfully added', | ||
| beforeDeclarationPaths: [[ | ||
| ...COMPONENTS_RESPONSE_PATH, | ||
| 'description', | ||
| ]], | ||
| type: ClassifierType.annotation, | ||
| }), | ||
| ])) | ||
| }) | ||
| test('could be a add annotation', async () => { | ||
| const before = { | ||
| 'openapi': '3.1.0', | ||
| 'paths': { | ||
| '/path1': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 'components': { | ||
| 'pathItems': { | ||
| 'componentsPathItem': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': { | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const after = { | ||
| 'openapi': '3.1.0', | ||
| 'paths': { | ||
| '/path1': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': {}, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 'components': { | ||
| 'pathItems': { | ||
| 'componentsPathItem': { | ||
| 'post': { | ||
| 'responses': { | ||
| '200': { | ||
| 'description': 'Pet successfully added', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| const result = apiDiff(before, after) | ||
| expect(result.diffs).toEqual(diffsMatcher([ | ||
| expect.objectContaining({ | ||
| action: DiffAction.add, | ||
| afterValue: 'Pet successfully added', | ||
| afterDeclarationPaths: [[ | ||
| ...COMPONENTS_RESPONSE_PATH, | ||
| 'description', | ||
| ]], | ||
| type: ClassifierType.annotation, | ||
| }), | ||
| ])) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.