Generate a Swagger spec from an API - api

I've build an API onto our Meteor backend, using Restivus. I would like to document it using Swagger, but the API is generated from MongoDB collections.
I would like to 'read' all the endpoints, and then generate a static Swagger file. Then I will update it from there. Is this possible?
eg: pass it something like :
http://servername.com/api/v1
And receive a listing of all available endpoints?

Related

Get source data from API

My team is trying to configure an Informatica job that pulls data from the SurveyCTO API. According to the documentation, the output is in CSV or JSON format.
I've seen this video and it looks like it's using ODBC to configure a JSON driver.
Is there a more direct / native way to connect to the API in Informatica? How can I setup the Informatica job to pull the data directly from the API?
Update
We were able to find the API Connector in our cloud PowerCenter and are trying to configure the Swagger file. We successfully created a Swagger file for a public API, but were unable to do so for our SurveyCTO API. We get an invalid URL error:
The SurveyCTO API URL is valid -- we tested it and it returned results, outside of Informatica.
Any ideas on what the issue could be?
References
Generating a Swagger file
HOW TO: Generate Swagger file in IICS

How to import the Google Chat API discovery document into a Postman collection?

I cannot get Postman to recognize https://chat.googleapis.com/$discovery/rest?version=v1
I normally import Swagger documents and it creates collections for me without any problems. But this is not a Swagger file, it's a Google "discovery document". I would have thought that Postman would somehow recognize this Google format but it doesn't. Is says: "Error while importing: format not recognized...".
My question: Without adding all methods separately, how do I "consume" / import this API in a / as a Postman collection?
I've not used it but you could try the Google Discovery to OpenAPI 3.x Converter, which converts Google discovery documents to OpenAPI (Swagger) format.

Generating OpenAPI definitions and documentation for an existing flask project

I'm trying to integrate an existing flask app with OpenAPI (Swagger), to generate its documentation and use Swagger UI. How should I do this?
The best solution (expected behaviour with least changes) for me was to use connexion, and use OpenAPI Specifications to replace the routes layer. Instead of using Flask "directly", a connection app was created.
app = connexion.App(__name__, specification_dir='swagger/')
app.add_api('my_api.yaml')
app.run(port=8080)
https://github.com/zalando/connexion

Adding header with username into request to backend in wso2 apimanager for all service

I am using apimanger 1.9.
I read this already : Add header with username into request to backend in wso2 apimanager.
I am able to add and forward username to backend in wso2 apimanager for specific service; but I want this for all service. I am modifying admin--<api_name>_<version>.xml for all services(50 services), which is very much manual. Something it leads to manual error.
Is there a single place configuration where I can set this (forward username to backend endpoint) for all service?
One more question - if I create and publish the APIs using "Publisher API" feature, is there a way to post something to set up the add header for each API?
Modify the velocity_template.xml which decides the template of an API. Please read my answer given to a similar requirement. You need to modify the relevant section in the velocity_template.xml.

Why create a separate application for RESTful API?

In the guide for Yii 2 it is said:
While not required, it is recommended that you develop your RESTful
APIs as a separate application, different from your Web front end and
back end for easier maintenance.
Source: RESTful Web Services - Quick Start
What does this mean? Would this be a completely different application or can it be in the same folder as the 'normal' web application? I've just started with my application so I can change things easily, more or less. But I'm wondering: if I would create another application than my business logic would not be accessible.
Why and how I should create another application? And when it's not required?
It means you have to create an application like frontend or backend(Yii 2 advanced application template),
what you have to do is create another directory call 'api' same as backend or frontend, and it'll contain folder structure same as backend|frontend except assets, views, widgets etc.
Basically you need folder structure like this
api
-config
-modules
--v1
---controllers
---models
-runtime
-tests
-web
backend
common
console
environments
frontend
If you'r going to use Yii 2 basic application template to develop rest api, it's posible. create module call 'api' and create a sub directory call 'v1' as sub-module.
(Yii doc -A module may consist of sub-modules.)(GiovanniDerks - backend sub-modules)
-modules
--api
---v1
----controllers
----models
There is an advantage of using one of these folder structure, because you don't have to worry about route much.
https://domain.com/api/v1/products
Here is good example for RESTful API with advance template
Setup RESTful API in Yii2(budiirawan)
API & RESTFull API are different. RESTFull APIs have to have REST standards. basically that's why APIs are developed as separate application. in normal app, we create 4 actions for CRUD functions. but in yii2 RESTFull API we just create One action for all CRUD functions. (Controllers extend from REST Active Controller - yii\rest\ActiveController ). in core code you can find find 4 actions for different headers GET,POST,PUT & DELETE .
'index' => ['GET', 'HEAD'],
'view' => ['GET', 'HEAD'],
'create' => ['POST'],
'update' => ['PUT', 'PATCH'],
'delete' => ['DELETE'],
for authentication basically we can use 'HTTP Basic Authentication'
This article explain the idea and the why , also it provide you a starter project called "yii2-advanced-api": http://budiirawan.com/setup-restful-api-yii2/
IMHO if you need REST API for Angular.js or Knockout.js AJAX calls on your website it's an overhead to do it as a separate application. Because you will have issues with cross-domain AJAX calls (especially for POST requests).
I think it's enough to make a module (API) in the frontend for REST API