Welcome to the Swagger API Generator project! This project allows you to upload a Swagger (OpenAPI) specification file, generate C# Web API code based on this specification, and dynamically serve the generated API. 🎉
- Upload Swagger (OpenAPI) specification files 📂
- Generate server-side C# Web API code from the uploaded specification 🛠️
- Dynamically load and serve the generated API on-the-fly 🌐
- Simple logging to track the invocation of generated server methods 📋
- .NET 6 SDK or later
- A tool like Postman for testing the API endpoints (optional)
Follow these steps to set up and run the project:
git clone https://github.com/yourusername/SwaggerApiGenerator.git
cd SwaggerApiGenerator
dotnet build
dotnet run
The application will start and be available at http://localhost:5000.
Upload a Swagger Specification File 📤
Use a tool like Postman to send a POST request to http://localhost:5000/api/swaggerupload/upload
.
Attach your Swagger (OpenAPI) specification file in the form-data.
Example using curl:
curl -X POST "http://localhost:5000/api/swaggerupload/upload" -F "file=@path/to/your/swaggerfile.json"
Send a GET request to http://localhost:5000/api/swaggerupload/serve
.
Check the console for logs indicating which controllers have been loaded.
Example using curl:
curl -X GET "http://localhost:5000/api/swaggerupload/serve"
SwaggerApiGenerator/
├── Controllers/
│ └── SwaggerUploadController.cs
├── Program.cs
├── SwaggerApiGenerator.csproj
└── README.md
Program.cs
: Configures services, logging, and maps endpoints.
Controllers/SwaggerUploadController.cs
: Contains endpoints for uploading Swagger files and serving generated APIs.
The project uses console logging to track the invocation of dynamically generated server methods. Check the console output to see logs indicating which controllers are being loaded.
Contributions are welcome! Feel free to open issues or submit pull requests.
This project is licensed under the MIT License. See the LICENSE file for details.