首页 > 解决方案 > Openapi 3.0:有效负载不反映我的架构 allOf

问题描述

我有一点麻烦:在 yaml 中,我将创建一个包含一些文件的通用模式。然后我会在各种 PUT\POST 调用中引用它。在每个 put\pos​​t 中,我将创建一个专门针对这个特定模式的 allOf。所以,就立场而言,这是我的模式

site:
      type: object
      properties:
        id:
          type: integer

          readOnly: true
        description:
          type: string
        idLicensee:
          type: integer
        uId:
          type: string
        active:
          type: boolean
        lastupdate:
          type: string
          format: date-time  
          readOnly: true

这是我的 PUT

put:
      tags:
      - sites
      operationId: editSite
      parameters:
        - name: id
          in: path
          description: "id of the object to be removed"
          required: true
          schema:
            type: integer
      requestBody:
        description: "Use this message to edit an existing site"
        content:
          application/json:
            schema:
              allOf:
              - type: object
                properties:
                    uId:
                      readOnly: true
                    idLicensee:
                      readOnly: true  
              - required:
                - description
                - active  
              - $ref: '#/components/schemas/site'

现在我终于在我编译的文档中看到了一个正确的请求正文,只需要 2 个字段,同时使用一个类似的 sitanx,我可以创建一个正确的 POST whit 4 所需的字段。

但是有些东西让我很烦:有效载荷。 有效载荷故障?

我的有效负载没有反映 allOf “覆盖”(对不起,我是初级开发人员 < 1y),但坚持使用一般模式。我什至不知道是否是openapi“错误”,个人对Payload的误解或编译错误。请问是否有关于openapi和Payload whit allof的已知问题?真挚地

标签: yamlopenapiopenapi-generator

解决方案


推荐阅读