IntelliJ IDEA 2024.1 Help

Coding assistance for REST development

Besides the common Web services support, IntelliJ IDEA provides the following facilities for developing RESTful Web services:

Code Inspection and Quick Fixes

IntelliJ IDEA supports code inspections and suggests quick fixes in the following cases:

Issue

Default Quick Fix

Inconsistency between a method annotation and the method return type: a @GET annotated method returns void value.

Change to String.

Resource methods errors.

Remove @Path annotation.

Incorrect parameter type.

Validation for parameters annotated with @QueryParam or @PathParam annotations.

@DefaultValue issues.

@GET public String get(@DefaultValue("33.5") @QueryParam("str") int str) { return "Hello"; }

DefaultValue is marked red with the description "Can't convert to int".

Rest @Path and @PathParam annotations inspections.

Rest References resolve problems.

References in @PathParam annotations are resolved to templates in @Path annotations

This method should have only one HTTP method designator.

Example:

@GET @POST public String get(){ return "Hello"; }

@POST is marked red.

HTTP Client in Code Editor

The dedicated HTTP Client provides the following facilities for working with HTTP requests:

  • Gutter icons Generate request in HTTP Client for request method designator annotations, such as @GET, @PUT, @POST, or @DELETE to quickly compose and execute requests.

  • Displaying server responses and the executed requests history

  • Completing the HTTP request parts from the @Path and @Produces annotations specified in the Java code

Change in the Java code

Change in the HTTP request in editor

@Path annotation is updated.

The contents of the Request-URI suggestion list change when you invoke code completion Ctrl+Space.

@Produces annotation is updated.

The contents of the Accept header field suggestion list change when you invoke code completion Ctrl+Space.

Last modified: 04 April 2024