swagger-api / swagger-api/swagger-codegen
[PHP] Handle non-required property as nullable
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When a property isn't required, it is not shown in Doc Block, that the getter can actually return "null".
Also it is not shown in the setter, that "null" is a valid value
Swagger-codegen version
2.3
Swagger declaration file content or url
/path
post:
parameters:
- in: body
required: true
name: objectName
schema:
type: object
required:
- requiredPropertyName
properties:
requiredPropertyName:
type: string
notRequiredPropertyName:
type: string
Suggest a fix/enhancement
Change returnType in Doc Block for getters to correctly show, that the returned value can be null (if the property is not required).
Also shown in Doc Block for setters, that value can be null (if property is not required)
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
Start by locating the PHP generation templates or entry points that produce model getter and setter DocBlocks, then reproduce the provided schema with one required and one non-required property. Done means the generated documentation marks the optional property's getter return value and setter argument as nullable, while the required property remains non-nullable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100