Cuba Platform Custom Controller Not Showing in Swagger

240 Views Asked by At

I created a custom rest controller in cuba platform and followed the instruction in Docs https://doc.cuba-platform.com/restapi-7.1/#rest_api_v2_custom_auth

My "rest-dispatcher-spring.xml"

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:security="http://www.springframework.org/schema/security"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-4.3.xsd">


    <context:component-scan base-package="com.company.test.web.resource"/>
</beans>

Added the "rest-dispatcher-spring.xml" to "web-app.properties"

cuba.restSpringContextConfig = +com/company/test/rest-dispatcher-spring.xml

My controller looks like this

package com.company.test.web.resource;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

@RestController
@RequestMapping("/test")
public class TestResource {

    @RequestMapping(value = "/testAPI", method = RequestMethod.GET, produces = APPLICATION_JSON_VALUE)
    public ResponseEntity testAPI() {
        return new ResponseEntity<>(HttpStatus.OK);
    }
}

I am able to call the API from Postman, but the API is not showing in Swagger-ui using URL

http://localhost:8080/app/rest/v2/docs/swaggerDetailed.yaml
1

There are 1 best solutions below

0
Andrey Subbotin On

Custom Spring MVC controllers are not counted in the detailed swagger documentation. Swagger documentation includes only:

  • entities,
  • queries,
  • REST services.