Azure / Azure/azure-openapi-validator

[TypeSpec False Positives] EvenSegmentedPathForPutOperation and XmsPageableForListCalls with @singleton

Open
#646 1 comment 0 reactions 1 assignee Assigned to @tejaswiMinnu View on GitHub
Dominant language
TypeScript
Stars
53
Forks
57
Avg merge
1d 23h
Merged PRs (30d)
2

Description

The regex used by `EvenSegmentedPathForPutOperation` requires the last path segment to be wrapped in curly braces:

https://github.com/Azure/azure-openapi-validator/blob/2873e674ce169c7c459a1a8028d75e058ff0f873/packages/rulesets/src/spectral/az-arm.ts#L556

This fails to match the OpenAPI generated by TypeSpec `@singletons`:

```
@singleton
model Employee is TrackedResource

.../providers/Microsoft.ContosoProviderHub/employees/default
```

But it does match the OpenAPI generated by TypeSpec when not using `@singleton`:

```
model Employee is TrackedResource {

.../providers/Microsoft.ContosoProviderHub/employees/{employeeName}
```

Should `EvenSegmentedPathForPutOperation` be adjusted to make optional the curly braces around the last path segment? Or even allow only the string `default` for TypeSpec singletons?

Rule `XmsPageableForListCalls` has a similar bug but in the opposite direction. It assumes if a path does not end with `}`, it must specify `x-ms-pageable`, which I believe should not apply to the `default` path generated from TypeSpec `@singleton`.

https://github.com/Azure/azure-openapi-validator/blob/2873e674ce169c7c459a1a8028d75e058ff0f873/packages/rulesets/src/spectral/az-arm.ts#L385

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.