Skip to content

Commit f43173c

Browse files
committed
Add readme tag support
1 parent 720b650 commit f43173c

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

lib/commands/oad.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ exports.builder = {
1515
describe: 'A boolean flag indicating whether output format of the messages is json.',
1616
boolean: true,
1717
default: true
18+
},
19+
o: {
20+
alias: 'old-tag-name',
21+
describe: 'The tag name for the readme. If include also indicates that the old spec file is a readme file',
22+
},
23+
n: {
24+
alias: 'new-tag-name',
25+
describe: 'The tag name for the readme. If include also indicates that the old spec file is a readme file',
1826
}
1927
};
2028

@@ -26,6 +34,8 @@ exports.handler = function (argv) {
2634
vOptions.consoleLogLevel = argv.logLevel;
2735
vOptions.logFilepath = argv.f;
2836
vOptions.json = argv.j;
37+
vOptions.oldTagName = argv.o;
38+
vOptions.newTagName = argv.n;
2939

3040
return validate.compare(oldSpec, newSpec, vOptions).then((result) => {
3141
console.log(result);

lib/validators/openApiDiff.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class OpenApiDiff {
5656
log.silly(`compare is being called`);
5757

5858
let self = this;
59-
var promise1 = self.processViaAutoRest(oldSwagger, 'old');
60-
var promise2 = self.processViaAutoRest(newSwagger, 'new');
59+
var promise1 = self.processViaAutoRest(oldSwagger, 'old', self.options.oldTagName);
60+
var promise2 = self.processViaAutoRest(newSwagger, 'new', self.options.newTagName);
6161

6262
return Promise.all([promise1, promise2]).then(results => {
6363
return self.processViaOpenApiDiff(results[0], results[1]);
@@ -119,7 +119,7 @@ class OpenApiDiff {
119119
* @param {string} outputFileName Name of the output file to which autorest outputs swagger-doc.
120120
*
121121
*/
122-
processViaAutoRest(swaggerPath, outputFileName) {
122+
processViaAutoRest(swaggerPath, outputFileName, tagName) {
123123
log.silly(`processViaAutoRest is being called`);
124124

125125
let self = this;
@@ -141,7 +141,12 @@ class OpenApiDiff {
141141

142142
let outputFolder = os.tmpdir();
143143
let outputFilePath = path.join(outputFolder, `${outputFileName}.json`);
144-
let autoRestCmd = `${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`;
144+
var autoRestCmd;
145+
if(tagName) {
146+
autoRestCmd = `${self.autoRestPath()} ${swaggerPath} --tag=${tagName} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`;
147+
}else {
148+
autoRestCmd = `${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`;
149+
}
145150

146151
log.debug(`Executing: "${autoRestCmd}"`);
147152

openapi-diff/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ public override IEnumerable<ComparisonMessage> Compare(ComparisonContext context
124124
if (previousDefinition == null)
125125
throw new ArgumentException("Comparing a service definition with something else.");
126126

127-
if (Info != null && previousDefinition.Info != null)
127+
if (Info != null &&
128+
previousDefinition.Info != null &&
129+
Info.Version != null &&
130+
previousDefinition.Info.Version != null)
128131
{
129132
context.PushProperty("info");
130133
context.PushProperty("version");

0 commit comments

Comments
 (0)