Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does Swagger server stub mean?

What does the term Server Stub mean in the context of the Swagger ecosystem? How is it used?

like image 582
Mohamad Haidar Avatar asked Aug 02 '18 15:08

Mohamad Haidar


People also ask

What is server stub in swagger?

The server stub is a good starting point for implementing your API – you can run and test it locally, implement the business logic for your API, and then deploy it to your server. Anyone can generate a server stub for any API in SwaggerHub, unless the API owner disabled server generation in the code generation options.

What does server stub mean?

Service stubs are simulations of an actual service, which can be used to functionally replace the service in a test environment. A stub server replaces the actual application server. From the point of view of the client application, the service stub looks identical to the actual service that it simulates.

What is an API server stub?

A stub in distributed computing is a piece of code that converts parameters passed between client and server during a remote procedure call (RPC). The main idea of an RPC is to allow a local computer (client) to remotely call procedures on a different computer (server).

What is client stub and server stub?

Client stubs convert parameters used in function calls and reconvert the result obtained from the server after function execution. Server stubs, on the other hand, reconvert parameters passed by clients and convert results back after function execution. Stubs are generated either manually or automatically.

How do I implement an API with SwaggerHub?

With SwaggerHub, you can easily generate a server stub ( an API implementation stub) for Node.js, ASP.NET, JAX-RS, and other servers and frameworks. The server stub is a good starting point for implementing your API – you can run and test it locally, implement the business logic for your API, and then deploy it to your server.

What is Swagger in Swagger?

Swagger allows you to describe the structure of your APIs so that machines can read them. The ability of APIs to describe their own structure is the root of all awesomeness in Swagger. You can write a Swagger spec for your API manually, or have it generated automatically from annotations in your source code.

What is a server stub?

tl;dr: A server stub is intended to be a ready-to-deploy application that routes HTTP requests to your actual business logic on the backend. Thanks for contributing an answer to Stack Overflow!

What can I do with Swagger UI?

Use Swagger UI to generate interactive API documentation that lets your users try out the API calls directly in the browser. Use the spec to connect API-related tools to your API. For example, import the spec to SoapUI to create automated tests for your API. And more!


3 Answers

From a swagger tutorial:

With SwaggerHub, you can easily generate a server stub (an API implementation stub) for Node.js, ASP.NET, JAX-RS, and other servers and frameworks. The server stub is a good starting point for implementing your API – you can run and test it locally, implement the business logic for your API, and then deploy it to your server.

https://app.swaggerhub.com/help/apis/generating-code/server-stub

and a stub is:

method stub or simply stub in software development is a piece of code used to stand in for some other programming functionality. A stub may simulate the behavior of existing code (such as a procedure on a remote machine, such methods are often called mocks) or be a temporary substitute for yet-to-be-developed code. Stubs are therefore most useful in porting, distributed computing as well as general software development and testing.

https://en.wikipedia.org/wiki/Method_stub

like image 170
maio290 Avatar answered Oct 20 '22 20:10

maio290


Stub the API means : create à mock to serve examples described in swagger file. This mock can be formatted in specific languages/ framework

like image 34
Etienne Avatar answered Oct 20 '22 19:10

Etienne


Server stubbing can be quite powerful depending on the backend platform and framework you plan to use for your API.

For example, you may choose Apache (common in Linux environments) or ASP.NET (common for IIS). The server "stubs" being generated will typically be a deployable library to that specific platform. What you typically get is:

  • Routing to your business logic. The framework will handle the HTTP specification, but actually mapping from a "controller" to your service layer is being handled by the code generator, based on your API specification.
  • Serialization and Deserialization of your models (applies to strongly-typed languages like Java/C#).
  • AuthN/AuthZ may be handled, to some degree, based on the framework's support for your API's chosen auth scheme.

tl;dr: A server stub is intended to be a ready-to-deploy application that routes HTTP requests to your actual business logic on the backend.

like image 2
Jmoney38 Avatar answered Oct 20 '22 19:10

Jmoney38