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

Duplicate fields in AllOf #191

Closed dickermoshe closed 4 months ago

dickermoshe commented 4 months ago
// 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 'all_of_with_properties.freezed.dart';
part 'all_of_with_properties.g.dart';

/// parent object without x-parent extension
@Freezed()
class AllOfWithProperties with _$AllOfWithProperties {
  const factory AllOfWithProperties({
    required bool isParent,
    bool? isParent,
    @JsonKey(name: 'mum_or_dad')
    String? mumOrDad,
    @JsonKey(name: 'mum_or_dad')
    String? mumOrDad,
  }) = _AllOfWithProperties;

  factory AllOfWithProperties.fromJson(Map<String, Object?> json) => _$AllOfWithPropertiesFromJson(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/Person"
components:
  schemas:
    Person:
      description: person using x-parent (abstract) to indicate it's a parent class
      type: object
      x-parent: "abstract"
      properties:
        $_type:
          type: string
        lastName:
          type: string
        firstName:
          type: string
    Adult:
      description: A representation of an adult
      allOf:
      - $ref: '#/components/schemas/Person'
      - type: object
        properties:
          children:
            type: array
            items:
              $ref: "#/components/schemas/Child"
    Child:
      description: A representation of a child
      allOf:
      - type: object
        properties:
          age:
            type: integer
            format: int32
      - $ref: '#/components/schemas/Person'
    AnotherChild:
      description: another child class that does NOT extend/inherit AnotherPerson
      allOf:
        - type: object
          properties:
            age:
              type: integer
              format: int32
        - $ref: '#/components/schemas/AnotherPerson'
    AnotherPerson:
      description: person object without x-parent extension
      type: object
      allOf:
        - properties:
            $_type:
              type: string
            lastName:
              type: string
            firstName:
              type: string
        - $ref: '#/components/schemas/AnotherParent'
    AnotherParent:
      description: parent object without x-parent extension
      type: object
      properties:
        isParent:
          type: boolean
        mum_or_dad:
          type: string
    allOfWithProperties:
      description: parent object without x-parent extension
      type: object
      allOf:
        - $ref: '#/components/schemas/AnotherParent'
      properties:
        isParent:
          type: boolean
        mum_or_dad:
          type: string
      required:
        - isParent
    allOfWithSingleItem:
      description: allOf with a single item
      nullable: true
      allOf:
        - $ref: '#/components/schemas/AnotherParent'