stoplight_elements 0.0.6 copy "stoplight_elements: ^0.0.6" to clipboard
stoplight_elements: ^0.0.6 copied to clipboard

A Dart package for OpenAPI generation and Stoplight Elements page rendering.

example/stoplight_elements_example.dart

import 'package:stoplight_elements/stoplight_elements.dart';

@ApiModel(description: 'Health check payload')
class HealthData {
  @ApiProperty(description: 'Service status', example: 'ok')
  final String status;

  HealthData({required this.status});
}

void main() {
  OpenApiConfig.configure(
    title: 'Example API',
    version: '1.0.0',
    serverUrl: 'http://localhost:8000/',
  );

  OpenApiRegistry.instance.autoScan(
    libraryFilter: (uri) => uri.toString().contains('stoplight_elements_example'),
  );

  OpenApiRegistry.instance.registerModel(
    'HealthData',
    const ApiModel(
      description: 'Health check payload',
      properties: {
        'status': ApiProperty(type: 'string', description: 'Service status'),
      },
    ),
  );

  final spec = OpenApiRegistry.instance.buildOpenApi();
  print(spec['info']);

  final html = buildStoplightElementsHtml(openapiUrl: '/openapi.json');
  print('Generated docs HTML (${html.length} bytes)');
}
1
likes
160
points
12
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Dart package for OpenAPI generation and Stoplight Elements page rendering.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on stoplight_elements