{"section":"http-status-codes","title":"HTTP Status Codes Rules","description":"Rules for proper status code usage","totalRules":5,"spectralRules":[{"name":"standard-status-codes","severity":"error","message":"Use only standard HTTP status codes","given":"$.paths[*][*].responses[*]~","then":{"function":"enumeration","functionOptions":{"values":["200","201","202","204","301","304","400","401","403","404","405","409","410","412","415","422","429","500","503","default"]}}},{"name":"get-response-200","severity":"warn","message":"GET operations should return 200 OK","given":"$.paths[*].get.responses","then":{"field":"200","function":"truthy"}},{"name":"post-response-201-or-200","severity":"warn","message":"POST operations should return 201 Created or 200 OK","given":"$.paths[*].post.responses","then":{"function":"xor","functionOptions":{"properties":["200","201","202"]}}},{"name":"delete-response-204-or-202","severity":"warn","message":"DELETE operations should return 204 No Content or 202 Accepted","given":"$.paths[*].delete.responses","then":{"function":"xor","functionOptions":{"properties":["202","204"]}}},{"name":"operation-error-response","severity":"info","message":"Operations should define at least one 4xx error response","given":"$.paths[*][get,post,put,patch,delete].responses","then":{"function":"schema","functionOptions":{"schema":{"anyOf":[{"required":["400"]},{"required":["401"]},{"required":["403"]},{"required":["404"]},{"required":["422"]},{"required":["default"]}]}}}}],"rules":[{"id":"standard-codes-only","requirement":"MUST","rule":"Use only standard HTTP status codes","severity":"error","spectralRule":"standard-status-codes","rationale":"Non-standard codes create client interoperability issues"},{"id":"get-returns-200","requirement":"SHOULD","rule":"GET operations should return 200 OK for successful requests","severity":"warn","spectralRule":"get-response-200"},{"id":"post-returns-201","requirement":"SHOULD","rule":"POST operations creating resources should return 201 Created","severity":"warn","spectralRule":"post-response-201-or-200"},{"id":"delete-returns-204","requirement":"SHOULD","rule":"DELETE operations should return 204 No Content","severity":"warn","spectralRule":"delete-response-204-or-202"},{"id":"define-error-responses","requirement":"SHOULD","rule":"Operations should define at least one 4xx error response","severity":"info","spectralRule":"operation-error-response"}]}