-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: add security field at the operation level #505
Changes from 1 commit
aaf0dcb
131d811
dbdd2bb
4f2e05b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const Base = require('./base'); | ||
|
||
/** | ||
* Implements functions to deal with a OperationSecurityRequirement object. | ||
* @class | ||
* @alias module:@asyncapi/parser#OperationSecurityRequirement | ||
* @extends Base | ||
* @returns {OperationSecurityRequirement} | ||
*/ | ||
class OperationSecurityRequirement extends Base { | ||
} | ||
|
||
module.exports = OperationSecurityRequirement; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const { expect } = require('chai'); | ||
const js = { summary: 't', description: 'test', traits: [{bindings: {kafka: {clientId: 'my-app-id'}}}], operationId: 'test', tags: [{name: 'tag1'}], externalDocs: { url: 'somewhere' }, bindings: { amqp: { test: true } }, message: { test: true }, 'x-test': 'testing' }; | ||
const js = { summary: 't', description: 'test', traits: [{bindings: {kafka: {clientId: 'my-app-id'}}}], operationId: 'test', tags: [{name: 'tag1'}], externalDocs: { url: 'somewhere' }, bindings: { amqp: { test: true } }, message: { test: true }, 'x-test': 'testing', security: [{ oauth2: ['user:read'] }]}; | ||
|
||
const Operation = require('../../lib/models/operation'); | ||
|
||
|
@@ -122,4 +122,15 @@ describe('Operation', function() { | |
assertMixinSpecificationExtensionsInheritance(Operation); | ||
}); | ||
}); | ||
|
||
describe('#security()', function() { | ||
it('should return an array of security requirements objects', function() { | ||
const d = new Operation(js); | ||
expect(Array.isArray(d.security())).to.equal(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to test that the array is not empty. Otherwise, in the case it is empty, the logic inside the following There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @smoya Thanks for the review! I have incorporated the suggestion. |
||
d.security().forEach((s, i) => { | ||
expect(s.constructor.name).to.equal('OperationSecurityRequirement'); | ||
expect(s.json()).to.equal(js.security[i]); | ||
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 where is this defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc should be generated automatically iirc.
Indeed
OperationSecurityRequirement
is not the method you declared, butSecurity
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @fmvilas and @smoya
If its generated automatically, would you suggest reverting my changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind trying
npm run docs
? This command should build the right API doc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole PR is ok, just delete the above and I can accept :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@smoya @magicmatatjahu I deleted my changes to the API doc and regenerated it using the above command.