This C# project is a RESTful API designed to manage and query compatibility data between software licenses. It utilizes ASP.NET Core framework for building web applications and Entity Framework Core for database operations.
The API includes functionality for checking compatibility between two licenses, retrieving unique license names, and managing license compatibility records. The compatibility data is stored in a MySQL database.
The MySQL database is used to store license compatibility data. The database schema includes a table named license_compatibility
with columns for the first license (License1
), the second license (License2
), and the compatibility status (Compatibility
). The database is populated using a Python script (populate_database.py
) that reads data from a CSV file (matrix.csv
) and inserts it into the license_compatibility
table.
- GET
/api/CompatibilityMatrix/CheckCompatibility
:- This endpoint accepts query parameters representing two license names (
license1
andlicense2
) and returns the compatibility result as aCompatibilityResponseModel
JSON object.
- This endpoint accepts query parameters representing two license names (
- GET
/api/CompatibilityMatrix/GetLicenses
:- This endpoint retrieves a list of unique license names stored in the database and returns them as a JSON array of strings.
The API is documented using Swagger/OpenAPI specification and can be explored interactively in a web browser by accessing the following URL: http://localhost:5191/swagger.
Program.cs
: Configures the application and sets up the HTTP request pipeline.InLicenses.cs
: Defines the input model for licenses.LicenseCompatibility.cs
: Defines the model for license compatibility records.ApplicationDbContext.cs
: Represents the database context for Entity Framework Core.CompatibilityMatrixController.cs
: Implements the API endpoints for license compatibility management.populate_database.py
: Python script to populate the MySQL database with license compatibility data from a CSV file.
To use the API:
- Set up a MySQL database and configure the connection string in
appsettings.json
. - Run the Python script
populate_database.py
to populate the database with license compatibility data. - Run the C# project to start the API.
- Explore the API endpoints and interact with them using Swagger UI.
- This project demonstrates how to build a RESTful API using ASP.NET Core, Entity Framework Core, and MySQL database.
- The Python script
populate_database.py
is provided as an example of how to automate the process of populating the database with data from a CSV file. - For more information on configuring and using Swagger/OpenAPI with ASP.NET Core, refer to Swashbuckle documentation.