Reputation: 21
I have an existing vert.x project which became too heavyweight and intransparent.*
To replace it I am checking for several options, one of those being swagger.
Does anyone know an opensource lib which can create a swagger-api from vert.x?
Upvotes: 0
Views: 3759
Reputation: 664
Here's an open source project (for the JVM) that generates a Swagger/OpenAPI specification from your existing Vert.x router:
https://github.com/outofcoffee/vertx-oas
(Disclosure: It's my open source project)
Example usage:
// your normal Vert.x Web Router with paths etc.
Router router = Router.router(vertx);
router.post("/users").handler( routingContext -> { /* etc... */ });
router.get("/users/:userId").handler( routingContext -> { /* etc... */ });
// publish the Swagger/OpenAPI specification to a URL
RouterSpecGenerator.publishApiDocs(router, "/api/spec");
You can obtain YAML or JSON versions of the specification by adding the appropriate file extension.
For example, fetching /api/spec.yaml
would produce:
openapi: "3.0.1"
info:
title: "Vert.x APIs"
description: "This specification was generated from a Vert.x Web Router."
paths:
/users:
post:
parameters: []
/users/{userId}:
get:
parameters:
- name: "userId"
required: true
allowEmptyValue: false
Upvotes: 2
Reputation: 17711
I'm not aware of something like that. The only vertx-swagger integration does exactly the opposite: generates Vertx router based on Swagger configuration: https://github.com/phiz71/vertx-swagger
What you can do is generate all routes using this solution: List all registered routes in Vertx
Then add them manually to Swagger Editor, and finally generate your new APIs with Swagger Codegen
Do mind that rewriting you application into another language or framework probably won't solve your problems. NodeJS is not as typesafe as Vertx, and SpringBoot is not as concurrent as Vertx. But if you don't need typesafety or concurrency, both are viable options, of course.
Upvotes: 2