typespec1-4 Exercise 3: A 4xx Response for Create ======================================================== The lint rule operation-4xx-response, before and after adding a BadRequest (400) to create (books_v2.tsp adds the model below and returns Created | BadRequest | ApiError): @error model BadRequest { @statusCode _: 400; message: string; } == out_books 30:7 warning operation-4xx-response Operation must have at least one `4XX` response. 48:7 warning operation-4xx-response Operation must have at least one `4XX` response. ❌ Validation failed with 8 errors and 4 warnings. == out_books_v2 30:7 warning operation-4xx-response Operation must have at least one `4XX` response. ❌ Validation failed with 8 errors and 3 warnings. WHAT CHANGED Before: two operations had no 4XX response (list at line 30 of the generated file and create at line 48). After: only list. The 4XX warning for create went away because create now declares a 400. The generic 'default' response was already there and does not count as a 4XX for this rule. The 8 errors are unchanged: the missing summaries and security from chapters 2 and 5. DO I AGREE THE REMAINING WARNING IS RIGHT? For list, only partly. A list that takes optional paging parameters can still be asked for something invalid (limit=-5), in which case a 400 would be reasonable, and a client library would like to know. If list has no parameters at all, a 4XX response would be invented. The linter cannot know; a person decides. Write the response if clients should handle it, and silence the rule for that operation otherwise. WHY THIS WORKS AS AN ANSWER --------------------------- It shows a lint rule turning into a design question and a one-model change in the TypeSpec, with no edit to generated output. It also shows that a rule can be right for one operation and arguable for its neighbour.