Skip to content

Commit

Permalink
Merge pull request Azure#113 from amarzavery/current
Browse files Browse the repository at this point in the history
Integrating public-current to private-current as of 8/15/2017 9:48 AM PST
  • Loading branch information
amarzavery authored Aug 15, 2017
2 parents 32cb614 + c38a439 commit 3441d1d
Show file tree
Hide file tree
Showing 205 changed files with 30,705 additions and 1,504 deletions.
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,36 @@ The structure of the directory should strictly follow these rules:
The structure should appear like so:
```bash
.
+---automation
| \---resource-manager
| \---Microsoft.Automation
| \---2015-10-31
| \---examples
+---batch
| +---data-plane
| | \---Microsoft.Batch
| | +---2015-12-01.2.2
| | +---2016-02-01.3.0
| | +---2016-07-01.3.1
| | +---2017-01-01.4.0
| | | \---examples
| | \---2017-05-01.5.0
| \---resource-manager
| \---Microsoft.Batch
| +---2015-12-01
| +---2017-01-01
| | \---examples
| \---2017-05-01
| \---examples
+---billing
| \---resource-manager
| \---Microsoft.Billing
| +---2017-02-27-preview
| | \---examples
| \---2017-04-24-preview
| \---examples
└── readme.md
\---specification
| +---automation
| | \---resource-manager
| | \---Microsoft.Automation
| | \---2015-10-31
| | \---examples
| +---batch
| | +---data-plane
| | | \---Microsoft.Batch
| | | +---2015-12-01.2.2
| | | +---2016-02-01.3.0
| | | +---2016-07-01.3.1
| | | +---2017-01-01.4.0
| | | | \---examples
| | | \---2017-05-01.5.0
| | \---resource-manager
| | \---Microsoft.Batch
| | +---2015-12-01
| | +---2017-01-01
| | | \---examples
| | \---2017-05-01
| | \---examples
| +---billing
| \---resource-manager
| \---Microsoft.Billing
| +---2017-02-27-preview
| | \---examples
| \---2017-04-24-preview
| \---examples
\--- readme.md
```

Currently, the specifications are expected to be in Swagger JSON format
Expand All @@ -77,4 +78,3 @@ The next step in the process after a spec is completed is to generate SDKs and A

---
_This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments._

51 changes: 4 additions & 47 deletions documentation/openapi-authoring-automated-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
| [R3017](#R3017) | [GuidUsage](#R3017) |
| [R2057](#R2057) | [InvalidSkuModel](#R2057) |
| [R3010](#R3010) | [TrackedResourceListByImmediateParent](#R3010) |
| [R2061](#R2061) | [ParameterizeProperties](#R2061) |
| [R2004](#R2004) | [NonApplicationJsonType](#R2004) |

### SDK Violations

Expand Down Expand Up @@ -102,7 +102,6 @@ We request OpenAPI(Swagger) spec authoring be assigned to engineers who have an
| [R2066](#R2066) | [PostOperationIdContainsUrlVerb](#R2066) |
| [R2015](#R2015) | [ParameterNotDefinedInGlobalParameters](#R2015) |
| [R1010](#R1010) | [AvoidMSDNReferences](#R1010) |
| [R2004](#R2004) | [NonApplicationJsonType](#R2004) |
| [R2017](#R2017) | [PutRequestResponseScheme](#R2017) |
| [R1009](#R1009) | [DeleteInOperationName](#R1009) |
| [R1005](#R1005) | [GetInOperationName](#R1005) |
Expand Down Expand Up @@ -587,15 +586,13 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul
Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rules](#automated-rules) | [RPC](#rpc-violations): [Errors](#rpc-errors) or [Warnings](#rpc-warnings) | [SDK](#sdk-violations): [Errors](#sdk-errors) or [Warnings](#sdk-warnings)

### <a name="R2004" />R2004 NonApplicationJsonType
**Output Message**: Please make sure that media types other than 'application/json' are supported by your service.
**Output Message**: Only content-type 'application/json' is supported by ARM..

**Description**: Verifies whether operation supports "application/json" as consumes or produces section.

**Why the rule is important**: Per the ARM SDK guidelines, the AutoRest is used to generated the language SDKs. All the supported language generator currently handles "application/json" but some SDKs may support other content-types. This rule is in place to warn the swagger writter that not all the SDKs would work with other content-types.
**Why the rule is important**: Per [ARM SDK guidelines](https://github.com/Azure/azure-resource-manager-rpc/blob/master/v1.0/common-api-details.md#client-request-headers) only content-type 'application/json' is supported.

**How to fix the violation**: Please consult with AutoRest to ensure that the content type desired can be supported.

**Impact on generated code**: If the other than `application/json` type is provided, not all SDKs would support that content-type.
**How to fix the violation**: Make sure to include only 'application/json' in the spec consumes/produces. Make sure your service supports 'application/json'.

**Examples**: N/A

Expand Down Expand Up @@ -1266,46 +1263,6 @@ Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rul

Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rules](#automated-rules) | [RPC](#rpc-violations): [Errors](#rpc-errors) or [Warnings](#rpc-warnings) | [SDK](#sdk-violations): [Errors](#sdk-errors) or [Warnings](#sdk-warnings)

### <a name="R2061" />R2061 ParameterizeProperties
**Output Message**: Type values \"{0}\" have default value(s), please consider parameterizing them

**Description**: Path URLs must be of the form `/subscriptions/{subscriptionId}/providers/<ProviderName>/typename/{typevalue}`, i.e., typevalues must be parameterized.

**Why the rule is important**: Path URLs should follow a consistent pattern across RPs. Consistent URL patterns also ensure determination of a resource from the URL and in turn trigger other resource related rules.

**How to fix the violation**: Parameterize all type values as path parameters.

**Bad Examples**:
```
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/sampleAccount":{
}
```
**Good Examples**:
```
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}":{
"get":{
"parameters": [
{
"$ref": "#/parameters/ResourceGroupName"
},
{
"name": "accountName",
"in": "path",
"required": true,
"type": "string",
"description": "The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.",
"maxLength": 24,
"minLength": 3
},
...
}
}
```

Links: [Index](#index) | [Error vs. Warning](#error-vs-warning) | [Automated Rules](#automated-rules) | [RPC](#rpc-violations): [Errors](#rpc-errors) or [Warnings](#rpc-warnings) | [SDK](#sdk-violations): [Errors](#sdk-errors) or [Warnings](#sdk-warnings)

### <a name="R2063" />R2063 OperationIdNounConflictingModelNames
**Output Message**: OperationId has a noun that conflicts with one of the model names in definitions section. The model name will be disambiguated to '{0}Model'. Consider using the plural form of '{1}' to avoid this. Note: If you have already shipped an SDK on top of this spec, fixing this warning may introduce a breaking change.

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"oav": "^0.4.1",
"js-yaml": "^3.8.2",
"azure-storage": "^2.1.0",
"oad": "^0.1.6"
"@microsoft.azure/literate":"^1.0.21",
"@microsoft.azure/async-io":"^1.0.21",
"@microsoft.azure/polyfill":"^1.0.17",
"oad": "^0.1.7"
},
"homepage": "https://github.com/azure/azure-rest-api-specs",
"repository": {
Expand Down
23 changes: 19 additions & 4 deletions scripts/breaking-change.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ function runOad(oldSpec, newSpec) {
console.log(`New Spec: "${newSpec}"`);
console.log(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`);

return Promise.resolve(oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn', json: true }));
return oad.compare(oldSpec, newSpec, { consoleLogLevel: 'warn', json: true }).then((result) => {
console.log(result);
if (result !== undefined && typeof result.valueOf() === 'string' && result.indexOf(`"type": "Error"`) > -1) {
console.log(`There are potential breaking changes in this PR. Please review before moving forward. Thanks!`);
process.exitCode = 1;
}
return Promise.resolve();
}).catch(err => {
console.log(err);
});
}

/**
Expand Down Expand Up @@ -99,8 +108,13 @@ async function runScript() {
console.dir(resolvedMapForNewSpecs);

for (const swagger of swaggersToProcess) {
let outputFileNameWithExt = path.basename(swagger);
// If file does not exists in the previous commits then we ignore it as it's new file
if (!fs.existsSync(swagger)) {
console.log(`File: "${swagger}" looks to be newly added in this PR.`);
continue;
}

let outputFileNameWithExt = path.basename(swagger);
console.log(outputFileNameWithExt);
if (resolvedMapForNewSpecs[outputFileNameWithExt]) {
await runOad(swagger, resolvedMapForNewSpecs[outputFileNameWithExt]);
Expand All @@ -110,8 +124,9 @@ async function runScript() {

// magic starts here
runScript().then(success => {
process.exit(0);
console.log(`Thanks for using breaking change tool to review.`);
console.log(`If you encounter any issue(s), please open issue(s) at https://github.com/Azure/openapi-diff/issues .`);
}).catch(err => {
console.log(err);
process.exit(1);
process.exitCode = 1;
})
45 changes: 27 additions & 18 deletions scripts/getStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var exec = require('child_process').exec,
utils = require("../test/util/utils");

var swaggersToProcess = utils.swaggers;
var readmesToProcess = utils.readmes;
var finalResult = {};
var filename = `log_${utils.getTimeStamp()}.log`;
var logFilepath = path.join(getLogDir(), filename);
Expand Down Expand Up @@ -50,9 +51,9 @@ function writeContent(content) {
}

//runs the linter on a given swagger spec.
async function runLinter(swagger) {
// TODO: update to use config file... but report grouping is by Swagger right now
let cmd = 'autorest --validation --azure-validator --input-file=' + swagger + ' --message-format=json';
async function runLinter(readme) {
let cmd = 'autorest ' + readme + ' --azure-validator=true --message-format=json';
console.log(cmd);
console.log(`\t- Running Linter.`);
const {err, stdout, stderr } = await new Promise(res => exec(cmd, { encoding: 'utf8', maxBuffer: 1024 * 1024 * 64 },
(err, stdout, stderr) => res({ err: err, stdout: stdout, stderr: stderr })));
Expand All @@ -69,7 +70,7 @@ async function runLinter(swagger) {
//console.log('>>>>>> Parsed Result...');
//console.dir(resultObject, {depth: null, colors: true});
} catch (e) {
console.log(`An error occurred while executing JSON.parse() on the linter output for ${swagger}:`);
console.log(`An error occurred while executing JSON.parse() on the linter output for ${readme}:`);
console.dir(resultString);
console.dir(e, { depth: null, colors: true });
}
Expand All @@ -88,27 +89,35 @@ function runSemanticValidator(swagger) {
});
}

//runs the validation and linting tools on all the swaggers in the repo.
async function runTools(swagger) {
console.log(`Processing "${swagger}":`);
const validationErrors = await runSemanticValidator(swagger);
updateResult(swagger, validationErrors, true);
const linterErrors = await runLinter(swagger);
updateResult(swagger, linterErrors, true);
}

//main function
async function runScript() {
// Useful when debugging a test for a particular swagger.
// Just update the regex. That will return an array of filtered items.
// swaggersToProcess = swaggersToProcess.filter(function (item) {
// return (item.match(/.*arm-network/ig) !== null);
// });
// swaggersToProcess = swaggersToProcess.filter(function (item) {
// return (item.match(/.*Microsoft.network/ig) !== null);
// });
// readmesToProcess = readmesToProcess.filter(function (item) {
// return (item.match(/.*.network/ig) !== null);
// });
createLogFile();
console.log(`The results will be logged here: "${logFilepath}".`);
for (const swagger of swaggersToProcess) {
await runTools(swagger);

for (let swagger of swaggersToProcess) {
const validationErrors = await runSemanticValidator(swagger);
swagger = swagger.split(/\/Microsoft\./gi)[0] + "/readme.md";
console.log(`File Name: "${swagger}"`);
if (validationErrors != null)
{
updateResult(swagger, validationErrors, true);
}
}

for (let readme of readmesToProcess) {
console.log(`Configuration file: "${readme}"`);
const linterErrors = await runLinter(readme);
updateResult(readme, linterErrors, true);
}

//console.dir(finalResult, { depth: null, colors: true });
return finalResult;
}
Expand Down
5 changes: 3 additions & 2 deletions scripts/momentOfTruth.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ async function runScript() {
for (const configFile of configsToProcess) {
await runTools(configFile, 'after');
}
execSync(`${gitCheckoutCmd}`, { encoding: 'utf8' });
execSync(`${gitLogCmd}`, { encoding: 'utf8' });

utils.checkoutTargetBranch();

for (const configFile of configsToProcess) {
await runTools(configFile, 'before');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,6 @@
"modelAsString": true
},
"description": "The name of the Azure pricing tier to which the SKU applies."
},
"capacity": {
"type": "integer",
"minimum": 1,
"maximum": 8,
"default": 1,
"description": "The number of instances in the read only query pool."
}
},
"required": [
Expand All @@ -577,19 +570,6 @@
"backupBlobContainerUri": {
"type": "string",
"description": "The container URI of backup blob."
},
"defaultConnectionMode": {
"type":"string",
"description": "How the read-write server's participation in the query pool is controlled.<br/>It can have the following values: <ul><li>readOnly - indicates that the read-write server is intended not to participate in query operations</li><li>all - indicates that the read-write server can participate in query operations</li></ul>Specifying readOnly when capacity is 1 results in error.",
"enum": [
"all",
"readOnly"
],
"x-ms-enum": {
"modelAsString": false,
"name": "ConnectionMode"
},
"default": "all"
}
}
},
Expand Down
Loading

0 comments on commit 3441d1d

Please sign in to comment.