From b711d809b6ae964fcbe7d04f31fec76db8798438 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 25 Oct 2019 09:59:01 +0800 Subject: [PATCH 1/5] Add free-form object spec for testing purpose. --- .../WorkbookTemplateGet.json | 34 +++ .../2019-09-01-preview/testBodyAsObject.json | 197 ++++++++++++++++++ 2 files changed, 231 insertions(+) create mode 100644 specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json create mode 100644 specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json diff --git a/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json b/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json new file mode 100644 index 000000000000..5e1dc0d37301 --- /dev/null +++ b/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json @@ -0,0 +1,34 @@ +{ + "parameters": { + "api-version": "2019-10-17-preview", + "subscriptionId": "6b643656-33eb-422f-aee8-3ac145d124af", + "resourceGroupName": "my-resource-group", + "resourceName": "my-resource-name" + }, + "responses": { + "200": { + "body": { + "name": "my-resource-name", + "type": "microsoft.insights/workbooktemplate", + "location": "westus", + "resourceId": "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/microsoft.insights/workbooktemplates/my-resource-name", + "properties": { + "id": "1bc6ac57-4789-4b4b-84ed-2ed293ee98e7", + "priority": 1, + "author": "Contoso", + "galleries": [ + { + "name": "Simple Template", + "category": "Failures", + "type": "tsg", + "resourceType": "microsoft.insights/components", + "order": 100 + } + ], + "templateData": {} + }, + "tags": null + } + } + } +} \ No newline at end of file diff --git a/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json b/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json new file mode 100644 index 000000000000..20396e7de2cb --- /dev/null +++ b/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json @@ -0,0 +1,197 @@ +{ + "swagger": "2.0", + "info": { + "title": "ApplicationInsightsManagementClient", + "description": "Azure Application Insights workbook template type.", + "version": "2019-10-17-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow.", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "paths": { + "/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}": { + "get": { + "description": "Get a single workbook template by its resourceName.", + "operationId": "WorkbookTemplates_Get", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/WorkbookTemplateResourceNameParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "A workbook template definition.", + "schema": { + "$ref": "#/definitions/BodyAsObject" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/WorkbookError" + } + } + }, + "x-ms-examples": { + "WorkbookTemplateGet": { + "$ref": "./WorkbookTemplateGet.json" + } + } + } + } + }, + "definitions": { + "Resource": { + "properties": { + "resourceId": { + "type": "string", + "readOnly": true, + "description": "Azure resource Id" + }, + "name": { + "type": "string", + "readOnly": true, + "description": "Azure resource name." + }, + "type": { + "type": "string", + "readOnly": true, + "description": "Azure resource type" + }, + "location": { + "type": "string", + "description": "Resource location", + "x-ms-mutability": [ + "create", + "read" + ] + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "required": [ + "location" + ], + "x-ms-azure-resource": true, + "description": "An azure resource object" + }, + "BodyAsObject": { + "description": "Test obj.", + "type": "object", + "additionalProperties": true + }, + "ErrorFieldContract": { + "properties": { + "code": { + "type": "string", + "description": "Property level error code." + }, + "message": { + "type": "string", + "description": "Human-readable representation of property-level error." + }, + "target": { + "type": "string", + "description": "Property name." + } + }, + "description": "Error Field contract." + }, + "WorkbookError": { + "properties": { + "code": { + "type": "string", + "description": "Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response." + }, + "message": { + "type": "string", + "description": "Human-readable representation of the error." + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/ErrorFieldContract" + }, + "description": "The list of invalid fields send in request, in case of validation error." + } + }, + "description": "Error message body that will indicate why the operation failed." + } + }, + "parameters": { + "WorkbookTemplateResourceNameParameter": { + "name": "resourceName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Application Insights component resource.", + "x-ms-parameter-location": "method" + }, + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "The ID of the target subscription.", + "minLength": 1 + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "The API version to use for this operation.", + "minLength": 1 + }, + "ResourceGroupNameParameter": { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group. The name is case insensitive.", + "pattern": "^[-\\w\\._\\(\\)]+$", + "minLength": 1, + "maxLength": 90, + "x-ms-parameter-location": "method" + } + } +} From d076bdcd400e1827059188aadeddd515fa47b0f4 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Tue, 3 Mar 2020 10:19:40 +0800 Subject: [PATCH 2/5] Revert "Add free-form object spec for testing purpose." This reverts commit b711d809b6ae964fcbe7d04f31fec76db8798438. --- .../WorkbookTemplateGet.json | 34 --- .../2019-09-01-preview/testBodyAsObject.json | 197 ------------------ 2 files changed, 231 deletions(-) delete mode 100644 specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json delete mode 100644 specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json diff --git a/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json b/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json deleted file mode 100644 index 5e1dc0d37301..000000000000 --- a/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/WorkbookTemplateGet.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "parameters": { - "api-version": "2019-10-17-preview", - "subscriptionId": "6b643656-33eb-422f-aee8-3ac145d124af", - "resourceGroupName": "my-resource-group", - "resourceName": "my-resource-name" - }, - "responses": { - "200": { - "body": { - "name": "my-resource-name", - "type": "microsoft.insights/workbooktemplate", - "location": "westus", - "resourceId": "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/microsoft.insights/workbooktemplates/my-resource-name", - "properties": { - "id": "1bc6ac57-4789-4b4b-84ed-2ed293ee98e7", - "priority": 1, - "author": "Contoso", - "galleries": [ - { - "name": "Simple Template", - "category": "Failures", - "type": "tsg", - "resourceType": "microsoft.insights/components", - "order": 100 - } - ], - "templateData": {} - }, - "tags": null - } - } - } -} \ No newline at end of file diff --git a/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json b/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json deleted file mode 100644 index 20396e7de2cb..000000000000 --- a/specification/applicationinsights/resource-manager/Microsoft.Insights/preview/2019-09-01-preview/testBodyAsObject.json +++ /dev/null @@ -1,197 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "ApplicationInsightsManagementClient", - "description": "Azure Application Insights workbook template type.", - "version": "2019-10-17-preview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ], - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow.", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "paths": { - "/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/microsoft.insights/workbooks/{resourceName}": { - "get": { - "description": "Get a single workbook template by its resourceName.", - "operationId": "WorkbookTemplates_Get", - "parameters": [ - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "$ref": "#/parameters/ResourceGroupNameParameter" - }, - { - "$ref": "#/parameters/WorkbookTemplateResourceNameParameter" - }, - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "A workbook template definition.", - "schema": { - "$ref": "#/definitions/BodyAsObject" - } - }, - "default": { - "description": "Error response describing why the operation failed.", - "schema": { - "$ref": "#/definitions/WorkbookError" - } - } - }, - "x-ms-examples": { - "WorkbookTemplateGet": { - "$ref": "./WorkbookTemplateGet.json" - } - } - } - } - }, - "definitions": { - "Resource": { - "properties": { - "resourceId": { - "type": "string", - "readOnly": true, - "description": "Azure resource Id" - }, - "name": { - "type": "string", - "readOnly": true, - "description": "Azure resource name." - }, - "type": { - "type": "string", - "readOnly": true, - "description": "Azure resource type" - }, - "location": { - "type": "string", - "description": "Resource location", - "x-ms-mutability": [ - "create", - "read" - ] - }, - "tags": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "Resource tags" - } - }, - "required": [ - "location" - ], - "x-ms-azure-resource": true, - "description": "An azure resource object" - }, - "BodyAsObject": { - "description": "Test obj.", - "type": "object", - "additionalProperties": true - }, - "ErrorFieldContract": { - "properties": { - "code": { - "type": "string", - "description": "Property level error code." - }, - "message": { - "type": "string", - "description": "Human-readable representation of property-level error." - }, - "target": { - "type": "string", - "description": "Property name." - } - }, - "description": "Error Field contract." - }, - "WorkbookError": { - "properties": { - "code": { - "type": "string", - "description": "Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response." - }, - "message": { - "type": "string", - "description": "Human-readable representation of the error." - }, - "details": { - "type": "array", - "items": { - "$ref": "#/definitions/ErrorFieldContract" - }, - "description": "The list of invalid fields send in request, in case of validation error." - } - }, - "description": "Error message body that will indicate why the operation failed." - } - }, - "parameters": { - "WorkbookTemplateResourceNameParameter": { - "name": "resourceName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the Application Insights component resource.", - "x-ms-parameter-location": "method" - }, - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "required": true, - "type": "string", - "description": "The ID of the target subscription.", - "minLength": 1 - }, - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "required": true, - "type": "string", - "description": "The API version to use for this operation.", - "minLength": 1 - }, - "ResourceGroupNameParameter": { - "name": "resourceGroupName", - "in": "path", - "required": true, - "type": "string", - "description": "The name of the resource group. The name is case insensitive.", - "pattern": "^[-\\w\\._\\(\\)]+$", - "minLength": 1, - "maxLength": 90, - "x-ms-parameter-location": "method" - } - } -} From c1ead2b5eb6c8db2cff65342f8bdb2fd5eaa5ce2 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Mon, 23 Mar 2020 11:11:40 +0800 Subject: [PATCH 3/5] Updated ci-fix document. Added how to run/fix model validation and semantic validation. --- documentation/ci-fix.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/documentation/ci-fix.md b/documentation/ci-fix.md index caa88d0ad563..737f03e52028 100644 --- a/documentation/ci-fix.md +++ b/documentation/ci-fix.md @@ -21,3 +21,17 @@ npm install; npm run prettier -- --write "specification//**/*.json" ``` Then please commit and push changes made by prettier. + +## How to run model validation locally + +Model validation is provided by OAV tool and the command to run model validation locally is `oav validate-example `. +Please see [readme](https://github.com/Azure/oav/blob/master/README.md) in OAV reposiotry for installation and command usuage details. + +## How to run semantic validation locally + +Semantic validation is provided by OAV tool and the command to run model validation locally is `oav validate-spec `. +Please see [readme](https://github.com/Azure/oav/blob/master/README.md) in OAV reposiotry for installation and command usuage details. + +## How to fix model validation and semantic checks + +Here is the [guideline](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) to understand the check failures and how to fix them. From 3314f6799c2c648e24d33acc362eb91aaa1ad250 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Wed, 25 Mar 2020 09:05:59 +0800 Subject: [PATCH 4/5] Combined run locally and fix tips parts. --- documentation/ci-fix.md | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/documentation/ci-fix.md b/documentation/ci-fix.md index 737f03e52028..ab23d7f0d2e8 100644 --- a/documentation/ci-fix.md +++ b/documentation/ci-fix.md @@ -22,16 +22,23 @@ npm install; npm run prettier -- --write "specification//**/*.json" Then please commit and push changes made by prettier. -## How to run model validation locally +## Model Validation -Model validation is provided by OAV tool and the command to run model validation locally is `oav validate-example `. -Please see [readme](https://github.com/Azure/oav/blob/master/README.md) in OAV reposiotry for installation and command usuage details. - -## How to run semantic validation locally - -Semantic validation is provided by OAV tool and the command to run model validation locally is `oav validate-spec `. -Please see [readme](https://github.com/Azure/oav/blob/master/README.md) in OAV reposiotry for installation and command usuage details. - -## How to fix model validation and semantic checks +Run Model Validation locally: +``` +npm install -g oav +oav validate-example +``` +Please see [readme](https://github.com/Azure/oav/blob/master/README.md) for how to install or run tool in details. +Or you can run it in [OpenAPI Hub](https://portal.azure-devex-tools.com/tools/static-validation/static/errors/default) +And refer to [guideline](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) to check error code and how to fix in detail. -Here is the [guideline](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) to understand the check failures and how to fix them. +## Semantic Validation +Run Semantic Validation locally: +``` +npm install -g oav +oav validate-spec +``` +Please see [readme](https://github.com/Azure/oav/blob/master/README.md) for how to install or run tool in details. +Or you can run it in [OpenAPI Hub](https://portal.azure-devex-tools.com/tools/static-validation/static/errors/default) +And refer to [guideline](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) to check error code and how to fix in detail. From dde651a3e977cbebb83bbbab63c4ed6e5e6c0754 Mon Sep 17 00:00:00 2001 From: Ray Chen Date: Fri, 27 Mar 2020 10:08:56 +0800 Subject: [PATCH 5/5] Tweaked link text. --- documentation/ci-fix.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/ci-fix.md b/documentation/ci-fix.md index ab23d7f0d2e8..9b0fae9ca435 100644 --- a/documentation/ci-fix.md +++ b/documentation/ci-fix.md @@ -31,7 +31,7 @@ oav validate-example ``` Please see [readme](https://github.com/Azure/oav/blob/master/README.md) for how to install or run tool in details. Or you can run it in [OpenAPI Hub](https://portal.azure-devex-tools.com/tools/static-validation/static/errors/default) -And refer to [guideline](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) to check error code and how to fix in detail. +Refer to [Semantic and Model Violations Reference](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) for detailed description of validations and how-to-fix guidance. ## Semantic Validation Run Semantic Validation locally: @@ -41,4 +41,4 @@ oav validate-spec ``` Please see [readme](https://github.com/Azure/oav/blob/master/README.md) for how to install or run tool in details. Or you can run it in [OpenAPI Hub](https://portal.azure-devex-tools.com/tools/static-validation/static/errors/default) -And refer to [guideline](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) to check error code and how to fix in detail. +Refer to [Semantic and Model Violations Reference](https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/Semantic-and-Model-Violations-Reference.md) for detailed description of validations and how-to-fix guidance.