Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

allOf validation not working?

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

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

Đánh giá

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

Hướng nghiên cứu

Tái hiện yêu cầu JSON PATCH tới /pets bằng tài liệu OpenAPI được cung cấp và tham chiếu allOf của schema Cat tới Pet. Theo dõi cách validator phân giải Pet và thuộc tính pet_type được kế thừa của nó, sau đó xác định liệu yêu cầu có được chấp nhận hay vì sao quá trình validation từ chối yêu cầu. Issue không nêu tên tệp dự án hoặc test nào.

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

Mô tả

good first issue hacktoberfest help wanted

Hi, I'm having issues getting an example spec using allOf to work. This is the spec, as provided by the OpenAPI docs:

openapi: 3.0.0
info:
  title: AllOf.v1
  version: '1.0'
servers:
  - url: 'http://localhost:3000'
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
    Dog: # "Dog" is a value for the pet_type property (the discriminator value)
      allOf: # Combines the main `Pet` schema with `Dog`-specific properties
        - $ref: '#/components/schemas/Pet'
        - type: object
          # all other properties specific to a `Dog`
          properties:
            bark:
              type: boolean
            breed:
              type: string
              enum: [ Dingo, Husky, Retriever, Shepherd ]
    Cat: # "Cat" is a value for the pet_type property (the discriminator value)
      allOf: # Combines the main `Pet` schema with `Cat`-specific properties
        - $ref: '#/components/schemas/Pet'
        - type: object
          # all other properties specific to a `Cat`
          properties:
            hunts:
              type: boolean
            age:
              type: integer

My test attempts to send a JSON PATCH request to the /pets endpoint, using:

[
    'pet_type' => 'Cat',
    'age' => 3,
    'hunts' => true,
]

However, this only results in:

Request body did not match provided JSON schema.

Digging in a bit more, it appears that the validator doesn't see the pet_type property it should be inheriting from the Pet component.

Any experience with this, or ideas? Thanks in advance.

Ngôn ngữ chính
PHP
Star
500
Fork
99
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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.

Issue khác của cebe/php-openapi

Tất cả issue của cebe/php-openapi

Issue tương tự

Thêm issue về PHP

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.