Skip to main content

swagger_parser 2.1.1 copy "swagger_parser: ^2.1.1" to clipboard
swagger_parser: ^2.1.1 copied to clipboard

Generate Dart models and HTTP clients from Swagger and OpenAPI. Supports Retrofit, Dio, and package:http.

example/swagger_parser_example.dart

import 'package:swagger_parser/swagger_parser.dart';

Future<void> main() async {
  const source = SchemaSource.yaml(r'''
openapi: 3.2.1
info:
  title: Stations
  version: '1'
paths:
  /stations:
    get:
      tags:
        - Stations
      operationId: getStations
      responses:
        '200':
          description: Stations
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Station'
components:
  schemas:
    Station:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
        name:
          type: string
''');
  final GenerationResult result = await const SwaggerParserRunner().generate(
    source,
  );
  for (final GeneratedFile file in result.files) {
    // ignore: avoid_print
    print('${file.relativePath}\n${file.content}');
  }
}
124
likes
160
points
110k
downloads
screenshot

Documentation

Documentation
API reference

Publisher

verified publishercarapacik.dev

Weekly Downloads

Generate Dart models and HTTP clients from Swagger and OpenAPI. Supports Retrofit, Dio, and package:http.

Repository (GitHub)
View/report issues
Contributing

Topics

#openapi #swagger #codegen #api-client #http

License

MIT (license)

Dependencies

args, code_builder, dart_style, path, pub_semver, swagger_parser_core, yaml

More

Packages that depend on swagger_parser