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 attribute not rendered as property metadata #4178

Open
danilobuerger opened this issue Jan 30, 2018 · 9 comments
Open

readOnly attribute not rendered as property metadata #4178

danilobuerger opened this issue Jan 30, 2018 · 9 comments

Comments

@danilobuerger
Copy link

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0.0
Which Swagger-UI version? 3.9.2
How did you install Swagger-UI? NPM
Which browser & version? Google Chrome, 63.0.3239.132 (Official Build) (64-bit)
Which operating system? MacOS X 10.13.2

Demonstration API definition

openapi: 3.0.0
info:
  version: 1.0.0
  title: Test
paths:
  /plan:
    post:
      summary: Creates a Test
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Test'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Test'
components:
  schemas:
    SomeSchema:
      required:
        - hello
      properties:
        hello:
          type: string
    Test:
      required:
        - field1
        - field2
      properties:
        field1:
          type: string
        field2:
          allOf:
            - $ref: '#/components/schemas/SomeSchema'
          readOnly: true

Configuration (browser query string, constructor, config.yaml)

n.a.

Expected Behavior

Request Body Model should match Example value:

{
  "field1": "string"
}

Current Behavior

Request Body Model shows field2 as well:

screen shot 2018-01-30 at 10 11 08

It is not visible that this field is readOnly.

Possible Solution

Context

@scottohara
Copy link
Contributor

scottohara commented Feb 7, 2018

Is this the same as #3445?

(if you expand the definition of field2 on the right hand side of the Model, does it show hello as a readOnly string field?)

@danilobuerger
Copy link
Author

No

@scottohara
Copy link
Contributor

OK, thanks.

I can see that field2 is showing as an object, but if I understand correctly, readOnly is typically set on properties of an object and not the object itself (but I could be wrong on this).

See here for some related discussion: OAI/OpenAPI-Specification#872

@danilobuerger
Copy link
Author

I personally would expect that field2 doesn't even show up there so that the model matches the example value. But if we can only mark it as readOnly, it should, as the spec doesn't prohibit this.

@webron
Copy link
Contributor

webron commented Jul 12, 2018

Updating the title to represent the issue. The readOnly information is missing both in the operations and the models section.

@webron webron changed the title readOnly, required shows up in request model readOnly attribute not rendered as property metadata Jul 12, 2018
@nzav
Copy link

nzav commented Nov 8, 2018

Any updates on this?

@stgiaf
Copy link

stgiaf commented Apr 1, 2019

Facing the same issue in SwaggerHub as well. Any update?

@CameronGo
Copy link

This is a pretty significant issue, the fact that you cannot tell from the API documentation when an object is readOnly. Has there been any movement to address this?

image

@ChMThiel
Copy link

ChMThiel commented Oct 24, 2022

Any progress here? Only description will be rendered (and the ref) if allOf is used:

quantityScrap:
  allOf:
  - $ref: '#/components/schemas/Quantity'
  - description: Total scrapped quantity booked at any Workstep
    default: My Default
    readOnly: true

will lead to something like this (default/readOnly is not shown):
grafik

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

No branches or pull requests

7 participants