swagger-api / swagger-api/swagger-codegen

readOnly on nested objects

Open
#6,537 10 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Apparently the readOnly property is ignored for definitions of type object. In my example, SomeDefinition has a property someSubObject, which is an object and should be readOnly. So I would expect someSubObject to be in the list of readOnlyVars for SomeDefinition, but instead I find it in the readWriteVars list.

The other readOnly property, someString, is correctly listed in readOnlyVars and not in readWriteVars.

Is there something wrong with the definition, or is this a bug?

Swagger-codegen version

2.2.3

Swagger declaration file content or url
definitions:
  SomeDefinition:
    type: object
    properties:
      someString:
        readOnly: true
        type: string
      someSubObject:
        readOnly: true
        type: object
        properties:
          someProperty:
            type: string

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 with the supplied Swagger declaration and trace how readOnly is handled for SomeDefinition properties, comparing someString with the nested someSubObject. Confirm the fix by checking that the nested object appears in readOnlyVars rather than readWriteVars while the existing scalar behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.