LogoRevali

Installation

Add revali_swagger to your Revali project

Revali Swagger is split across two packages:

PackagePurposeWhere
revali_swagger_annotations Runtime annotations (@ApiTag, @ApiSummary, etc.) dependencies
revali_swagger OpenAPI spec generator (the construct itself) dev_dependencies

Add the Packages#

dart pub add revali_swagger_annotations
dart pub add --dev revali_swagger

Your pubspec.yaml should look like this:

pubspec.yaml
dependencies:
  revali_swagger_annotations: ^1.0.0

dev_dependencies:
  revali_swagger: ^1.0.0

Register the Construct#

Add revali_swagger to your revali.yaml constructs list:

revali.yaml
constructs:
  - name: revali_swagger

That's all that's needed for a working spec. Configuration options are covered in Configuration.

Run the Generator#

dart run revali dev

The spec is written to:

.revali/
└── revali_swagger/
    ├── swagger.yaml
    └── swagger.json

Verify the Output#

Open .revali/revali_swagger/swagger.yaml or .revali/revali_swagger/swagger.json. You should see your API paths listed under the paths key, with schemas for any complex types under components/schemas.

If a type could not be resolved, a warning is printed to stderr:

[revali_swagger] Warning: cannot infer schema for type 'Duration'.
Use @ApiType to specify the schema explicitly.

See Type Inference for guidance on resolving these warnings.