Azure / Azure/azure-openapi-validator

RequestSchemaForTrackedResourcesMustHaveTags is incorrectly triggered for a Proxy resource with top-level property Location

Open
#753 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
53
Forks
57
Avg merge
1d 23h
Merged PRs (30d)
2

Description

**Describe the bug**
**To Reproduce**

Given a proxy resource (such as inherited from common type ProxyResource) which has a top-level property `location`:

```
model ProxyAccount is ProxyResource {
name: string;
location: ProxyAccountLocation;
}

union ProxyAccountLocation {
Global: "global",
string,
}

@armResourceOperations
interface ProxyAccounts {
get is ArmResourceRead;
create is ArmResourceCreateOrReplaceAsync;
update is ArmResourcePatchAsync;
delete is ArmResourceDeleteWithoutOkAsync;
listByResourceGroup is ArmResourceListByParent;
listBySubscription is ArmListBySubscription;
}
```

What results in the following swagger:

```json
"ProxyAccount": {
"type": "object",
"description": "Proxy account",
"properties": {
"properties": {
"$ref": "#/definitions/ProxyAccountProperties",
"description": "The resource-specific properties for this resource."
},
"location": {
"$ref": "#/definitions/ProxyAccountLocation",
"description": "Proxy account location",
"x-ms-mutability": [
"read",
"create"
]
}
},
"required": [
"location"
],
"allOf": [
{
"$ref": "../../../../../common-types/resource-management/v5/types.json#/definitions/ProxyResource"
}
]
}
```

triggers the following Linter rule `RequestSchemaForTrackedResourcesMustHaveTags`

>A tracked resource MUST always have tags as a top level optional property. Tracked resource does not have tags in the request schema.

Steps to reproduce the behavior:

**Expected behavior**

The rule should not infer the resource's type (tracked vs proxy) by the presence of a top-level property `location`.

Instead, it should check whether the resource inherits a common type first, and only if doesn't then fall back to the current logic.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.