swagger-api / swagger-parser

Swagger Spec to Java POJOs
http://swagger.io
Apache License 2.0
773 stars 526 forks source link

Parser ignore readOnly/writeOnly on property with $ref #2036

Open rongli-mx opened 5 months ago

rongli-mx commented 5 months ago

The Parser ignore the readOnly attribute on the property Order.customer

openapi: "3.0.1"
info:
  title: test
  version: "1.0"

paths:

  /ping:
    get:
      operationId: ping
      responses:
        200:
          description: OK
  /order:
    get:
      operationId: getOrder
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Order'
    put:
      operationId: putOrder
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Order'
      responses:
        200:
          description: OK
          content:
            application/json:
              schema:
                type: string

components:
  schemas:
    Customer:
      type: object
      properties: 
        id:
          type: string
        name:
          type: string
    Order:
      type: object
      properties:
        id:
          type: string
        operations:
          type: array
          items:
            $ref: '#/components/schemas/Operation'
          readOnly: true
        customer:
          $ref: '#/components/schemas/Customer'
#          readOnly: true # readOnly here will be ignored
    Operation:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
          readOnly: true
        name:
          type: string
          writeOnly: true
          readOnly: false