Skip to content

Commit 68030f1

Browse files
authored
[ci-fix.md] Add known issues to "Swagger LintDiff for TypeSpec" (Azure#27573)
1 parent 3efb341 commit 68030f1

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

documentation/ci-fix.md

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
- [`Record<unkown>` causes `AvoidAdditionalProperties` and `PropertiesTypeObjectNoDefinition`](#recordunkown-causes-avoidadditionalproperties-and-propertiestypeobjectnodefinition)
1717
- [`RequestBodyMustExistForPutPatch`](#requestbodymustexistforputpatch)
1818
- [`PatchPropertiesCorrespondToPutProperties`](#patchpropertiescorrespondtoputproperties)
19+
- [`@singleton` causes `EvenSegmentedPathForPutOperation` and `XmsPageableForListCalls`](#singleton-causes-evensegmentedpathforputoperation-and-xmspageableforlistcalls)
20+
- [`AvoidAnonymousParameter`, `AvoidAnonymousTypes`, `IntegerTypeMustHaveFormat`](#avoidanonymousparameter-avoidanonymoustypes-integertypemusthaveformat)
21+
- [`AvoidAnonymousTypes` inside a 202 response](#avoidanonymoustypes-inside-a-202-response)
22+
- [`OAuth2Auth` causes `XmsEnumValidation`](#oauth2auth-causes-xmsenumvalidation)
1923
- [`Swagger Avocado`](#swagger-avocado)
2024
- [Get help fixing Avocado validation failures](#get-help-fixing-avocado-validation-failures)
2125
- [Run avocado locally](#run-avocado-locally)
@@ -155,21 +159,53 @@ To reproduce LintDiff failures locally, see [CONTRIBUTING.md / How to locally re
155159

156160
## `Swagger LintDiff` for TypeSpec: troubleshooting guides
157161

162+
Check `Swagger LintDiff` may fail for the OpenAPI generated from TypeSpec, even if there are no warnings or errors reported from the TypeSpec compiler. Causes include bugs in the TypeSpec OpenAPI emitter, bugs in LintDiff rules, incompatibilities between TypeSpec and LintDiff, or checks duplicated in TypeSpec and LintDiff.
163+
164+
We are working to address the root causes (where possible). Until then, we recommend you [suppress](#suppression-process) these LintDiff errors, using a "permanent suppression" with a descriptive "reason", so we can revert your suppression when the root cause is fixed.
165+
158166
### `Record<unkown>` causes `AvoidAdditionalProperties` and `PropertiesTypeObjectNoDefinition`
159167

160-
The use of `Record<unkown>` in TypeSpec is discouraged, and there is a TypeSpec lint rule to enforce this. If you still need to use `Record<unknown>`, the OpenAPI spec generated will cause many LintDiff errors of types `AvoidAdditionalProperties` and `PropertiesTypeObjectNoDefinition`. You will need to suppress both the TypeSpec violation (in TypeSpec source code) and the LintDiff violations (in `readme.md`).
168+
The use of `Record<unkown>` in TypeSpec is discouraged, and there is a TypeSpec lint rule to enforce this. If you still need to use `Record<unknown>`, the OpenAPI spec generated will cause many LintDiff errors of types `AvoidAdditionalProperties` and `PropertiesTypeObjectNoDefinition`. You will need to suppress both the TypeSpec violation (in TypeSpec source code) and the LintDiff violations.
161169

162170
### `RequestBodyMustExistForPutPatch`
163171

164-
We believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/641. Until fixed, spec authors should **not** suppress the violations in `readme.md`, but rather have label `Approved-LintDiff` applied to their PR to ignore the errors.
172+
We believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/641
165173

166174
### `PatchPropertiesCorrespondToPutProperties`
167175

168-
We believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/642. Until fixed, spec authors should **not** suppress the violations in `readme.md`, but rather have label `Approved-LintDiff` applied to their PR to ignore the errors.
176+
We believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/642
169177

170178
### `@singleton` causes `EvenSegmentedPathForPutOperation` and `XmsPageableForListCalls`
171179

172-
If `EvenSegmentedPathForPutOperation` and/or `XmsPageableForListCalls` are failing for OpenAPI generated from TypeSpec using `@singleton` (OpenAPI path ends with `/default`), we believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/646. Until fixed, spec authors should **not** suppress the violations in `readme.md`, but rather have label `Approved-LintDiff` applied to their PR to ignore the errors.
180+
If `EvenSegmentedPathForPutOperation` and/or `XmsPageableForListCalls` are failing for OpenAPI generated from TypeSpec using `@singleton` (OpenAPI path ends with `/default`), we believe this is a false positive: https://github.com/Azure/azure-openapi-validator/issues/646
181+
182+
### `AvoidAnonymousParameter`, `AvoidAnonymousTypes`, `IntegerTypeMustHaveFormat`
183+
184+
Data-plane specs can suppress violations of the following rules, since they only exist for the benefit of SDKs generated from swagger, and data-plane SDKs are generated directly from TypeSpec. Resource-manager specs should **not** suppress violations of these rules, since resource-manager SDKs are generated from OpenAPI, and rely on these errors being fixed.
185+
186+
* `AvoidAnonymousParameter`
187+
* `AvoidAnonymousTypes`
188+
* `IntegerTypeMustHaveFormat`
189+
190+
### `AvoidAnonymousTypes` inside a 202 response
191+
192+
As an exception to the previous note, resource-manager specs **may** be able to suppress `AvoidAnonymousTypes`, but only if the error is inside a 202 response from a long-running operation (LRO). It is known that SDKs do not need to generate type names for such responses.
193+
194+
### `OAuth2Auth` causes `XmsEnumValidation`
195+
196+
TypeSpec using `OAuth2Auth` may generate the following OpenAPI:
197+
198+
```
199+
"type": {
200+
"type": "string",
201+
"description": "OAuth2 authentication",
202+
"enum": [
203+
"oauth2"
204+
]
205+
},
206+
```
207+
208+
Which causes error `XmsEnumValidation`. The recommended workaround is to add `omit-unreachable-types: true` to your `tspconfig.yaml`.
173209

174210
## `Swagger Avocado`
175211

0 commit comments

Comments
 (0)