0

I have a simple API in spring boot using JpaRepository:

public interface UserRepository extends JpaRepository<User, Long> {...}

I'm able to create a user using POST API:

curl localhost:8080/users -i -X POST -H "Content-Type:application/json" -d '{"firstName": "Alik", "lastName": "Elzin", "username": "kilaka"}'

I'm also able update one of the fields of a user using PATCH:

curl localhost:8080/users/1 -i -X PATCH -H "Content-Type:application/json" -d '{"firstName": "Alikuki"}'

Swagger config:

@Configuration
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}

When using swagger to create the API as UI, I see the POST option and also a PUT option, but not the working PATCH API. See screecap below.

Any idea how I can make swagger generate the PATCH API?

enter image description here

AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277
  • Possible duplicate of [Swagger Is not able to produce documentation for HTTP "PATCH"](https://stackoverflow.com/questions/28585774/swagger-is-not-able-to-produce-documentation-for-http-patch) – Laurent B Mar 09 '18 at 08:43
  • Can you post your method/interface signatures including annotations? – Helen Mar 09 '18 at 08:53
  • @Helen - Added missing swagger config. There isn't any more configuration. Spring boot magic :) – AlikElzin-kilaka Mar 09 '18 at 20:38

0 Answers0