Evaluate whether your service conforms with Level 2 of the Richardson Maturity Model.
Mature RESTful designs represent
- Resources as HTTP paths and
- Operations available for resources as HTTP methods.
- Table of contents
- Traditional, non-RESTful operations
- RESTful API verbs represented by HTTP method type
- Rule Details
- When Not To Use It
- Version
- Further Reading
Traditional RPC and SOAP calls expose procedure and method calls for CRUD operations. When RPCs and SOAP rarely take HTTP method types into consideration beyond data exchange (e.g., sending data in HTTP request and response bodies).
| HTTP method type (verb) | CRUD | Collection (e.g., /pets) |
Item (e.g., /pets/{id}) |
|---|---|---|---|
| POST | Create | /pets/createPets |
/pets/createPet |
| GET | Read | /pets/getAllPets |
/pets/getPetById |
| POST | Update/Replace | /pets/updateAllPets |
/pets/updateById |
| POST | Update/Modify | /pets/updateBreed |
/pets/updateBreedById |
| POST | Delete | /pets/deleteAllPets |
/pets/deletePetsByBreed |
RESTful APIs standardize resource operations, e.g., find, get, create, update, with HTTP method method types.
| HTTP method type (verb) | CRUD | Collection (e.g., /pets) |
Item (e.g., /pets/{id}) |
|---|---|---|---|
| POST | Create | 201 Created |
404 Not Found409 Conflict (if resource already exists) |
| GET | Read | 200 OK |
200 OK404 Not Found (if resource doesn't exist or invalid) |
| PUT | Update/Replace | 405 Method Not Allowed (unless replacement of every resource is allowed) |
200 OK204 No Content404 Not Found |
| PATCH | Update/Modify | 405 Method Not Allowed (unless you allow modification of the entire collection) |
200 OK204 No Content404 Not Found (if ID not found or invalid) |
| DELETE | Delete | 405 Method Not Allowed (unless you want to delete the whole collection; not often desirable) |
404 Not Found200 OK404 Not Found (if ID not found or invalid) |
This rule evaluates API paths for
- Common (English) verbs
- Resources with names identical to its operation
{
"paths": {
"/pets/findByStatus": ...,
"/pets/findByTags": ...,
"/users/createWithArray": ...,
"/users/createWithList": ...
}
}{
"paths": {
"/pets/{petId}/uploadImage": ...,
"/users/login": ...,
"/users/logout": ...
}
}{
"paths": {
"/pets": ..., // with <query> input params
"/pets": ..., // with <query> input params
"/pets/{petId}/images": ..., // with uploadImage method
"/users": ..., // with overloaded operation
"/users": ..., // with overloaded operation
"/users/{id}/sessions": ..., // POST
"/users/{id}/sessions": ... // DELETE
}
}Disable this rule only in cases of backwards compatibility.
Disabling this rule will affect your RESTful service's maturity level, and your service will not, by definition, achieve Level 2, "HTTP Verbs".
The no-path-verbs rule was introduced to eslint-plugin-swagger in version 0.2.0.