Skip to content
pubscout

shelf_swagger_ui

2.0.0, released 2 years ago by flutterando.com.br

Serve Swagger UI API documentation using Shelf.

$ flutter pub add shelf_swagger_ui
Source repository

What it does

Integrates Swagger UI into a Shelf server to present clean and professional API documentation. It allows configuring handlers directly from YAML or JSON schema files.

AI-written summary of version 2.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a backend API in Dart using the shelf package
  • You need to serve Swagger UI documentation for your OpenAPI specs

Skip it when

  • You are not using the shelf package for your Dart backend
  • You need client-side code generation rather than server documentation rendering

Strengths

  • Easy setup with Shelf handlers
  • Supports loading schema directly from files
  • Supports custom titles and configuration options like syntax highlighting and doc expansion

Weaknesses

  • Limited documentation outside basic file loading
  • Dependent on external OpenAPI schema files being correctly formatted

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
5

Requires an OpenAPI schema file (YAML or JSON) and a running Shelf server.

import 'package:shelf/shelf_io.dart' as io;
import 'package:shelf_swagger_ui/shelf_swagger_ui.dart';

void main(List<String> args) async {
  final path = 'specs/swagger.yaml';
  final handler = SwaggerUI.fromFile(File(path), title: 'Swagger Test');
  var server = await io.serve(handler, '0.0.0.0', 4001);
  print('Serving at http://${server.address.host}:${server.port}');
}

Works with

Packages commonly used together with shelf_swagger_ui: ones it builds on, ones built on it, and its own family.