Azure / Azure/azure-openapi-validator

[PatchBodyParameterSchema] Improve error message from nested properties

Open
#708 0 comments 0 reactions 1 assignee Claimed by @mikeharder View on GitHub
Dominant language
TypeScript
Stars
53
Forks
57
Avg merge
1d 23h
Merged PRs (30d)
2

Description

If rule `PatchBodyParameterSchema` fails, the error message only includes the name of the property and the top-level reference that contains the nested property:

> ❌ [PatchBodyParametersSchema](https://github.com/Azure/azure-openapi-validator/blob/main/docs/patch-body-parameters-schema.md) Properties of a PATCH request body must not be required, **property:type**.
> Location: [Microsoft.AVS/stable/2023-09-01/vmware.json#L489](https://github.com/Azure/azure-rest-api-specs/blob/49c09a54a1f96f8b78ddce62e79fb9b7dc30b535/specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/vmware.json#L489) RPC-Patch-V1-10
> ❌ [PatchBodyParametersSchema](https://github.com/Azure/azure-openapi-validator/blob/main/docs/patch-body-parameters-schema.md) Properties of a PATCH request body must not be required, **property:name**.
> Location: [Microsoft.AVS/stable/2023-09-01/vmware.json#L489](https://github.com/Azure/azure-rest-api-specs/blob/49c09a54a1f96f8b78ddce62e79fb9b7dc30b535/specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/vmware.json#L489) RPC-Patch-V1-10
> ❌ [PatchBodyParametersSchema](https://github.com/Azure/azure-openapi-validator/blob/main/docs/patch-body-parameters-schema.md) Properties of a PATCH request body must not be required, **property:name**.
> Location: [Microsoft.AVS/stable/2023-09-01/vmware.json#L1609](https://github.com/Azure/azure-rest-api-specs/blob/49c09a54a1f96f8b78ddce62e79fb9b7dc30b535/specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/vmware.json#L1609) RPC-Patch-V1-10
>
> https://github.com/Azure/azure-rest-api-specs/pull/28023/checks?check_run_id=22174134612

This can be very difficult to debug, especially if the property is nested multiple levels or is under `common-types` which spec authors asssume are 100% correct.

Can the rule be improved to show the original source location of the violation? Or a "call stack" of $refs?

I'm unsure if this behavior is specific to `PatchBodyParameterSchema`, or applies to many (or all) rules.

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.