swagger-api / swagger-api/swagger-codegen-generators
Python template makes `readOnly`+`required` fields required for requests. Does not respect openapi 3.0.3
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Openapi 3.0.3 says a readOnly and required field is only required in responses, not in requests. The Python template does not make this distinction and generates code such as
@field.setter
def field(self, field):
"""Sets the field of this Model.
:param field: The field of this Model. # noqa: E501
:type: str
"""
if field is None:
raise ValueError("Invalid value for `field`, must not be `None`") # noqa: E501
self._field = field
It's not possible to create an instance of Model without field for a request.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named in the issue. Start by locating the Python template logic that turns required fields into constructor or setter validation, then compare its handling of readOnly fields with OpenAPI 3.0.3. Done means a readOnly and required field is optional when creating requests while remaining required in responses, with a regression test covering the generated model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100