Skip to main content

swagger_parser_core 1.0.1 copy "swagger_parser_core: ^1.0.1" to clipboard
swagger_parser_core: ^1.0.1 copied to clipboard

Typed Swagger and OpenAPI models with JSON/YAML parsing, validation, and reference resolution for swagger_parser.

example/swagger_parser_core_example.dart

import 'dart:convert';

import 'package:swagger_parser_core/swagger_parser_core.dart';

void main() {
  const source = SchemaSource.yaml('''
swagger: '2.0'
info:
  title: Pets
  version: '1'
paths:
  /pets:
    get:
      responses:
        '200':
          description: Pets
          schema:
            type: array
            items:
              type: string
''');
  final document = const OpenApiParser().parse(source) as SwaggerV2Document;
  final ValidationReport report = const OpenApiValidator().validate(document);
  if (report.hasErrors) {
    throw StateError('The schema has validation errors.');
  }
  // ignore: avoid_print
  print(const JsonEncoder.withIndent('  ').convert(document.toJson()));
}
0
likes
160
points
0
downloads

Documentation

API reference

Publisher

verified publishercarapacik.dev

Weekly Downloads

Typed Swagger and OpenAPI models with JSON/YAML parsing, validation, and reference resolution for swagger_parser.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

source_span, yaml

More

Packages that depend on swagger_parser_core