다음 두 엔티티 클래스가 있습니다.다른 jar 파일에있는 엔티티 클래스에서 ApiModel 및 ApiModelProperty 주석을 검색하지 않습니다.
는제 클래스 SampleApiEntity
이다
package my.company.rest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Type;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@ApiModel (
value = "SampleApiEntity",
description = "This is a sample entity from the Api package."
)
@Entity
public class SampleApiEntity
implements Serializable
{
public SampleApiEntity() {}
private static final long serialVersionUID = 1L;
@Column (nullable = false)
@ApiModelProperty (
value = "level",
required = true
)
private Integer level;
@Column (length = 255)
@ApiModelProperty (
value = "description"
)
private String description;
@Column (nullable = false)
@ApiModelProperty (
value = "time",
required = true
)
private Timestamp time;
@Id
@Column (
unique = true,
nullable = false
)
@Type (type = "pg-uuid")
@ApiModelProperty (
value = "id",
readOnly = true,
dataType = "uuid",
example = "123e4567-e89b-12d3-a456-426655440000"
)
private UUID sampleApiEntityId;
public String getDescription()
{
return this.description;
}
public Integer getLevel()
{
return this.level;
}
public UUID getSampleApiEntityId()
{
return this.sampleApiEntityId;
}
public Timestamp getTime()
{
return this.time;
}
public void setDescription (String description)
{
this.description = description;
}
public void setLevel (Integer level)
{
this.level = level;
}
public void setSampleApiEntityId (UUID sampleApiEntityId)
{
this.sampleApiEntityId = sampleApiEntityId;
}
public void setTime (Timestamp time)
{
this.time = time;
}
}
번째 클래스 SampleModelEntity
이다
package my.company.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.annotations.Type;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@ApiModel (
value = "SampleModelEntity",
description = "This is a sample entity from the Model package."
)
@Entity
public class SampleModelEntity
implements Serializable
{
public SampleModelEntity() {}
private static final long serialVersionUID = 1L;
@Column (nullable = false)
@ApiModelProperty (
value = "level",
required = true
)
private Integer level;
@Column (length = 255)
@ApiModelProperty (
value = "description"
)
private String description;
@Column (nullable = false)
@ApiModelProperty (
value = "time",
required = true
)
private Timestamp time;
@Id
@Column (
unique = true,
nullable = false
)
@Type (type = "pg-uuid")
@ApiModelProperty (
value = "id",
readOnly = true,
example = "123e4567-e89b-12d3-a456-426655440000"
)
private UUID sampleModelEntityId;
public String getDescription()
{
return this.description;
}
public Integer getLevel()
{
return this.level;
}
public UUID getSampleModelEntityId()
{
return this.sampleModelEntityId;
}
public Timestamp getTime()
{
return this.time;
}
public void setDescription (String description)
{
this.description = description;
}
public void setLevel (Integer level)
{
this.level = level;
}
public void setSampleModelEntityId (UUID sampleModelEntityId)
{
this.sampleModelEntityId = sampleModelEntityId;
}
public void setTime (Timestamp time)
{
this.time = time;
}
}
두 클래스 간의 유일한 차이점은 이들이 별개의 JAR 파일에 정의되어있다. SampleApiEntity
은 REST 자원 클래스와 동일한 JAR에 패키지되어 있습니다. SampleModelEntity
은 다른 엔티티 클래스와 별도의 JAR에 패키지되어 있습니다. 생성 된 swagger.yaml
파일은 두 클래스를 모두 포함하지만 SampleModelEntity
클래스의 ApiModel
및 ApiModelProperty
주석에 의해 제공된 정보가 부족합니다.
SampleApiEntity:
type: "object"
required:
- "level"
- "time"
properties:
level:
type: "integer"
format: "int32"
description: "level"
description:
type: "string"
description: "description"
time:
type: "string"
format: "date-time"
description: "time"
sampleApiEntityId:
type: "string"
format: "uuid"
example: "123e4567-e89b-12d3-a456-426655440000"
description: "id"
readOnly: true
description: "This is a sample entity from the Api package."
SampleModelEntity:
type: "object"
properties:
level:
type: "integer"
format: "int32"
description:
type: "string"
time:
type: "string"
format: "date-time"
sampleModelEntityId:
type: "string"
format: "uuid"
사람은 ApiModel
및 ApiModelProperty
주석 swagger.yaml
에서 출력을 생성하지 않는 이유를 내가 이해하는 데 도움이 : 여기
내가 생성 된 swagger.yaml
파일에보고하고 무엇인가?
내가 어떤 연구를하고있다 그리고 나는 아래로 좁혀했습니다 발행물. 이 문제는'SampleModelEntity' 클래스가 REST 리소스 클래스와는 별도의 JAR에 패키지되어 있다는 사실 때문에 간단히 나타나지는 않습니다. REST 리소스 패키지의 pom.xml 파일에서'SampleModelEntity'를 포함하는 종속성 JAR이'제공된 '범위로 선언됩니다. 범위가 문제의 원인 인 것 같습니다. –