Skip to content

Commit

Permalink
remove option
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Oct 9, 2023
1 parent afe9d47 commit 00c8a44
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
1 change: 0 additions & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type ConvertV2ToV3Options = {
useChannelIdExtension?: boolean;
convertServerComponents?: boolean;
convertChannelComponents?: boolean;
failOnParameterReference?: boolean;
}
export type ConvertOptions = {
v2tov3?: ConvertV2ToV3Options;
Expand Down
6 changes: 1 addition & 5 deletions src/third-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,7 @@ function convertParameter(parameter: any, options: RequiredConvertV2ToV3Options)
}

if(parameter.schema?.$ref) {
const errorMessage = 'Could not convert parameter object because the `.schema` property was a reference. This have to be changed manually if you want any of the properties included. The reference was ' + parameter.schema?.$ref;
if(options.failOnParameterReference === true) {
throw new Error(errorMessage);
}
console.error(errorMessage);
console.error('Could not convert parameter object because the `.schema` property was a reference. This have to be changed manually if you want any of the properties included. The reference was ' + parameter.schema?.$ref);
}

const enumValues = parameter.schema?.enum ?? null;
Expand Down
7 changes: 1 addition & 6 deletions test/second-to-third-version.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,10 @@ describe('convert() - 2.X.X to 3.X.X versions', () => {
assertResults(output, result);
});

it('should throw exception when parameter encountered with failOnParameterReference=true', () => {
const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0-with-reference-parameter.yml'), 'utf8');
expect(() => {convert(input, '3.0.0', {v2tov3: {failOnParameterReference: true}})}).toThrowError('Could not convert parameter object because the `.schema` property was a reference. This have to be changed manually if you want any of the properties included. The reference was #/components/schemas/sentAt');
});

it('should handle parameter object', () => {
const input = fs.readFileSync(path.resolve(__dirname, 'input', '2.6.0', 'for-3.0.0-with-reference-parameter.yml'), 'utf8');
const output = fs.readFileSync(path.resolve(__dirname, 'output', '3.0.0', 'from-2.6.0-with-reference-parameter.yml'), 'utf8');
const result = convert(input, '3.0.0', {v2tov3: {failOnParameterReference: false}});
const result = convert(input, '3.0.0');
assertResults(output, result);
});
});

0 comments on commit 00c8a44

Please sign in to comment.