22 October 2020

#Spring_Rest

#Spring_Rest

Key Concepts


Topic SubTopic (comma separated) Basic Intermediate Advanced Expert
Introduction to REST What is REST, REST Principles, HTTP Methods (GET, POST, PUT, DELETE), Idempotency
Spring REST Overview Spring MVC, @RestController, @RequestMapping, DispatcherServlet
Request Handling @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping
Path and Query Parameters @PathVariable, @RequestParam, Default Values, Optional Parameters
Request and Response Bodies @RequestBody, @ResponseBody, JSON and XML Conversion, HttpMessageConverter
Content Negotiation Produces/Consumes, MediaType, Accept Headers, Custom Converters
ResponseEntity & HTTP Status Codes ResponseEntity, HttpStatus, Custom Responses, Standard REST Practices
Exception Handling @ExceptionHandler, @ControllerAdvice, Custom Error Response, Global Exception Handling
Validation @Valid, @NotNull, @Size, BindingResult, Custom Validators
Data Binding & Conversion @InitBinder, Type Conversion, Formatters, Custom Converters
CORS (Cross-Origin Resource Sharing) @CrossOrigin, Global CORS Config, Security Config Integration
HATEOAS (Hypermedia as the Engine of Application State) HATEOAS Concepts, RepresentationModel, Link Building, HAL Format
Pagination & Sorting Pageable, Page, Sort, Spring Data REST Pagination
Filtering and Projection Request Filtering, DTO Projection, Jackson Views, Dynamic Fields
File Upload & Download MultipartFile, File Upload Endpoint, Download Response, MediaType Config
Spring Data REST RepositoryRestResource, Exposing Repositories, Projections, Excerpts
Versioning REST APIs URI Versioning, Header Versioning, Media Type Versioning, Best Practices
API Documentation Swagger (Springfox), OpenAPI 3, SpringDoc Integration, Custom Documentation
Security in REST Basic Auth, JWT, OAuth2, CSRF Protection, Secure Endpoints
Testing REST APIs MockMvc, WebTestClient, RestTemplate, TestRestTemplate, Integration Testing
RestTemplate GET/POST Requests, Error Handling, Exchange Method, Interceptors
WebClient (Reactive) Mono, Flux, Reactive Streams, Asynchronous Calls, Error Handling
Asynchronous REST Processing @Async, Callable, DeferredResult, CompletableFuture
Caching in REST APIs ETag, Cache-Control, Conditional GET, Spring Cache Integration
Rate Limiting API Throttling, Bucket4j, Redis-based Rate Limiting, Gateway Integration
API Gateway Integration Spring Cloud Gateway, Routing, Filters, Rate Control
Hypermedia and HAL Explorer HAL Browser, Link Discovery, Hypermedia Controls
Reactive REST (Spring WebFlux) Router Functions, Handler Functions, Functional Endpoints
Error Response Design Problem Details RFC 7807, Custom Error JSON, Validation Error Models
Metrics & Observability Micrometer, Prometheus, API Performance Metrics, Logging
Performance Optimization Connection Pooling, Async Calls, Compression, Lazy Loading
Internationalization (i18n) MessageSource, LocaleResolver, Error Message Localization
REST API Design Patterns DTO Pattern, Builder Pattern, Adapter Pattern
Best Practices Naming Conventions, Consistent HTTP Status Codes, Statelessness, Documentation
Deployment Containerization, Docker, Kubernetes, CI/CD Integration
Resilience & Fault Tolerance Circuit Breaker, Retry Mechanisms, Fallback, Resilience4j Integration
Advanced REST Patterns Richardson Maturity Model, Idempotency Keys, Long Polling
GraphQL vs REST Comparison, Use Cases, Coexistence Strategies
Event-driven REST APIs Webhooks, SSE (Server-Sent Events), Event Streaming
Real-world Scenarios Building CRUD APIs, E-commerce API, Authentication API
API Monitoring Logging, Tracing, Distributed Tracing, ELK Stack Integration

Interview question

Basic Level

  1. What is REST, and what does it stand for?
  2. What are the key principles of RESTful architecture?
  3. What are the main HTTP methods used in REST APIs?
  4. What is the difference between PUT and POST methods?
  5. What is idempotency in REST, and which methods are idempotent?
  6. What annotations are used to create RESTful web services in Spring?
  7. What is the purpose of @RestController in Spring?
  8. What is the difference between @Controller and @RestController?
  9. What does @RequestMapping do in Spring REST?
  10. How do you map different HTTP methods using annotations?
  11. What is the use of @PathVariable and @RequestParam?
  12. How do you handle JSON request and response in Spring REST?
  13. What is the role of @ResponseBody?
  14. What is ResponseEntity, and when should it be used?
  15. How do you return custom HTTP status codes from a REST endpoint?
  16. What is content negotiation in REST?
  17. What is the default format used by Spring REST for responses?
  18. How do you enable XML support in Spring REST?
  19. What is the function of HttpMessageConverter?
  20. What is the purpose of the @Valid annotation in REST APIs?
  21. What is a DTO in REST, and why is it used?
  22. How do you handle path variables with multiple values?
  23. How do you pass query parameters in a GET request?
  24. What is a REST client? Give examples in Spring.
  25. What are the main advantages of using RESTful APIs?

Intermediate Level

  1. What is exception handling in Spring REST?
  2. How do you use @ExceptionHandler for handling exceptions?
  3. What is @ControllerAdvice, and how does it work?
  4. How do you create a global error handler in Spring REST?
  5. What are the different HTTP status codes commonly used in REST APIs?
  6. How do you implement input validation using Spring Validator?
  7. How can you handle file uploads using Spring REST?
  8. How do you download files using Spring REST?
  9. What is the difference between @RequestBody and @ModelAttribute?
  10. What is CORS, and how do you enable it in Spring REST?
  11. How do you secure a REST API in Spring using Basic Authentication?
  12. How do you secure REST endpoints using JWT?
  13. How do you enable Swagger documentation in a Spring REST project?
  14. What is OpenAPI, and how does it relate to SpringDoc?
  15. How can you test REST endpoints using MockMvc?
  16. What is the use of RestTemplate in Spring?
  17. What are the drawbacks of RestTemplate compared to WebClient?
  18. What is WebClient, and how is it different from RestTemplate?
  19. How do you consume external APIs in Spring REST?
  20. How do you use query parameters with RestTemplate?
  21. What is the use of ResponseEntityExceptionHandler?
  22. How do you enable pagination and sorting in REST APIs?
  23. How do you handle validation errors in REST responses?
  24. What is @JsonIgnore used for in Spring REST?
  25. How do you implement a simple CRUD REST API in Spring Boot?

Advanced Level

  1. What is HATEOAS in Spring REST?
  2. What are the benefits of HATEOAS in RESTful APIs?
  3. How do you add links using RepresentationModel?
  4. What is the HAL format in Spring HATEOAS?
  5. How do you enable content negotiation for different clients?
  6. What are some common REST API design best practices?
  7. How do you handle versioning in REST APIs?
  8. What are the different approaches to versioning APIs in Spring?
  9. How do you implement custom exception responses?
  10. How do you log requests and responses in Spring REST?
  11. How do you implement a retry mechanism for failed REST calls?
  12. How do you implement caching in REST APIs?
  13. What is ETag, and how is it used for caching?
  14. How do you set custom HTTP headers in a response?
  15. How do you use filters or interceptors in Spring REST?
  16. What is the difference between a filter and an interceptor?
  17. How can you improve REST API performance?
  18. How do you implement rate limiting in Spring REST?
  19. What is Spring Data REST, and when should you use it?
  20. How does RepositoryRestResource work in Spring Data REST?
  21. What is the difference between Spring MVC and Spring WebFlux?
  22. How do you make asynchronous REST calls in Spring?
  23. What are functional endpoints in Spring WebFlux?
  24. How do you handle backpressure in reactive REST APIs?
  25. What are the pros and cons of using reactive programming in REST APIs?

Expert Level

  1. How do you design fault-tolerant REST services using Resilience4j?
  2. What is a circuit breaker, and how is it used in REST APIs?
  3. How do you use Retry and Fallback patterns in REST?
  4. How can you integrate Spring REST with an API Gateway?
  5. How do you handle distributed tracing across multiple REST services?
  6. What is Micrometer, and how do you use it to monitor REST endpoints?
  7. How do you integrate Prometheus or Grafana with Spring REST metrics?
  8. How can you log REST request latency and throughput?
  9. What are the strategies to avoid over-fetching and under-fetching in APIs?
  10. What is Richardson Maturity Model (RMM)?
  11. How do you achieve Level 3 of Richardson Maturity Model in REST?
  12. How do you handle long-running REST operations asynchronously?
  13. What is Server-Sent Events (SSE) in Spring?
  14. How do you implement SSE using Spring WebFlux?
  15. How can you implement an event-driven REST API?
  16. How do you design REST APIs for microservices communication?
  17. What is the difference between REST and GraphQL?
  18. How can REST and GraphQL coexist in a single application?
  19. How do you secure REST APIs using OAuth2 in Spring?
  20. What is token introspection, and how does it work in OAuth2?
  21. How do you manage role-based access control in REST APIs?
  22. How can you externalize API configurations using Config Server?
  23. How do you deploy Spring REST microservices in Kubernetes?
  24. What are the best practices for REST API logging and monitoring?
  25. How do you ensure backward compatibility in evolving REST APIs?

Related Topics