swagger - Vert.x 的基于注释的 Swagger 文档

标签 swagger swagger-ui vert.x swagger-editor swagger-codegen

是否有任何可用于 Vert.x 的基于注释的 Swagger 文档创建者?其余端点都是使用路由器管理的,因此,如果有任何方法可以生成 Swagger 文档,那就太好了。
我已经使用各种注释浏览了基于 Java Jersey 的文档创建器,但找不到 Vert.x 文档的任何内容。 Git Hub 上的官方 swagger wiki 也不包含任何与 Vert.x 文档相关的文档。

最佳答案

自从提出这个问题以来,Swagger 被命名为 OpenAPI,Vert.x 提供了 Web API Contract模块。使用这个anupsaund创建了vertx-auto-swagger repo (又基于 vertx-openapi-spec-generator )。它确实:

  • Read Java Annotations and map them into a openAPI spec.
  • Serve the openAPI spec out on an end point.
  • Serve a distributable version of SwaggerUI which presents the swagger spec from point 2.


然后允许注释如下:

@Operation(summary = "Find products by ID", method = "GET", operationId = "product/:productId",
    tags = {
        "Product"
    },
    parameters = {
        @Parameter(in = ParameterIn.PATH, name = "productId",
                required = true, description = "The unique ID belonging to the product", schema = @Schema(type = "string"))
    },
    responses = {
        @ApiResponse(responseCode = "200", description = "OK",
            content = @Content(
                mediaType = "application/json",
                encoding = @Encoding(contentType = "application/json"),
                schema = @Schema(name = "product", example =
                    "{" +
                            "'_id':'abc'," +
                            "'title':'Red Truck'," +
                            "'image_url':'https://images.pexels.com/photos/1112597/pexels-photo-1112597.jpeg'," +
                            "'from_date':'2018-08-30'," +
                            "'to_date':'2019-08-30'," +
                            "'price':'125.00'," +
                            "'enabled':true" +
                            "}",
                    implementation = Product.class)
            )
        ),
        @ApiResponse(responseCode = "404", description = "Not found."),
        @ApiResponse(responseCode = "500", description = "Internal Server Error.")
    }
)

关于swagger - Vert.x 的基于注释的 Swagger 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44700652/

相关文章:

php - 如何在swagger api中发布数组

spring-mvc - spring-mvc如何改变swagger-ui的路径

java - Vert.x 启动应用程序和配置文件的方式

java - 我如何在我的 vert.x 应用程序中使用独立的 log4j 实例?

java - Spring 验证 + Swagger 文档 : Based on conditions or values of other fields

swagger - 我可以在引用参数定义对象时覆盖它的属性吗?

swagger-ui - SwaggerUIBundle 和 SwaggerUi 有什么区别

java - 如何使用 Swagger 生成的客户端 (Feign)

java - swagger ui 不从通用字段中选取 apimodelproperty 注释

hazelcast - vert.x 事件总线在扩展方面是否有限制