Azure / Azure/azure-openapi-validator
[TypeSpec False Positives] EvenSegmentedPathForPutOperation and XmsPageableForListCalls with @singleton
- 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
Assessment
This issue has not been assessed yet.