cancel
Showing results for 
Search instead for 
Did you mean: 

Openapi working in postman and not working in swagger-ui

Highlighted
Occasional Visitor

Openapi working in postman and not working in swagger-ui

After generating endpoints from Openapi i am getting 501 error(method unimplemented) in Swagger-UI.

However when using postman its working fine.

The following endpoint was generated using openapi

@Controller
@RequestMapping("${openapi.customerKyc.base-path:}")
public class CustomerApiController implements CustomerApi {
    private final NativeWebRequest request;
    @org.springframework.beans.factory.annotation.Autowired
    public CustomerApiController(NativeWebRequest request) {
        this.request = request;
    }
    public ResponseEntity<Void> createCustomer(@ApiParam(value = "create customer"  )  @Valid @RequestBody CustomerDto customerDto) {
        return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
    }

}

Together with the following interface

 

@Validated
@Api(value = "customer", description = "the customer API")
public interface CustomerApi {

    @ApiOperation(value = "", nickname = "createCustomer", notes = "", tags={ "customer", })
    @ApiResponses(value = { 
        @ApiResponse(code = 201, message = "Created"),
        @ApiResponse(code = 405, message = "Invalid input") })
    @RequestMapping(value = "/customer/create",
        consumes = { "application/json" },
        method = RequestMethod.POST)
    ResponseEntity<Void> createCustomer(@ApiParam(value = "create customer"  )  @Valid @RequestBody CustomerDto customerDto);

}

Rest Endpoint implementation :

@RestController
@RequestMapping("create")
public class CustomerController implements CustomerApi {
    @Override
    @PostMapping("customer")
    public ResponseEntity<Void> createCustomer(@Valid CustomerDto customerDto) {
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
}

Executing the above in postman works perfect.however in swagger-ui it results in 501 error.

 

What might be the issue ?

New Here?
Join us and watch the welcome video:
Top Kudoed Authors