swagger-api / swagger-api/swagger-ui

readOnly attribute not rendered as property metadata

Open
#4,178 9 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cat: rendering type: bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied OpenAPI 3 YAML in Swagger UI and inspect how the request-body model handles the nested readOnly property. Compare the rendered request example with the expected behavior, then verify that the readOnly field is excluded from the request model and its metadata is visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.