rest-api-design

REST API design patterns and MicroProfile OpenAPI documentation. Use when designing endpoints, choosing HTTP methods, status codes, or documenting APIs with OpenAPI annotations.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "rest-api-design" with this command: npx skills add emvnuel/skill.md/emvnuel-skill-md-rest-api-design

REST API Design Best Practices

Design consistent, intuitive REST APIs with proper documentation.


Endpoint Design Rules

Use Nouns, Not Verbs

// ❌ Bad
@GET @Path("/getUsers")
@POST @Path("/createUser")

// ✓ Good
@GET @Path("/users")
@POST @Path("/users")

Use Plural Nouns for Collections

@Path("/users")        // Collection
@Path("/users/{id}")   // Single resource
@Path("/orders")       // Collection
@Path("/orders/{id}")  // Single resource

Nest Related Resources (Max 3 Levels)

@Path("/users/{userId}/orders")              // User's orders
@Path("/users/{userId}/orders/{orderId}")    // Specific order
@Path("/posts/{postId}/comments")            // Post's comments

Cookbook: endpoint-design.md


HTTP Methods

MethodPurposeIdempotentRequest Body
GETRetrieveYesNo
POSTCreateNoYes
PUTReplace entirelyYesYes
PATCHPartial updateYesYes
DELETERemoveYesNo

Cookbook: http-methods.md


Status Codes

CodeMeaningWhen to Use
200OKSuccessful GET, PUT, PATCH
201CreatedSuccessful POST
204No ContentSuccessful DELETE
400Bad RequestValidation errors
401UnauthorizedMissing/invalid auth
403ForbiddenInsufficient permissions
404Not FoundResource doesn't exist
422Unprocessable EntityBusiness rule violation
500Internal ErrorUnexpected server error

Cookbook: status-codes.md


Filtering & Pagination

@GET
@Path("/products")
public List<Product> list(
    @QueryParam("category") String category,
    @QueryParam("minPrice") BigDecimal minPrice,
    @QueryParam("sort") @DefaultValue("name") String sort,
    @QueryParam("page") @DefaultValue("0") int page,
    @QueryParam("size") @DefaultValue("20") int size
) { }

Cookbook: filtering-pagination.md


API Versioning

// URL path versioning (recommended)
@Path("/v1/users")
public class UserResourceV1 { }

@Path("/v2/users")
public class UserResourceV2 { }

Cookbook: versioning.md


MicroProfile OpenAPI Documentation

@Path("/users")
@Tag(name = "Users", description = "User management")
public class UserResource {

    @GET
    @Path("/{id}")
    @Operation(summary = "Get user by ID")
    @APIResponse(responseCode = "200", description = "User found")
    @APIResponse(responseCode = "404", description = "User not found")
    public User getById(@PathParam("id") Long id) { }
}

Cookbook: openapi-documentation.md


Cookbook Index

Design: Endpoint Design · HTTP Methods

Responses: Status Codes

Querying: Filtering & Pagination

Evolving: Versioning

Documentation: OpenAPI Documentation

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

clean-code-principles

No summary provided by upstream source.

Repository SourceNeeds Review
General

quarkus-panache-smells

No summary provided by upstream source.

Repository SourceNeeds Review
General

lombok-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

mapstruct-patterns

No summary provided by upstream source.

Repository SourceNeeds Review