Is there a way to generate a swagger specification file from C++ code?
Asked Answered
K

2

11

I've a requirement to create a HTTP API layer over a legacy API interface written in C++. My plan is to generate the Swagger or open API file and then make it available to bunch of projects that needs to write a client (who will be consumer of new API) or a server (wrapper to legacy API).

Is there anything that can expedite this requirement (other than manually parsing them and creating swagger spec file)? i.e. using C++ code to generate swagger JSON/YML file

Krystakrystal answered 10/12, 2018 at 3:52 Comment(1)
You may take a look at github.com/oatpp/oatpp-swagger. It provides annotation - like swagger-ui generation. But it requires oatpp as your server frameworkEmileeemili
R
2

Quite late answer and I think that with no good news.

If you're talking about the implementation of Annotations in C++. As far as I know the Swagger Core Annotations are part of the Swagger Core Project, and in the documentation you can find:

Swagger Core is a Java implementation of the OpenAPI Specification. Current version supports JAX-RS2.

Also the Prerequisites says:

You need the following installed and available in your $PATH:

  • Java 8
  • Apache maven 3.0.4 or greater
  • Jackson 2.4.5 or greater
Richie answered 29/1, 2019 at 15:33 Comment(0)
S
-4

you've been tried Swagger Codegen is an API that serves for a bunch of languages inclusive C++

Scriber answered 17/1, 2019 at 13:59 Comment(1)
I'm looking for the opposite, swagger spec from code. Like Swagger2Feature serves swagger spec from JAX-RS service endpoints, I want the dynamic swagger definition created from the C++ code. Why? No manual swagger creation for a large number of endpoints. Also, any additions to service entry point will get the latest swagger. Here what I managed: Parsed the service endpoint definitions in the C++ code(used pycparser) got the specifics of service endpoint/operation and then generated the swagger from it.Krystakrystal

© 2022 - 2024 — McMap. All rights reserved.