Skip to content

apiaddicts/apigen.net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

🍩 Apigen Release stability-alpha Swagger License: LGPL v3

Asp.Net microservice archetype generator in dotnet with hexagonal architecture based on an openapi document with extended annotations. This project is a wrapper of the java apigen with springboot but using dotnet and adapting some concepts due to the paradigm difference. The project is currently being developed by the CloudAPPi Services.

This repository is intended for :octocat: community use, it can be modified and adapted without commercial use. If you need a version, support or help for your enterprise or project, please contact us 📧 [email protected]

Twitter Discord LinkedIn Facebook YouTube

🙌 Join the Apigen Adopters list

📢 If Apigen is part of your organization's toolkit, we kindly encourage you to include your company's name in our Adopters list. 🙏 This not only significantly boosts the project's visibility and reputation but also represents a small yet impactful way to give back to the project.

Organization Description of Use / Referenc
CloudAppi Apification and generation of microservices
Apiquality Generation of microservices

👩🏽‍💻 Contribute to ApiAddicts

We're an inclusive and open community, welcoming you to join our effort to enhance ApiAddicts, and we're excited to prioritize tasks based on community input, inviting you to review and collaborate through our GitHub issue tracker.

Feel free to drop by and greet us on our GitHub discussion or Discord chat. You can also show your support by giving us some GitHub stars ⭐️, or by following us on Twitter, LinkedIn, and subscribing to our YouTube channel! 🚀

"Buy Me A Coffee"

📑 Getting started

cli dotnet

dotnet run --project ./src/Api/Api.csproj

docker

docker build -t apigen .
docker run -d -p 1000:80 --name apigen.net apigen

docker-compose

 docker-compose up --build -d

▶️ Usage

if you start your application you can directly access /swagger to see the documentation. You can also call the generation endpoint directly with a curl, you have some examples in the Doc/Examples/ folder

example api-hospital.yaml

curl -X 'POST' \
  '{{url}}/generator/file' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F '[email protected]'

💚 Status

🧱 Feature

The following table shows a state of the functionalities, remember that the project is currently in alpha state and the generation of archetypes may vary and generate some errors.

Features Status 📜
CRUD Ok ✔️
Expand Ok. No depth limit ✔️
Select Ok. Needs QA ✔️
Search Some operations ⚠️
Pagination Ok. Not dynamic ✔️
Dynamic Response Needs definition 🚨
OrderBy Ok ✔️
Control Exception Ok. Not custom messages ✔️
dBContext Needs more testing and quality control. Only works with the 'api-hospital' example 🚨
OpenApi Needs quality control 🚨

🔍 Standard Search

Operation Status 📜
AND Ok. Needs QA ✔️
OR Ok. Needs QA ✔️
GT Ok. Needs QA ✔️
LT Ok. Needs QA ✔️
GTEQ Ok. Needs QA ✔️
LTEQ Ok. Needs QA ✔️
EQ Ok. Needs QA ✔️
SUBSTRING Ok. Needs QA ✔️
LIKE Ok. Needs QA ✔️
NLIKE Ok. Needs QA ✔️
ILIKE Ok. Needs QA ✔️
IN Ok. Needs QA ✔️
BETWEEN Ok. Needs QA ✔️
REGEXP Not Implement 🚨

🎲 Samples

🔎 Search operations

json body for search queries for the openapi api-hospital.yaml provided in the examples. ⚠️ don't work with lists.

EQ

{
    "filter": {
        "operation": "EQ",
        "values": [
            {
                "property": "cause",
                "value": "Crocodile bite"
            }
        ]
    }
}

variant LIKE with OR

{
    "filter": {
        "operation": "OR",
        "values": [
            {
                "filter": {
                    "operation": "LIKE",
                    "values": [
                        {
                            "property": "cause",
                            "value": "Cro%"
                        }
                    ]
                }
            },
            {
                "filter": {
                    "operation": "ILIKE",
                    "values": [
                        {
                            "property": "room.code",
                            "value": "%2"
                        }
                    ]
                }
            }
        ]
    }
}

BETWEEN

{
    "filter": {
        "operation": "BETWEEN",
        "values": [
            {
                "property": "entrydate",
                "value": ["2021-01-01", "2021-08-30"]
            }
        ]
    }
}

variant IN with AND

{
    "filter": {
        "operation": "AND",
        "values": [
            {
                "filter": {
                    "operation": "IN",
                    "values": [
                        {
                            "property": "cause",
                            "value": ["Dog bite","Burn"]
                        }
                    ]
                }
            },
            {
                "filter": {
                    "operation": "IN",
                    "values": [
                        {
                            "property": "room.active",
                            "value": [true]
                        }
                    ]
                }
            }
        ]
    }
}

📚 TargetFramework .net 7

the libraries that extend from others are not indicated in the description

🏡 apigen core libraries

Name Descripción
CodegenCS Class Library and Toolkit for Code Generation using plain C#
DotNetZip Create, extract, or update zip files
OpenAPI.NET Extract raw OpenAPI JSON and YAML documents from the model
Serilog Simple .NET logging with fully-structured events support
Swashbuckle Swagger tools for documenting APIs built on ASP.NET Coreframework

✏️ libraries that the generated project has

Name Descripción
AutoMapper Mapping one object to another
EntityFrameworkCore Object-database mapper
EntityFrameworkCore Dynamic Linq extensions for Microsoft.EntityFrameworkCore which adds Async support
Serilog Simple .NET logging with fully-structured events support
xUnit developer testing framework
Swashbuckle Swagger tools for documenting APIs built on ASP.NET Coreframework
Moq Moq is the most popular and friendly mocking framework for .NET

💿 Auto ORM

The generation of the orm through special tags in openapi still generates problems but you can integrate the automatically generated code using the orm provided by entity framework. This generates the database context and the necessary entities.

dotnet tool uninstall dotnet-ef -g
dotnet tool install --global dotnet-ef
dotnet ef dbcontext scaffold <db_conexion> <driver> -o <output>

example generate with PostgreSQL

dotnet ef dbcontext scaffold "Host=<url>:<port>;Database=<db>;Username=<user>;Password=<pass>" Npgsql.EntityFrameworkCore.PostgreSQL -o Infrastructure

💛 Sponsors

cloudappi