Skip to content
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

Suggest common types resources #524

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@microsoft.azure/openapi-validator-rulesets",
"comment": "Add suggestion to use common types to the output message of RequiredPropertiesMissingInResourceModel",
"type": "patch"
}
],
"packageName": "@microsoft.azure/openapi-validator-rulesets"
}
3 changes: 2 additions & 1 deletion docs/required-properties-missing-in-resource-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ ARM OpenAPI(swagger) specs

## Output Message

Model definition '{0}' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.
Model definition '{0}' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.

## Description

Expand Down
2 changes: 1 addition & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ Please refer to [operations-api-schema-uses-common-types.md](./operations-api-sc

### OperationsApiTenantLevelOnly

The get operation endpoint for the operations API must be scoped tenant-wide. Operations should _not_ vary per subscription.
The get operation endpoint for the operations API must be scoped tenant-wide. Operations **must not** vary per subscription.

Please refer to [operations-api-tenant-level-only.md](./operations-api-tenant-level-only.md) for details.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ export function* resourcesHaveRequiredProperties(openapiSection: any, options: {
if (!prop || armHelper.getAttribute(prop, "readOnly")?.value !== true) {
yield {
location: ["definitions", re.modelName],
message: `Model definition '${re.modelName}' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.`,
message: `Model definition '${re.modelName}' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.`,
}
break
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
[
{
"code": "RequiredPropertiesMissingInResourceModel",
"message": "Model definition 'FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.",
"jsonpath": "$.definitions.FirewallRule",
"message": "Model definition 'FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.","jsonpath": "$.definitions.FirewallRule",
"source": "specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/FirewallRules.json:308:4"
},
{
"code": "RequiredPropertiesMissingInResourceModel",
"message": "Model definition 'IPv6 FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.",
"jsonpath": "$.definitions[\"IPv6 FirewallRule\"]",
"message": "Model definition 'IPv6 FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.","jsonpath": "$.definitions[\"IPv6 FirewallRule\"]",
"source": "specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/IPv6FirewallRules.json:215:4"
},
{
"code": "RequiredPropertiesMissingInResourceModel",
"message": "Model definition 'ProxyResourceWithWritableName' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.",
"jsonpath": "$.definitions.ProxyResourceWithWritableName",
"message": "Model definition 'ProxyResourceWithWritableName' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.","jsonpath": "$.definitions.ProxyResourceWithWritableName",
"source": "specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/IPv6FirewallRules.json:264:4"
}
]

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16144,19 +16144,22 @@ Array [
Object {
"code": "RequiredPropertiesMissingInResourceModel",
"jsonpath": "$.definitions.FirewallRule",
"message": "Model definition 'FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.",
"message": "Model definition 'FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.",
"source": "specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/FirewallRules.json:308:4",
},
Object {
"code": "RequiredPropertiesMissingInResourceModel",
"jsonpath": "$.definitions[\\"IPv6 FirewallRule\\"]",
"message": "Model definition 'IPv6 FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.",
"message": "Model definition 'IPv6 FirewallRule' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.",
"source": "specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/IPv6FirewallRules.json:215:4",
},
Object {
"code": "RequiredPropertiesMissingInResourceModel",
"jsonpath": "$.definitions.ProxyResourceWithWritableName",
"message": "Model definition 'ProxyResourceWithWritableName' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly.",
"message": "Model definition 'ProxyResourceWithWritableName' must have the properties 'name', 'id' and 'type' in its hierarchy and these properties must be marked as readonly. ARM suggests to use the common-types
resource definitions if possible.",
"source": "specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/IPv6FirewallRules.json:264:4",
},
]
Expand Down
Loading