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

fix: fix issue of vendor-id being required parameter #86

Merged
merged 4 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/commands/smapi/cli-customization-processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class CliCustomizationProcessor {
* @param {Map} definitions Map with all Swagger definitions.
*/
processParameter(parameter, parentOperation, definitions) {
const customization = customizationMap.get(parameter.name) || {};
parameter.skip = customization.skip || false;
if (parameter.skip) return;

if (parameter.in === 'body') {
this._processBodyParameter(parameter, parentOperation, definitions);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ const appendVendorId = (requestParameters, profile) => {
const { createSkillRequest, createInSkillProductRequest } = requestParameters;
const body = createSkillRequest || createInSkillProductRequest;
const vendorId = AppConfig.getInstance().getVendorId(profile);
if (body && !body.vendorId) {
if (body) {
body.vendorId = vendorId;
} else if (!requestParameters.vendorId) {
} else {
requestParameters.vendorId = vendorId;
}
};
Expand Down
3 changes: 3 additions & 0 deletions lib/commands/smapi/customizations/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"stageV2": {
"name": "stage"
},
"vendorId": {
"skip": true
},
"createSkillRequest": {
"skipUnwrap": true,
"name": "manifest"
Expand Down
11 changes: 11 additions & 0 deletions test/unit/commands/smapi/cli-customization-processor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ describe('Smapi test - CliCustomizationProcessor class', () => {
expect(flatParamsMap.get(key)).eql(expected);
});

it('| should skip processing of parameter', () => {
const parameter = makeParameter();
const skip = true;

sinon.stub(customizationMap, 'get').returns({ skip });

processor.processParameter(parameter, parentOperation, definitions);

expect(parameter.skip).eql(true);
});


it('| should add simple array of non body paramter', () => {
const parameter = makeParameter({ type: 'array' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@ describe('Smapi hook functions test - appendVendorId tests', () => {
expect(requestParameters.vendorId).eql(vendorId);
});

it('| should not append vendor id to requestParameters if already exists', () => {
const existingVendorId = 'some existing vendor id';
const requestParameters = { vendorId: existingVendorId };

appendVendorId(requestParameters, profile);

expect(requestParameters.vendorId).eql(existingVendorId);
});

afterEach(() => {
sinon.restore();
});
Expand Down