Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readOnly is not respected on $ref #2763

Open
callebjorkell opened this issue Jan 23, 2025 · 1 comment
Open

readOnly is not respected on $ref #2763

callebjorkell opened this issue Jan 23, 2025 · 1 comment

Comments

@callebjorkell
Copy link

$ref objects that are marked as readOnly, and are not relevant for requests, still show up in the documentation and cause confusion.

Current Behavior

For any property marked as readOnly, that also uses a $ref, the read-only marking is not reflected in the documentation.
The readOnly is ignored, and the element shows up in requestBody elements, as well as in examples. In the schema section, the element is rendered without a "read-only" label.

Expected Behavior

The property set to readOnly should be omitted from request bodies, examples and be marked in the schema as "read-only"

Steps to Reproduce

Given the following spec:

openapi: 3.1.0
paths:
  /outcomes:
    patch:
      description: "Quick patch example"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Outcome"
info:
  title: "Test"
  version: "1.0"

components:
  schemas:
    Video:
      properties:
        url:
          readOnly: true
          type: string
    Outcome:
      properties:
        title:
          type: string
        createdAt:
          type: string
          readOnly: true
        subtitle:
          type: object
          readOnly: true
          properties:
            url:
              type: string
              format: uri
        video:
          $ref: "#/components/schemas/Video"
          readOnly: true

The patch endpoint gets rendered with an empty video element:

Image

... and looking at the schemas section for the Outcome, the read-only label is also missing from the video element:

Image

Note that the inlined subtitle object works as expected.

Environment

  • Version used: 9.0.0 (can be reproduced at https://elements-demo.stoplight.io)
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Firefox 134.0.1
  • Operating System and version (desktop or mobile): Linux
  • Link to your environment/workspace/project: N/A
@callebjorkell
Copy link
Author

I did find issue #2194 that is very similar, and where this functionality seems to have worked, so maybe it's a regression?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant