Annotating C++ code for generating swagger json/yaml - swagger

I know that there is a way to generate the client-side code from the swagger yaml with swagger-codegen, but is there a way to generate the swagger yaml with the C++ annotations similar to what can be done in Java.
There seem to be annotation libraries available for other languages e.g python C# (https://swagger.io/blog/api-development/swagger-annotation-libraries/) but I am not able to find any support for C++.

I don`t think so. 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
Update:
I'm not quite sure if oatpp-swagger can fit your requirements.

Related

How can I diff Swagger to compare and find the differences of 2 versions

if I can get a guide on how I can use a diff tool or some inbuilt diff in swagger to compare 2 swagger API versions and then I can use it to add documentation notes.
If you use swagger 2 specification, you could use the swagger diff library.
There is a maven plugin for Java application : https://github.com/Sayi/swagger-diff
Or use Agnostic Java application by comparing the swagger file https://github.com/civisanalytics/swagger-diff
And for open api 3 specification you could use open api diff (you could find maven plugin or binary diff tool)
All these tools let to get a details report about the changed, breaking change between the specification file.
And then if you want, you could include the step in continuous integration step.
If you have only one file to describe all version api, you should find a way to split version file to execute the diff.

Grails 2: Is it possible to use swagger to document the APIs?

I'm attempting to create a prototype (using Grails 2) where we take advantage of swagger for our documentation.
As such, I had included the following in our BuildConfig.groovy:
compile "io.swagger:swagger-core:1.5.3"
compile "io.swagger:swagger-jaxrs:1.5.3"
And then I declared a bean in resources.groovy using the BeanConfig class provided by the above dependencies. And finally, I had just used the various annotations provided by the jaxrs dependency to document the controllers and their methods.
Everything was great until I realized that these are the older versions of swagger (as in, not OAS 3). I'm completely stumped as to how to use the new libraries.
Going through the documentation, I can pull in the dependencies like this in resources.groovy:
compile "io.swagger.core.v3:swagger-core:2.0.5"
But I have no idea what class I can use to initialize swagger. Where do I defined which packages it needs to scan? What class can I use to generate the swagger JSON?
I realize that there are plugins (like swaggydoc) but these are not maintained, and thus I would rather not use them.
Ideally, I would use the libraries provided by swagger themselves.
It's all just java code, and so I feel like I should be able integrate it with grails 2, especially since it worked with the old swagger libraries. But I need some help getting started.

What is the different between io.swagger.annotations and com.wordnik.swagger.annotations

I am new to swagger and found there are two packages for swagger annotation: io.swagger.annotations and com.wordnik.swagger.annotations. I wonder what the difference is between them and what I should use?
The com.wordnik package is for the older swagger specifications, 1.x. As of swagger specification 2.0, the package is now io.swagger. The annotation signatures should be the same, just the package has changed.
These are different versions of swagger which go with different versions of other supporting software stack that you might be using.
I too came across these two a month ago when trying to integrate my application with swagger ui. I was using cxf 2.7.11, jackson 2.6.0 with spring 3.0.7 . I struggled a lot with com.wordnik (older version where swagger json is generated at url api_docs with usage of ApiListingResource etc) but then thought of implementing io.swagger (newer version) just to see the difference. Turned out that was the version i should have been using in the first place. Everything fell in place after that.
One addition in case others were wondering, too:
We used swagger version 1.3.13 which was called swagger-core_2.10. Initially I thought this may indicate a swagger API 2.X compatibility which it actually isn't: 2.10 is the bundled Scala version (mentioned here) This means means 25 MB of unecessary dependenies! So the current swagger version 1.5.X was rewritten in pure java and is much smaller in size. The scala version was moved to a separate project.

How to access the JSON created by swagger at compile time using Dropwizard Testing?

I have a simple Dropwizard application with swagger integrated and I want to access the JSON created by swagger at compile time using Dropwizard Testing. Is this possible, and If it is, please guide me how it can be done?
I assume you use swagger-core for the generation of your Swagger spec. Swagger-core is a runtime library and produces the documentation as part of your running application.
There is a community contribution of a maven plugin that you can use to generate static documentation during the build process. Keep in mind that it may differ from the output of swagger-core as it basically scans the annotations but does not necessarily employ the same business logic of the generation process.

wsdl generator for java code

Can someone please recommend me a good tool to generate wsdl from java code?
For JAX-WS, read this post JAX-WS's wsgen tool.
Most of the open source frameworks provide this feature. Below are two
Axis
CXF

Resources