Open cataggar opened 11 months ago
I saw this discussed in https://github.com/Azure/azure-sdk-tools/issues/6191. The solution was to add use-read-only-status-schema: true
to the tspconfig.yml
:
options:
"@azure-tools/typespec-autorest":
azure-resource-provider-folder: "resource-manager"
emitter-output-dir: "{project-root}/.."
examples-directory: examples
output-file: "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/vmware.json"
omit-unreachable-types: true
use-read-only-status-schema: true
This should be fixed in coordination wtih https://github.com/Azure/oav/issues/848.
The rule is a "false positive" from the perspective of autorest, but it's correct from the perspective of OpenAPI 2.0. Siblings of $ref are allowed in the former, but ignored in the latter (https://github.com/Azure/azure-openapi-validator/discussions/706).
ProvisioningStateMustBeReadOnly
is a "spectral" rule:
It's probably ignoring the readonly
property, because the OpenAPI 2.0 spec says it should be ignored. It might be possible to configure spectral allow siblings of $ref, but I'm not sure if or how yet, other than converting the autorest to OpenAPI 3.1 which allows siblings of $ref.
Relevant unit test from spectral:
Otherwise, this rule could be converted from spectral to native, which should be able to allow siblings of $ref
.
Until fixed, we should improve the documentation:
use-read-only-status-schema: true
to the rule error message.@markcowl: How would you characterize setting use-read-only-status-schema: true
in tspconfig.yaml
? Is this a "workaround" for the bugs in azure-openapi-validator
and oav
? Or should specs configure this for other reasons, and the errors are just a good reminder?
Put another way, if the bugs in azure-openapi-validator
and oav
are fixed, is TypeSpec setting use-read-only-status-schema
still useful? Ignoring our tooling, how does this setting impact the spec, the SDKs, or customers?
I am working on https://github.com/Azure/azure-rest-api-specs-pr/pull/15631 and there are many instances of
ProvisioningStateMustBeReadOnly
errors that are false positives. https://github.com/Azure/azure-rest-api-specs-pr/pull/15631/checks?check_run_id=19650955197All of the
provisioningState
s are marked asreadOnly
, for example:I see this test was considered flaky before in #561. cc @AkhilaIlla