Swagger Configuration


#1

Hello, Im trying to build an app in which I want the user to get some information after he press a Buttom. This information would come from an API , the problem that i have is that ther are 4 functions the GET, PUT ,POST and DELETE, Which one or more should I use to achieve my goal?. Im using the PetStore swagger example, but that example does not contain data base, I think it has the structure only.

Im not a developer so Im not that use to the terminology yet, thanks for any help!


#2

Hi @gns_diego, you can do a simple google on rest api methods and you will get detailed info on this but here is a very short summary on the different methods.

So assuming you have a database table. Then these are the functions of the various methods.

POST : For creating a new entry/row in your table
GET : For retrieving a row from your table.
PUT : For replacing a row in your table.
PATCH : For modifying some values of a row in your table.
DELETE : For removing a row in your table.

So to answer your question, you will need to use GET to retrieve information from your table when the button is pressed.


#3

Really helpful I will do the research, this post just let me go throught the proccess quicker.

On the other hand, I see that I can update information to my table, I have a table that is already with the info I need, what I need to do is to put this table or information to my swagger right?

I have the swagger editor example that is : http://editor.swagger.io/#/

Can you tell me how to put my table in here?, which format do I need or which proccess do I need to go throught?, thanks again


#4

Hi @gns_diego,
From these questions i think you’re very new to this whole thing.
So again i will suggest you do some background reading to get a better understanding before diving in.
I will try to point you in some directions on what to read.

First of all you don’t put and table in the swagger. I will explain briefly below.

To create any data-driven app in dropsource these are the components that is needed (your reading list)

  1. A database/backend. This is where your real data and application logic will reside. For example if you’re creating a mobile app for a your online shop, you database will contain tables such as Users, Products, Orders, etc.
    Each of these tables will have fields (columns), e.g. Product table will have fields such name, stock, unit price, picture, etc. There are numerous database or backend systems that you can choose from. Example GoogleSheets, Backendless, Bubble, MySQL , etc. As long as you can provide a REST API (see point 2 below) to the backend, you can use it with dropsource

  2. A REST API. This is an interface to your database/backend. An API allows your system to communicate with other services. For example through the API external services can read,modify and write data to your database using the different REST methods such as GET, POST, PUT, PATCH and DELETE as i explained in my previous post. Each API endpoint defines the inputs (parameters) and output (response) of the endpoint. For example for an API endpoint to retrieve a row from your product’s table, it will be a GET and have a parameter which is the unique id of the row to retrieve and the response will the the row that is returned. Your application will have several of these API endpoints.
    It is through this API that Dropsource will be able to send or retrieve information from your backend.
    Different database/backend have different ways of creating these APIs. Some of them automatically generate the API for you (e.g. Bubble, Wordpress) and for some you will have to do it yourself or use other external services (Sheetsu for GoogleSheets, or DreamFactory for a MySQL database).

  3. A REST API documention/Swagger specification. This is a file that specifies all the API endpoints your backend provides. You supply this file to dropsource and dropsource will make your endpoints available in your editor so you can call your API endpoints for getting and sending data to your backend. You can create this swagger specification from your API endpoints yourself using a tool like stoplight.io. Some backends like Bubble also automatically generate this swagger specification for you.

Hopefully if I explained myself well you now understand you don’t need to add any data to your swagger specification as you asked.

If you’re all new to this, I will suggest looking into Bubble.is because bubble automatically provide all these three components for you. It has an in-built database system that you can easily create your tables from. Then it will automatically generate APIs and also create the swagger specification for you without you doing anything.
But note that its not all smooth like butter. You’re going to have some challengers here and there so you need to read and understand these concepts else you will always have to be asking questions and waiting on people to answer.

Hope this helps you or anyone who is new to all this as well.

Good luck.


#5

Amazing explanation as always from @seanhoots… :trophy::tada:

@gns_diego We have guides to setting up a few backends including Bubble in our help center: