Skip to content

Commit 59d6479

Browse files
committed
Updates from feedback
1 parent f43173c commit 59d6479

File tree

7 files changed

+36
-14
lines changed

7 files changed

+36
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## 0.1.12 Released on 2018-05-19.
3+
4+
* Added support for readme tags.
25

36
## 0.1.11 Released on 2018-05-14
47

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Options:
2323
-j, --inJson A boolean flag indicating whether output format of the
2424
messages is json. [boolean] [default: true]
2525
-h, --help Show help [boolean]
26+
-o, --oldTagName The tag name for the old specification file. If include it
27+
indicates that the old spec file is a readme file
28+
-n, --newTagName The tag name for the new specification file. If include it
29+
indicates that the new spec file is a readme file
2630
```
2731

2832
## Build dependencies

cli.js

100644100755
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ yargs
2828
describe: `Set the log file path. It must be an absolute filepath. ` +
2929
`By default the logs will stored in a timestamp based log file at "${defaultLogDir}".`
3030
})
31+
.option('o', {
32+
alias: 'oldTagName',
33+
describe: `The tag name for the old specification file. If include it ` +
34+
`indicates that the old spec file is a readme file`
35+
})
36+
.option('n', {
37+
alias: 'newTagName',
38+
describe: `The tag name for the new specification file. If include it ` +
39+
`indicates that the new spec file is a readme file`
40+
})
3141
.global(['h', 'l', 'f'])
3242
.help()
3343
.argv;

lib/commands/oad.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ exports.builder = {
1717
default: true
1818
},
1919
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',
20+
alias: 'oldTagName',
21+
describe: 'The tag name for the old specification file. If include it indicates that the old spec file is a readme file',
2222
},
2323
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',
24+
alias: 'newTagName',
25+
describe: 'The tag name for the new specification file. If include it indicates that the new spec file is a readme file',
2626
}
2727
};
2828

lib/validate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ exports = module.exports;
2121
*
2222
* @param {boolean} [options.matchApiVersion] A boolean flag indicating whether to consider api-version while comparing.
2323
*
24+
* @param {string} [options.oldTagName] Tag name used for autorest with the old specification file.
25+
*
26+
* @param {string} [options.newTagName] Tag name used for autorest with the new specification file.
27+
*
2428
*/
2529
exports.compare = function compare(oldSwagger, newSwagger, options) {
2630
if (!options) options = {};

lib/validators/openApiDiff.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class OpenApiDiff {
2727
*
2828
* @param {boolean} [options.matchApiVersion] A boolean flag indicating whether to consider api-version while comparing.
2929
*
30+
* @param {string} [options.oldTagName] Tag name used for autorest with the old specification file.
31+
*
32+
* @param {string} [options.newTagName] Tag name used for autorest with the new specification file.
33+
*
3034
* @returns {object} OpenApiDiff Returns the configured OpenApiDiff object.
3135
*/
3236
constructor(options) {
@@ -118,6 +122,8 @@ class OpenApiDiff {
118122
*
119123
* @param {string} outputFileName Name of the output file to which autorest outputs swagger-doc.
120124
*
125+
* @param {string} tagName Name of the tag in the specification file.
126+
*
121127
*/
122128
processViaAutoRest(swaggerPath, outputFileName, tagName) {
123129
log.silly(`processViaAutoRest is being called`);
@@ -141,12 +147,9 @@ class OpenApiDiff {
141147

142148
let outputFolder = os.tmpdir();
143149
let outputFilePath = path.join(outputFolder, `${outputFileName}.json`);
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-
}
150+
var autoRestCmd = tagName
151+
? `${self.autoRestPath()} ${swaggerPath} --tag=${tagName} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`
152+
: `${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`;
150153

151154
log.debug(`Executing: "${autoRestCmd}"`);
152155

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ 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 &&
128-
previousDefinition.Info != null &&
129-
Info.Version != null &&
130-
previousDefinition.Info.Version != null)
127+
if (Info?.Version != null &&
128+
previousDefinition.Info?.Version != null)
131129
{
132130
context.PushProperty("info");
133131
context.PushProperty("version");

0 commit comments

Comments
 (0)