Combine swagger Definition files - swagger

I am generating a swagger definition for all the my APIs by annotating the source code.
I was wondering if there is any way for make possible merge all the APIs in one single json file?
Note: I am using Swagger 2.0 definitions.

If you deploy those apps in a WebSphere Liberty server with the apiDiscovery-1.0 feature defined in your server.xml, then you can simply go into (GET) /ibm/api/docs and retrieve your aggregated JSON file. You can also retrieve it as YAML, by adding the Accept header "application/yaml".
You can download it for free at wasdev.net then just run the installUtility command to grab the feature (wlp/bin installUtility install apiDiscovery-1.0).
More information in this blog: https://developer.ibm.com/wasdev/blog/2016/04/13/deploying-swagger-enabled-endpoints-websphere-liberty-bluemix-api-connect/

Related

Jenkins JSON API - Locate Build, Build Environment, and Build Trigger API data

I am working with the Jenkins API JSON.
I understand the format to retrieve API data in JSON
<Jenkins_URL>/job/<job_name>/api/json
Within the job/<job_name>/configure UI we can configure/add Build triggers, build env, and build data.
I want to be able to view the Build, Build Env, and Build Triggers data in a JSON API.
Is it even possible to get said data? What are alternative ways to get all available data that is found in the configure page of a job?
I think the most straightforward way is to access <Jenkins_URL>/job/<job_name>/config.xml.
Yes, it's not JSON, but you can be sure that this contains everything that was configured on the configuration page.
The XML file is the "native" serialized version of the Job configuration. The JSON API will always require some additional glue that may exist or not exist.

How does swagger-codegen automatically generate applications and dockerfiles?

I want to clarify the generation process of applications and dockerfiles. In order to understand this, I have drawn a graph to represent the flow based on my understanding of the documentation and source code. I will be glad if someone takes a look and corrects or approves the schema. The flow tries to describe the generation of NodeJS application from a Java application.
The swagger-codegen doesn't generate the template files, it uses the template files that are written by the (insert language here) codegen developer(s).
I assume the schema you've drawn is the flow of the NodeJSCodeGen because not every supported language generates a dockerfile.
Personally I would replace the Java microservice -> generates Model with OpenAPI specification -> Code Generator, as the generator uses the specification. It doesn't matter if you generated it from from a micro service or if you went with the API first approach.

How to keep Postman collections and tests in sync with swagger/open api specs and git in a CI flow

We are investigating whether we can incorporate Postman Test Runner and Newman into an API testing flow with our Jenkins CI server.
My question is this: once I import a swagger/Open API file into a Postman collection, how can I keep changes from multiple team members in sync?
For example, if a team member adds a new api endpoint to the swagger file, do we have to re-import the swagger file into a postman collection overwriting it? We'd like to keep using the swagger file as the single source of truth so would like to keep that in sync with the postman collection. Ideally we would update the swagger file, commit it to git and get its changes synced to postman.
What about tests created in postman? Is there a way to keep that checked into git? Would we have to export the collection after each test change and check that into git, and re-import changes to postman collections after each git pull?
It looks like since some of the online postman features are built for sharing - the idea is that you would make a change to the collection directly in the postman client and that gets shared out to other postman clients? If so, is there a hook that can be added to sync those changes to git automatically?
To answer your questions in order:
Once I import a swagger/open api file into a postman collection, how
can I keep changes from multiple team members in sync?
To keep your collections in sync everyone will need to sign in and use a team workspace. As of Postman 6.2 a single team workspace is now free.
https://www.getpostman.com/docs/v6/postman/workspaces/intro_to_workspaces
For example, if a team member adds a new api endpoint to the swagger file, do we have to re-import the swagger file into a postman collection overwriting it?
Depends on how you are generating the file. If it is being generated using a run-time tool (e.g., NSwag, Swashbuckle) then you'll most likely end up needing to overwrite the file. If you have a swagger.json your team is directly maintaining, you can probably modify the scripts Postman provides to keep your definitions in sync with Postman: http://blog.getpostman.com/2018/03/02/sync-your-specs/
What about tests created in postman? Is there a way to keep that checked into git?
Yes. You can export Postman collections which include your tests and check those into Git.
If so, is there a hook that can be added to sync those changes to git automatically?
Answered on SO here.

XDT transformation for JSON in VSTS?

Is there any tool which can transform JSON as well similar to XDT transformations for XML files?
thanks
Azure App service deploy task has a variable substitution option supporting json files. You have to provide json file paths and you can use wild cards in the path. You can define the substitute variables and values in the task so that they will be applied in the deployment. However for on-premises IIS deployments there is no task supporting json file variable substitution support as of now. More information on the json variable substitution is here
This vsts task source code can be found in here you may inspect the implementation logic there and define your own component to do the substitution of json variables.

Swagger and Jenkins integration

So we have Swagger UI and YAML file manually generated by a developer. The plan is to use Jenkins to validate our API endpoints (request and response schemas) using the Swagger schema. Is there a way to do that?
Please check Sagger Diff. This CLI tool shows breaking changes between 2 different swagger json files
http://swagger.io/using-swagger-to-detect-breaking-api-changes/

Resources