-
Couldn't load subscription status.
- Fork 42
Add readme tag support #115
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
Changes from all commits
f43173c
59d6479
52b3aea
932c74d
38ceb2d
0997434
a3db030
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 |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| # Changelog | ||
| ## 0.1.12 Released on 2018-05-19. | ||
|
|
||
| * Added support for readme tags. | ||
|
|
||
| ## 0.1.11 Released on 2018-05-14 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,67 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See License.txt in the project root for license information. | ||
|
|
||
| 'use strict'; | ||
| const log = require('../util/logging'), | ||
| validate = require('../validate'); | ||
| "use strict"; | ||
| const log = require("../util/logging"), | ||
| validate = require("../validate"); | ||
|
|
||
| exports.command = 'compare <old-spec> <new-spec>'; | ||
| exports.command = "compare <old-spec> <new-spec>"; | ||
|
|
||
| exports.describe = 'Compares old and new open api specification for breaking changes.'; | ||
| exports.describe = | ||
| "Compares old and new open api specification for breaking changes."; | ||
|
|
||
| exports.builder = { | ||
| j: { | ||
| alias: 'inJson', | ||
| describe: 'A boolean flag indicating whether output format of the messages is json.', | ||
| alias: "inJson", | ||
| describe: | ||
| "A boolean flag indicating whether output format of the messages is json.", | ||
| boolean: true, | ||
| default: true | ||
| }, | ||
| o: { | ||
| alias: "oldTagName", | ||
| describe: | ||
| "The tag name for the old specification file. If included it indicates that the old spec file is a readme file" | ||
| }, | ||
| n: { | ||
| alias: "newTagName", | ||
| describe: | ||
| "The tag name for the new specification file. If included it indicates that the new spec file is a readme file" | ||
| } | ||
| }; | ||
|
|
||
| exports.handler = function (argv) { | ||
| exports.handler = function(argv) { | ||
| log.debug(argv); | ||
| let oldSpec = argv.oldSpec; | ||
| let oldTag = argv.o; | ||
| let newSpec = argv.newSpec; | ||
| let newTag = argv.n; | ||
| let vOptions = {}; | ||
| vOptions.consoleLogLevel = argv.logLevel; | ||
| vOptions.logFilepath = argv.f; | ||
| vOptions.json = argv.j; | ||
|
|
||
| return validate.compare(oldSpec, newSpec, vOptions).then((result) => { | ||
| console.log(result); | ||
| }).catch(err => { | ||
| console.log(err); | ||
| process.exitCode = 1; | ||
| }); | ||
| } | ||
| let compareFunc; | ||
| if (oldTag && newTag) { | ||
| compareFunc = validate.compareTags( | ||
| oldSpec, | ||
| oldTag, | ||
| newSpec, | ||
| newTag, | ||
| vOptions | ||
| ); | ||
| } else { | ||
| compareFunc = validate.compare(oldSpec, newSpec, vOptions); | ||
| } | ||
|
|
||
| return compareFunc | ||
| .then(result => { | ||
| console.log(result); | ||
| }) | ||
| .catch(err => { | ||
| console.log(err); | ||
| process.exitCode = 1; | ||
| }); | ||
| }; | ||
|
|
||
| exports = module.exports; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,13 +51,17 @@ class OpenApiDiff { | |
| * | ||
| * @param {string} newSwagger Path to the new specification file. | ||
| * | ||
| * @param {string} oldTag Tag name used for autorest with the old specification file. | ||
| * | ||
| * @param {string} newTag Tag name used for autorest with the new specification file. | ||
| * | ||
| */ | ||
| compare(oldSwagger, newSwagger) { | ||
| compare(oldSwagger, newSwagger, oldTag, newTag) { | ||
| log.silly(`compare is being called`); | ||
|
|
||
| let self = this; | ||
| var promise1 = self.processViaAutoRest(oldSwagger, 'old'); | ||
| var promise2 = self.processViaAutoRest(newSwagger, 'new'); | ||
| var promise1 = self.processViaAutoRest(oldSwagger, 'old', oldTag); | ||
| var promise2 = self.processViaAutoRest(newSwagger, 'new', newTag); | ||
|
|
||
| return Promise.all([promise1, promise2]).then(results => { | ||
| return self.processViaOpenApiDiff(results[0], results[1]); | ||
|
|
@@ -118,8 +122,10 @@ class OpenApiDiff { | |
| * | ||
| * @param {string} outputFileName Name of the output file to which autorest outputs swagger-doc. | ||
| * | ||
|
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. missing comment for new param 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. Done #Closed |
||
| * @param {string} tagName Name of the tag in the specification file. | ||
| * | ||
| */ | ||
| processViaAutoRest(swaggerPath, outputFileName) { | ||
| processViaAutoRest(swaggerPath, outputFileName, tagName) { | ||
| log.silly(`processViaAutoRest is being called`); | ||
|
|
||
| let self = this; | ||
|
|
@@ -141,7 +147,9 @@ class OpenApiDiff { | |
|
|
||
| let outputFolder = os.tmpdir(); | ||
| let outputFilePath = path.join(outputFolder, `${outputFileName}.json`); | ||
| let autoRestCmd = `${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`; | ||
| var autoRestCmd = tagName | ||
| ? `${self.autoRestPath()} ${swaggerPath} --tag=${tagName} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}` | ||
| : `${self.autoRestPath()} --input-file=${swaggerPath} --output-artifact=swagger-document.json --output-file=${outputFileName} --output-folder=${outputFolder}`; | ||
|
|
||
| log.debug(`Executing: "${autoRestCmd}"`); | ||
|
|
||
|
|
||
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.
since this will always be a Readme, maybe we can name it something like
oldReadmenewReadmeThere 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.
Lets look at this in a subsequent checkin.