Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
88 stars 33 forks source link

Bad type hint #192

Closed dickermoshe closed 4 months ago

dickermoshe commented 4 months ago

club.dart

// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, unused_import

import 'package:freezed_annotation/freezed_annotation.dart';

import 'owner.dart';

part 'club.freezed.dart';
part 'club.g.dart';

@Freezed()
class Club with _$Club {
  const factory Club({
    owner? owner, // Should be Owner
  }) = _Club;

  factory Club.fromJson(Map<String, Object?> json) => _$ClubFromJson(json);
}

owner.dart

// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint, unused_import

import 'package:freezed_annotation/freezed_annotation.dart';

part 'owner.freezed.dart';
part 'owner.g.dart';

@Freezed()
class Owner with _$Owner {
  const factory Owner({
    String? name,
  }) = _Owner;

  factory Owner.fromJson(Map<String, Object?> json) => _$OwnerFromJson(json);
}

Schema

openapi: 3.0.1
info:
  version: 1.0.0
  title: Example
  license:
    name: MIT
servers:
  - url: http://api.example.xyz/v1
paths:
  /person/display/{personId}:
    get:
      parameters:
        - name: personId
          in: path
          required: true
          description: The id of the person to retrieve
          schema:
            type: string
      operationId: list
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/club"
components:
  schemas:
    club:
      properties:
        owner:
          allOf:
            - $ref: '#/components/schemas/owner'
          nullable: true

    owner:
      properties:
        name:
          type: string
          maxLength: 255
dickermoshe commented 4 months ago

Fixed with #198