Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Swagger and does it relate to OData?

I am familiar with the Microsoft stack. I am using OData for some of my restful services. Recently I came across Swagger for API documentation and I am trying to understand how it relates to OData. Both of them seem to be RESTful specifications. Which one is widely used?

like image 286
Muthukumar Avatar asked Sep 30 '15 05:09

Muthukumar


People also ask

Is OpenAPI an OData?

OData is based on a powerful set of concepts and conventions which allow rich interaction with OData services. OpenAPI on the other hand does not assume or rely on any conventions and requires explicit and – from an OData perspective – relatively low-level and repetitive description of each service feature.

What is the Swagger used for?

Swagger helps users build, document, test and consume RESTful web services. It can be used with both a top-down and bottom-up API development approach. In the top-down, or design-first, method, Swagger can be used to design an API before any code is written.

What is the difference between OData and REST API?

REST stands for REpresentational State Transfer which is a resource based architectural style. Resource based means that data and functionalities are considered as resources. OData is a web based protocol that defines a set of best practices for building and consuming RESTful web services.

What is the difference between API and Swagger?

The easiest way to understand the difference is: OpenAPI = Specification. Swagger = Tools for implementing the specification.


1 Answers

Swagger is a specification for documenting APIs. By creating a swagger document for your API, you can pass it to an instance of Swagger UI, which renders the document in a neat, readable format and provides tooling to invoke your APIs. See the swagger.io website for further information.

OData is a specification for creating data services over http, it defines how a service should be constructed and what patterns it should follow. For example, the use of the $top directive to provide the first n results of a data set. OData is currently at version 4, but the v2 documentation has a very good overview.

Swashbuckle is a nuget package for the Microsoft stack that produces swagger documents for your API's automatically, based on inspecting the code and additional metadata you provide to shape the output document.

If you want Swashbuckle to automatically generate swagger documents for an OData API you are building, then you can use Swashbuckle.OData to provide this for you.

If you are using .NET Core, then it gets a little more complex, but a full example can be found at the .NET Core Swagger OData sample.

OpenAPI is a specification for describing API's; Swagger is an implementation of the OpenAPI standard. You can find more details here.

I hope this helps clear up any confusion.

like image 81
Murray Foxcroft Avatar answered Sep 23 '22 10:09

Murray Foxcroft