API Template
API Template
1. API Specification
List all endpoints clearly with details:
HTTP
Endpoint Path Description/Purpose
Method
/api/
PUT Update existing customer
customers/{id}
/api/
DELETE Delete customer by ID
customers/{id}
3. Entity Definitions
Clearly define all required entities or database tables:
Example Entity (Customer):
java
CopyEdit
@Entity
public class Customer {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Embedded
private Address address;
4. Database Specifications
Specify Database type (SQL/NoSQL)
Specify Schema or Data Migration preference (Flyway/Liquibase if
required)
Detail any constraints (e.g., unique, not-null, foreign keys, indexing)
8. Testing
Specify testing requirements clearly:
Unit tests (JUnit 5)
Integration tests (Testcontainers if DB is involved)
Provide at least one example test case clearly in the prompt.
Example Test Scenario:
Verify that creating a new customer succeeds with valid input and returns
HTTP 201.
Verify that creating a new customer with duplicate email fails with HTTP
400.
9. Documentation
Specify documentation requirements:
Use OpenAPI/Swagger for API documentation.
Generate interactive Swagger UI accessible at /swagger-ui.