wkennedy / swagger4spring-web

Swagger support for Spring MVC
89 stars 46 forks source link

What are the preconditions for having a response properly show up in the documentation? #43

Open MartinAhrer opened 10 years ago

MartinAhrer commented 10 years ago

I have a controller that basically is shown in the swagger UI. However, its response type is not resolved properly. Only the fully qualified class name is shown without the structural drill-down on the TestResource type properties.

Response Class
Model  Model Schema
web.controller.UserGroupController$TestResource
@Controller
@RequestMapping(value = UserGroupController.REQUEST_MAPPING_PATH, produces = {"application/json"})
public class UserGroupController {
    public static final String REQUEST_MAPPING_PATH = "/entities";

    @RequestMapping(value = "/{reference}", method = RequestMethod.GET, produces = "application/json")
    @ApiOperation(value = "Find an entity", response = TestResource.class, produces = "application/json", httpMethod = "GET")
    public @ResponseBody TestResource entity(@NonNull @PathVariable UUID reference) {
        return new TestResource(reference.toString());
    }
    @ApiModel(value = "Test resource")
    public static class TestResource {
        @ApiModelProperty(value = "Name")
        private String name;
        public TestResource(String name) {
            this.name = name;
        }
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
    }
}

The documentation controller performs the setup for the packages:

@Controller
@RequestMapping(value = DocumentationController.REQUEST_MAPPING_PATH)
public class DocumentationController extends ApiDocumentationController {
    public static final String REQUEST_MAPPING_PATH = "/documentation";
    public DocumentationController() {
        setBaseControllerPackage("web.controller");
        setBaseModelPackage("web.controller");
        setAdditionalModelPackages(Arrays.asList(new String[] {"web.controller"}));
        setApiVersion("TODO");
    }

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String documentation() {
        return "documentation";
    }
}

I'm using the 0.3.1 release.

mayonesa commented 9 years ago

same here