私はApacheのcxfプロジェクトでswaggerを使用し、@Apiと@ApiOperationsと@ApiParamアノテーションを使用し、残りのサービスのためにAPIドキュメントを生成しました。swaggerレスポンスからモデルやプロパティを除外
しかし、私は、EntityTag、StatusType、MediaTypeなどのフィールドの一部をModels属性または完全なモジュールまたはプロパティ属性から除外したいと考えています。
どうすればよいですか?
私はdbからデータを取得してそれをユーザーオブジェクトに設定し、そのユーザーオブジェクトをJAX-RSレスポンスビルダーに渡していました。
以下は私のDTOオブジェクトのいずれかです。
@ApiModel
public class User{
private String name;
private String email;
@ApiModelProperty(position = 1, required = true, notes = "used to display user name")
public int getName() {
return name;
}
public void setName(String name) {
this.name= name;
}
@ApiModelProperty(position = 2, required = true, notes = "used to display user email")
public int getEmail() {
return email;
}
public void setEmail(String email) {
this.email= email;
}
は、今私はJSON形式返さ闊歩内のユーザーオブジェクトのフィールドやプロパティが表示されません。
私のサービスクラスのメソッドの応答は次のとおりです。すべての
@GET
@ApiOperation(value = "xxx", httpMethod = "GET", notes = "user details", response = Response.class)
public Response getUserInfo(){
User userdto = userdaoimpl.getUserDetails();
ResponseBuilder builder = Response.ok(user, Status.OK), MediaType.APPLICATION_JSON);
builder.build();
}
<bean id="swaggerConfig" class="com.wordnik.swagger.jaxrs.config.BeanConfig">
<property name="resourcePackage" value="com.services.impl" />
<property name="version" value="1.0.0" />
<property name="basePath" value="http://localhost:8080/api" />
<property name="license" value="Apache 2.0 License" />
<property name="licenseUrl"
value="http://www.apache.org/licenses/LICENSE-2.0.html" />
<property name="scan" value="true" />
</bean>
どのswagger-coreのバージョンをお使いですか? – Ron