Azure / azure-openapi-validator

Azure Open API Validator
MIT License
47 stars 46 forks source link

[TypeSpec False Positive] PostResponseCodes should allow LRO with 202 and 204 responses #660

Closed mikeharder closed 8 months ago

mikeharder commented 8 months ago

@markcowl believes the following rule is incorrect, and should allow LRO with both 202 and 204 responses:

https://github.com/Azure/azure-openapi-validator/blob/main/docs/post-response-codes.md https://github.com/Azure/azure-openapi-validator/blob/main/packages/rulesets/src/spectral/functions/post-response-codes.ts

The rule currently only allows LRO with either 202 | 200 responses, or just 202, but never 202 | 204.

The following PR has TypeSpec similar to this:

foo is ArmResourceActionAsync<FooConnector, FooParameters, void>;

https://github.com/Azure/azure-rest-api-specs-pr/pull/16638/files#diff-50b0d71c5f3859fbe9a1ceb4096d1350251ff89dddc1c727406a86d15ef555b4R166

Which generates OpenApi similar to this:

"responses": {
  "202": {
    ...
  },
  "204": {
    "description": "ARM operation completed successfully."
  },
  "default": {
    ...
  }
}

https://github.com/Azure/azure-rest-api-specs-pr/pull/16638/checks?check_run_id=21130130696

Which causes rule PostResponseCodes to fail.

@AkhilaIlla, @bdefoy, @tejaswiMinnu, @rkmanda: Do you agree with @markcowl that the PostResponseCodes rule is incorrect and should be updated? Or do you think the rule is still correct, and TypeSpec should generate OpenAPI that satisfies the rule?

markcowl commented 8 months ago

@mikeharder I think I was mistaken about this. It is supported in TypeSpec, and Mike did verify that SDK clients supported it