Draft - Spring REST Endpoint and Persistence
Authoring skeleton - backend focus (CS112 backend integration)
Three short topics
- Request to controller to repository to database: who owns what.
- Entity, DTO, and JSON contract (field names, types, required values).
- Success and error responses a client can rely on.
PBL context
Connect a browser interaction to a Spring endpoint and persist or retrieve project data. Observe an existing controller/entity pair, then extend it; do not build the frontend.
Backend layers to author
- Read an existing controller method and trace one request end to end.
- Add a field or endpoint to an entity and expose it through JSON.
- Persist a record and retrieve it with a repository query.
- Document the API contract (method, path, body, status codes).
Evidence checklist to author
Call the endpoint with a valid request, a missing field, and an unknown id; record status code and body for each. Show that valid stored data is unchanged after a failed request.
Publication checklist
Complete examples, a CodeRunner exercise, and tests before removing the draft/hide flags, enabling submissions, or confirming the course and week.
Code Runner Challenge
Authoring draft - spring rest endpoint exercise is not ready
View IPYNB Source
// CODE_RUNNER: Authoring draft - spring rest endpoint exercise is not ready
public class RestEndpointDraft {
public static void main(String[] args) {
throw new UnsupportedOperationException("Draft: author a controller/repository exercise and tests before publication.");
}
}
RestEndpointDraft.main(null);
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...