Skip to content

Multiple colliding allOfs causing issues in generation #4325

Closed

Description

I'm analyzing an OpenAPI where they used allOfs heavily, here you have a reproducer:

openapi: 3.0.3
info:
  title: Model Registry REST API
  version: v1alpha2
  description: REST API for Model Registry to create and manage ML model metadata
  license:
    name: Apache 2.0
    url: "https://www.apache.org/licenses/LICENSE-2.0"
servers:
  - url: "https://localhost:8080"
  - url: "http://localhost:8080"
paths:
  /api/model_registry/v1alpha2/registered_models:
    summary: Path used to manage the list of registeredmodels.
    description: >-
      The REST endpoint/path used to list and create zero or more `RegisteredModel` entities.  This path contains a `GET` and `POST` operation to perform the list and create tasks, respectively.
    get:
      responses:
        "200":
          $ref: "#/components/responses/RegisteredModelListResponse"
      summary: List All RegisteredModels
      description: Gets a list of all `RegisteredModel` entities.
components:
  schemas:
    BaseResource:
      type: object
      properties:
        id:
          format: int64
          description: Output only. The unique server generated id of the resource.
          type: number
          readOnly: true
      allOf:
        - $ref: "#/components/schemas/BaseResourceCreate"
    BaseResourceCreate:
      type: object
      properties:
        name:
          description: |-
            The client provided name of the artifact. This field is optional. If set,
            it must be unique among all the artifacts of the same artifact type within
            a database instance and cannot be changed once set.
          type: string
    BaseResourceList:
      required:
        - size
      type: object
      properties:
        size:
          format: int32
          description: Number of items in result list.
          type: integer
    RegisteredModel:
      description: A registered model in model registry. A registered model has ModelVersion children.
      allOf:
        - $ref: "#/components/schemas/BaseResource"
        # - $ref: "#/components/schemas/BaseResourceCreate"
        - $ref: "#/components/schemas/RegisteredModelCreate"
    RegisteredModelCreate:
      description: A registered model in model registry. A registered model has ModelVersion children.
      allOf:
        - $ref: "#/components/schemas/BaseResourceCreate"
    RegisteredModelList:
      description: List of RegisteredModels.
      type: object
      allOf:
        - $ref: "#/components/schemas/BaseResourceList"
        - type: object
          properties:
            items:
              description: ""
              type: array
              items:
                $ref: "#/components/schemas/RegisteredModel"
              readOnly: false
  responses:
    RegisteredModelListResponse:
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/RegisteredModelList"
      description: A response containing a list of `RegisteredModel` entities.\

The pattern that is causing issues here is:

  • RegisteredModel
    • BaseResource
      • BaseResourceCreate
    • RegisteredModelCreate
      • BaseResourceCreate

I acknowledge that this is not supported, but the generator doesn't throw any error or warning.

The final result is to have a RegisteredModel data class without the name field, breaking the "multiple inheritance pattern" correctly generates all of the expected fields.

Reproducer command:

kiota generate -l python -c PostsClient -n client -d minimal_single.yaml -o ./client --clean-output --log-level Trace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

enhancementNew feature or requestgeneratorIssues or improvements relater to generation capabilities.help wantedIssue caused by core project dependency modules or library

Type

No type

Projects

  • Status

    Done ✔️

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions