swagger-api / swagger-api/swagger-codegen-generators

[Templates] undefined template variable readOnly used instead of isReadOnly

Open
#1,017 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Description

This issue regards at least client documentation automatic generation (plus for some languages also not just doc) with swagger-codegen because of a bug in few languages templates.
Precisely, it regards the use of the undefined template variable readOnly to check if the variable/parameter is read-only while the right variable to use in the templates is isReadOnly as defined by: https://github.com/swagger-api/swagger-codegen/commit/a6df340cdc80f71cc4bdb88aa7174013a5d41c5c

Swagger-codegen version

I am using version 3.0.30 but I don't see this fixed in the current master.

Swagger declaration file content or url
Command line used for generation

swagger-codegen generate -i <your yaml file with models that have readonly attributes> -l python -o client

Note: it does not apply only to python clients.

Steps to reproduce

Just generate for example a python client.
You will see that for the generated models documentation, models' attributes that are readonly are not annotated as readonly because of the problem mentioned above.

Related issues/PRs

I haven't found any but please feel free to point that out if I missed something.

Suggest a fix/enhancement

Replace readonly with isReadOnly whenever it occurs in the templates.

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

Search the generator templates for uses of the undefined readOnly variable, starting with the Python client generation path described in the issue. Reproduce with swagger-codegen generate -i <your yaml file with models that have readonly attributes> -l python -o client, then verify generated model documentation marks readonly attributes correctly across the affected language templates.

Written by the indexing model from the issue text.

Assessment

Domain
documentation, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.