-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b59ceda
commit 5667936
Showing
3 changed files
with
133 additions
and
113 deletions.
There are no files selected for viewing
This file contains 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 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,37 @@ | ||
import { RuleType, Spectral } from '../../../spectral'; | ||
import testParameterDescription from '../../__tests__/shared/_parameter-description'; | ||
import * as ruleset from '../index.json'; | ||
|
||
describe('oas2-parameter-description', () => { | ||
const s = new Spectral(); | ||
|
||
s.setRules({ | ||
'oas2-parameter-description': Object.assign(ruleset.rules['oas2-parameter-description'], { | ||
recommended: true, | ||
type: RuleType[ruleset.rules['oas2-parameter-description'].type], | ||
}), | ||
}); | ||
|
||
testParameterDescription(s); | ||
|
||
test('return errors if shared level parameter description is missing', async () => { | ||
const results = await s.run({ | ||
swagger: '2.0', | ||
parameters: { | ||
limit: { | ||
name: 'limit', | ||
in: 'query', | ||
type: 'integer', | ||
}, | ||
}, | ||
}); | ||
expect(results).toEqual([ | ||
expect.objectContaining({ | ||
code: 'oas2-parameter-description', | ||
message: 'Parameter objects should have a `description`.', | ||
path: ['parameters', 'limit'], | ||
severity: 1, | ||
}), | ||
]); | ||
}); | ||
}); |
This file contains 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,94 @@ | ||
import { RuleType, Spectral } from '../../../spectral'; | ||
import testParameterDescription from '../../__tests__/shared/_parameter-description'; | ||
import * as ruleset from '../index.json'; | ||
|
||
describe('oas3-parameter-description', () => { | ||
const s = new Spectral(); | ||
|
||
s.setRules({ | ||
'oas3-parameter-description': Object.assign(ruleset.rules['oas3-parameter-description'], { | ||
recommended: true, | ||
type: RuleType[ruleset.rules['oas3-parameter-description'].type], | ||
}), | ||
}); | ||
|
||
testParameterDescription(s); | ||
|
||
describe('$.components.parameters', () => { | ||
it('validates description', async () => { | ||
const results = await s.run({ | ||
openapi: '3.0.2', | ||
components: { | ||
parameters: { | ||
address: { | ||
in: 'body', | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(results).toEqual([ | ||
expect.objectContaining({ | ||
code: 'oas3-parameter-description', | ||
message: 'Parameter objects should have a `description`.', | ||
path: ['components', 'parameters', 'address'], | ||
severity: 1, | ||
}), | ||
]); | ||
}); | ||
}); | ||
|
||
describe('description for parameters in links', () => { | ||
describe('$.components.links', () => { | ||
it('does not validate description', async () => { | ||
const results = await s.run({ | ||
openapi: '3.0.2', | ||
components: { | ||
links: { | ||
address: { | ||
operationId: 'getUserAddressByUUID', | ||
parameters: { | ||
param: { | ||
value: 'value', | ||
in: 'header', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(results).toEqual([]); | ||
}); | ||
}); | ||
|
||
describe('links in a response', () => { | ||
it('does not validate description', async () => { | ||
const results = await s.run({ | ||
paths: { | ||
'/pets': { | ||
get: { | ||
responses: { | ||
'200': { | ||
links: { | ||
abc: { | ||
parameters: { | ||
param: { | ||
in: 'body', | ||
val: 2, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(results).toEqual([]); | ||
}); | ||
}); | ||
}); | ||
}); |