swagger-api / swagger-api/swagger-parser

readonly is ignored for array property in model.

Open
#485 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

If a model has a readOnly array property, readOnly field is ignored and set to null when parsed with swagger parser.

Consider definition shown below.

  Category:
    type: object
    properties:
      id:
        type: integer
        format: int64
      users:
        type: array
        items:
          $ref: '#/definitions/User'
        readOnly: true
    xml:
      name: Category

Property "users" is an array of type "User" which is readOnly.
Swagger parser ignores readOnly and when parsed, readOnly is set to null.

Swagger swagger = new SwaggerParser().read("test.yaml");

test.txt

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

Start at SwaggerParser().read("test.yaml") and use the supplied test.txt definition to trace how the readOnly array property is parsed. Done means the users property retains readOnly: true instead of becoming null when the model is read.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
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.