首页 > 解决方案 > OpenAPI、Swagger 和 Lombok

问题描述

我一直在寻找一种集成 OpenAPI、Swagger 和 Lombok 的解决方案。OpenAPI 定义不显示参数。示例基础实体:

@Data
@NoArgsConstructor
@AllArgsConstructor
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;
    
    public BaseEntity setId(Long id) {
        this.id = id;
        return this;
    }
}

标签: javaspring-bootswaggeropenapilombok

解决方案


问题是什么?可能值得看看 springfox 的 Swagger 实现。只需将依赖项添加到您的 pom 或 build.gradle 并运行 springboot 应用程序并访问 localhost:8080/swagger-ui.html

https://springfox.github.io/springfox/


推荐阅读