JSONDoc doesn't detect @ApiObject annotation of models in multimodule projects

477 Views Asked by At

With Spring Boot, JsonDoc nicely detects all the controllers but it doesn't detect models which are located in another maven module.

Our project has 2 modules:

  • my-app-core
  • my-app-impl

The main controllers as well as properties files e.g. application.properties are located in my-app-core and the followings are jsondoc's configurations:

# mandatory configuration
jsondoc.version=1.0
jsondoc.basePath=http://localhost:8090
jsondoc.packages[0]=com.myapp
jsondoc.packages[1]=com.myapp.api.docs.GlobalDocumentation
jsondoc.packages[2]=com.myapp.api.docs.ChangeLogDocumentation
jsondoc.packages[3]=com.myapp.api.jsonapi.model
# optional configuration
jsondoc.playgroundEnabled=true
jsondoc.displayMethodAs=URI

The package com.myapp.api.jsonapi.model is in the other module my-app-impl and JSONDoc doesn't detect them.

Below is a sample annotated model

@JsonApiResource(type="advisers")
@ApiObject(description = "Adviser model")
public class Adviser {
    @JsonApiId
    @ApiObjectField(description = "ID")
    private Integer id;
    @ApiObjectField(description = "Adviser's name")
    private String name;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}
1

There are 1 best solutions below

2
yaosing yao On

I also met this problem.My Jsondoc version is 1.2.19.
I found this issue on GitHub:
https://github.com/fabiomaffioletti/jsondoc/issues/244
They may caused with same reason.
The code just detect the method with @RequestMapping annotation and if you not use it as method's param or return value, it can't find the Adviser Object.
Hope this is helpful!