OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.58k stars 6.52k forks source link

[BUG][dart-dio] Using oneOf together with allOf does not generate properties #18380

Open rfuerst87 opened 6 months ago

rfuerst87 commented 6 months ago

Bug Report Checklist

Description

dart-dio does not generate properties for models when using oneOf together with allOf. The schema posted below generates the following code:

// ...
/// Dog
///
/// Properties:
/// * [petType] 
/// * [hunts] 
/// * [age] 
/// * [bark] 
/// * [breed] 
@BuiltValue()
abstract class Dog implements Pet, Built<Dog, DogBuilder> {
  Dog._();

  factory Dog([void updates(DogBuilder b)]) = _$Dog;

  @BuiltValueHook(initializeBuilder: true)
  static void _defaults(DogBuilder b) => b..petType=b.discriminatorValue;

  @BuiltValueSerializer(custom: true)
  static Serializer<Dog> get serializer => _$DogSerializer();
}
// ...

I'd expect that it generates all properties related to Dog (petType, bark and breed).

openapi-generator version

7.4.0

OpenAPI declaration file content or url
openapi: 3.0.1
info:
   title: pet
   version: 0.0.1
paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/Cat'
                - $ref: '#/components/schemas/Dog'
              discriminator:
                propertyName: pet_type
      responses:
        '200':
          description: Updated
components:
  schemas:
    Pet:
      type: object
      required:
        - pet_type
      properties:
        pet_type:
          type: string
      discriminator:
        propertyName: pet_type
      oneOf:
        - $ref: '#/components/schemas/Cat'
        - $ref: '#/components/schemas/Dog'
    Dog:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            bark:
              type: boolean
            breed:
              type: string
              enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            hunts:
              type: boolean
            age:
              type: integer
Steps to reproduce
openapi-generator-cli generate -i pet.yaml -g dart-dio -o ./pet
rfuerst87 commented 5 months ago

Hi there,

Just wanted to gently nudge this issue in case you haven't had a chance to look at it yet. I'm happy to provide any additional information that might be helpful.

Thanks!

@jaumard @josh-burton @amondnet @sbu-WBT @kuhnroyal @agilob @ahmednfwela