openapi-generators / openapi-generators/openapi-python-client

Schema processing fails when "allOf" references to nullable object

Đang mở
#1,066 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
2k
Fork
293
Merge trung bình
34 phút
Pull request đã merge (30 ngày)
1

Mô tả

Describe the bug
When using a schema that contains an "allOf" reference to a nullable object, the generation fails with the message "Cannot take allOf a non-object".

OpenAPI Spec File
Document to recreate:

openapi: 3.0.1
info:
  title: Title
  description: Description
  version: 1.0.0
servers:
  - url: /api
paths:
  /item:
    get:
      operationId: item
      responses:
        "200":
          description: Successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Item'
components:
  schemas:
    RelatedItemSuper:
      type: object
      nullable: true
      properties:
        propertyA:
          type: string
    RelatedItem:
      type: object
      allOf:
        - $ref: '#/components/schemas/RelatedItemSuper'
        - type: object
          properties:
            propertyB:
              type: string
    Item:
      type: object
      nullable: false
      properties:
        key:
          type: string
        relatedItem:
          $ref: '#/components/schemas/RelatedItem'

A real world example can be found here.

Desktop (please complete the following information):

  • OS: Linux
  • Python Version: 3.11.2
  • openapi-python-client version: 0.21.1

Additional context
Changing "nullable" to "false" on "RelatedItem" in the above example works but does not seem to be a suitable solution as the construct used is legitimate, or is it not?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách chạy openapi-python-client 0.21.1 với tài liệu OpenAPI 3.0.1 được cung cấp và lần theo đường dẫn xử lý schema phát ra "Cannot take allOf a non-object." Sử dụng các định nghĩa RelatedItemSuper và RelatedItem có nullable làm trường hợp hồi quy; được xem là hoàn tất khi việc tạo client thành công mà không yêu cầu thay đổi nullable thành false.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
openapi, python
Lĩnh vực
api, tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.