Swagger UI Darto
πΆπ’ Swagger UI Darto Github
The Swagger UI Darto is a plugin developed exclusively for the Darto framework. It allows you to easily integrate a beautiful Swagger UI into your Darto application, making it simple to visualize your API documentation. This plugin is intended for use with Darto only.
Support π
If you find Swagger UI Darto useful, please consider supporting its development πBuy Me a Coffeeπ. Your support helps improve the framework and make it even better!
Getting Started π
Installation
Add the following dependencies to your pubspec.yaml
:
dependencies:
swagger_ui_darto: 0.0.1
darto: latest
path: latest
Replace latest
with the most recent version available.
Usage
Below is a complete example of how to configure and use Swagger UI Darto in a Darto application with a Todo List API that includes routes for GET, POST, PUT, and DELETE.
import 'dart:io';
import 'package:darto/darto.dart';
import 'package:path/path.dart';
import 'package:swagger_ui_darto/swagger_ui_darto.dart';
void main() {
final app = Darto();
// Swagger UI options configuration is optional π
final options = SwaggerUiOptions(
title: 'My API Documentation',
deepLink: true,
syntaxHighlightTheme: 'monokai',
persistAuthorization: true,
);
// Define the absolute path to the swagger.json file
final swaggerJsonPath = join(Directory.current.path, 'swagger.json');
// Mount the Swagger UI router on "/docs"
// This will set up:
// - GET /docs -> Swagger UI HTML page
// - GET /docs/swagger.json -> Swagger JSON document
app.use('/docs', SwaggerUi.serve(swaggerJsonPath, options: options));
// Your API routes
// ...
app.listen(3000, () {
print('Server running on http://localhost:3000');
print('Swagger UI available at http://localhost:3000/docs');
});
}
Example Swagger JSON π
Create a file named swagger.json
at the root of your project with the following document your API like this:
{
"swagger": "2.0",
"info": {
"title": "My API",
"version": "1.0.0"
},
"paths": {}
}
You can use yaml instead of json, just change the extension to .yaml
Official Documentation π
For more details on how to structure your swagger.json
, please refer to the Swagger Official Documentation.
License
This project is licensed under the MIT License.
Have Fun! π
Enjoy building amazing APIs with Darto and the Swagger UI Darto Plugin!
Made by evendersondev with β€οΈ for Dart/Flutter developers! π―
Libraries
- swagger_ui_darto
- Support for doing something awesome.