Skip to main content

Swagger Example

 In this Text, I want to talk about Swagger Example I developed in GitHub 


as below URL:

SwaggerExampleAttr for .NET core

and this is Nuget library:

<PackageReference Include="SwaggerExampleAttrLib" Version="0.1.23" />

if you want to add customized examples for the rest API models to show in swagger UI, you can use this library.

Install Instructions:

1- first install Nuget library

Install-Package SwaggerExampleAttrLib -Version 0.1.23

2- add schema filter in SwaggerGen

services.AddSwaggerGen(c =>  

{  
    c.SchemaFilter<ExampleSchemaFilter>();
    ...
}

Example

if you want to use this library you should use the Example attribute above of your properties like:

public class TestModel{
[Example("Test")]   
public string Address { get; set; }
[Example(12.2)]   
public decimal Lat { get; set; }
[Example(1, 2, 3)]   
public List<int> Ints { get; set; }
...
}

*Supported Types:

string

int

double

decimal

System.Collections.Generic simple types like (List<int>, List<string>,IEnumrable<int>)



Comments

Popular posts from this blog

Processing high-volume data in .NET Entity Framework

 The efficiency of DDL and DML operations on data within Object-Relational Mapping (ORM) systems has become a prominent concern in the contemporary development landscape. Entity Framework stands out as a widely-used ORM within the .NET ecosystem. In specific scenarios, business requirements necessitate retrieving or doing some processes with large datasets, often involving millions of records in SQL Server databases. In light of this challenge, I have chosen to share my insights and experiences. Firstly, we should understand the coroutine, then we will discuss IAsyncEnumerable and IEnumerable , and finally, we will discuss approaches to handling huge numbers of data. What is coroutine? From the Educative website The word “coroutine” is composed of two words: “co” (cooperative) and “routines” (functions). In .NET, a coroutine is a function that can be suspended and resumed later. The .NET Framework keeps track of the state of a coroutine using a data structure called a coroutine frame

Job pause and resume on Hangfire on Execution mode

  A common approach to handling tasks automatically in your application is to use jobs. Hangfire is an excellent tool for managing jobs easily. The stopping and resuming of jobs in Hangfire sometimes require stopping and restarting your project, so I decided to introduce new components in this framework after reviewing comments and advice carefully. in this article, I will describe how you can implement this component in your Hangfire Project.