GithubHelp home page GithubHelp logo

ahmedfathydev / fathy.swagger Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 78 KB

NuGet package for efficiently adding swagger in Web APIs.

Home Page: https://www.nuget.org/packages/Fathy.Swagger

License: GNU General Public License v2.0

C# 100.00%

fathy.swagger's Introduction

Fathy.Swagger

NuGet package for efficiently adding swagger in ASP.NET Core Web API apps. It simplifies the creation of interactive API documentation using the OpenAPI (Swagger) specification. This package helps developers to effortlessly visualize, test, and debug their API endpoints directly from the browser.

Package Features

  1. Authorization: Enable Bearer authorization by adding JWT bearer token to test authorized APIs.

Authorization

Bearer

  1. Localization: Enable localization and support multi-languages by sending the Accept-Language header, facilitating better internationalization.

Accept-Language

  1. Minimal APIs: Enable interactive UI for minimal API endpoints to explore and test directly in the browser.
var app = builder.Build();

///

app.MapGet("/", () => "Hello, World!");

///

app.Run();

Minimal APIs

  1. Query Parameters: Enable sending date in the query string as query parameters, enhancing API usability and understanding.
[HttpGet]
public IActionResult Verify([FromQuery] string code) => code == VerificationCode ?
    Ok("Verified...") : BadRequest("Wrong verification code!!!");

Query Parameters

Installing Package

$ dotnet add package Fathy.Swagger

Adding Service

var builder = WebApplication.CreateBuilder(args);

///

var openApiInfo = new OpenApiInfo
{
    Title = "HelloWorld.API",
    Version = "v1"
};

builder.Services.AddSwaggerService(openApiInfo);

///

var app = builder.Build();
///

Using Service

///
var app = builder.Build();

///

app.UseSwagger();

app.UseSwaggerUI(options =>
{
    options.SwaggerEndpoint($"/swagger/{openApiInfo.Version}/swagger.json", openApiInfo.Title);
});

///

app.Run();

Test your API

APPLICATION_URL/swagger/index.html

fathy.swagger's People

Contributors

ahmedfathydev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.