Does OpenWhisk support OpenAPI 3.x specification? - openwhisk

Is it possible to import OpenAPI/Swagger 3.0 specification file to create APIs in OpenWhisk? I am able to import 2.0 specification file, but when I convert the file to 3.0, I hit the following error.
error: Unable to parse swagger file: Swagger file is invalid (missing basePath, info, paths, or swagger fields)
I am using open source OpenWhisk on self hosted Kubernetes cluster, not the one hosted on IBM Cloud.

Not yet but the project welcomes contributions. Some of the route management API and the OpenWhisk CLI will require adjustments to align the schema with OpenAPI.

Related

How to Generate Swagger File For Azure Java Function

I Have Azure HttpTrigger Java functions(get, Post) Those are Working Fine in Postman but, as per the Client Requirement I need To create swagger UI file for all those functions(Java) i am searching Refference stuff from lastweek, stil i did not get it,So plese any one share/guide/help me
How to craete Azure HttpTriggerr Java function project with Springboot Application?
How to add Swagger Configuration to it?
How to craete Azure HttpTriggerr Java function project with Springboot Application?
Following this MS Doc, created the Azure Functions Http Trigger in Spring boot.
1st Step is cloning the basic Function code of Sprint Boot Azure Functions Application.
Step 2: In pom.xml, you have to change these properties accordingly:
<functionResourceGroup>HariTestRG</functionResourceGroup>
<functionAppName>my-spring-function-app</functionAppName>
Step 3: Clean and build the packages ./mvnw clean package and then run using the cmdlet ./mvnw azure-functions:run
Next is to deploy the function code to Azure Function App:
./mvnw azure-functions:deploy
Result:
How to add Swagger Configuration to it?
Go to the Azure Portal > Deployed Function App > Click on API Management on left Index > Import the Function App APIs in APIM Instance > Then you'll see the Open API Definition which generates the swagger UI file for all the functions:

Generate OpenAPI spec from gin project

Is there a way to generate OpenAPI spec files from a gin project? This issue is really hard to search for, all I could find so far are on doing there reverse.
gin-swagger is extracting comments from your code.
Running swag init generates :
docs.go: To serve SwaggerUI pages
swagger.json: The Swagger Specification in json file format.
swagger.yaml: The Swagger Specification in yaml file format.
You mean API docs for API user?
I saw you tag the question with swagger.
You have two chooses:
go-swagger
This package contains a golang implementation of Swagger 2.0 (aka OpenAPI 2.0): it knows how to serialize and deserialize swagger specifications.
swag
Swag converts Go annotations to Swagger Documentation 2.0. We've created a variety of plugins for popular Go web frameworks. This allows you to quickly integrate with an existing Go project (using Swagger UI).
What difference between them?
Here is the answer from go-swagger:
The main difference at this moment is that this one actually works...
The swagger-codegen project (like swag) only generates a workable go client and even there it will only support flat models. Further, the go server generated by swagger-codegen is mostly a stub.
Detail of this answer in How is this different from go generator in swagger-codegen?
from go-swagger.

Automatic OpenAPI YAML generation

I am working on the backend of a Spring Boot application that uses OpenAPI and Swagger to provide the interface for frontend application via an schema.yml file.
When a change is done on the controllers, we use the swagger-ui to get the api-docs JSON, convert it to yaml using the online swagger editor and paste the result in th schema.yml file
Now, I want to automate this so that we can just call a maven task that will automatically generate the yaml file, but I could not find any maven plugin that does this.
Is there a way to automate the generation of the yaml file or do I need to write my own plugin?

What is the best way to version the yaml files?

I'm working on a API project on a hybrid cloud. APIs are hosted on-premise and via the cloud service (Azure API Management service), the APIs are exposed to the external world. For any APIs, we are writing the contract in Open API Specification as Yaml file manually and then import it into Azure APIM. Everytime yaml is imported in APIM, the version number in the Yaml get's reset to 1.0, even though it is something different in the Yaml file (unless we modify it manually after the import). This is creating confusion on what version is in the cloud vs what version is there locally. So, I'm looking for option if anybody faced this issue and how did they resolve it? One of the workaround solution that we have been doing is writing the version number in description when revising the version in Azure APIM.
You could create a new version of an existing API and then import your updated OpenAPI spec using the update method as below
Also, something that you might already be doing is to maintain your OpenAPI specs in a git repository for version control since its like any file.

Mocking Rest Api with Swagger Documentation

Whole idea is to create Mock service for UI guys to test without actual api.
- We have define specification in .ymcl files.
- Now want to generate Swagger-UI and Mock rest URI with mock data.
- Using spring-boot.
Please suggest some way to generate the same.
Given that you've the API documented in Swagger/OpenAPI spec (YAML format), you can use Swagger Codegen to generate Spring boot server stub.
Please pull the latest master of https://github.com/swagger-api/swagger-codegen and follow the instruction in the wiki:
https://github.com/swagger-api/swagger-codegen/wiki/Server-stub-generator-HOWTO#java-springboot

Resources