OpenAPITools / OpenAPITools/openapi-generator
[Go] Array of nullable items not modeled as a slice of pointers
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
If I run the following spec against the online API:
openapi: "3.0.3"
info:
title: Example
version: "0.0.0"
paths: {}
components:
schemas:
A:
type: object
properties:
strs:
type: array
items:
type: string
nullable: true
it produces the following model:
type A struct {
Strs []string `json:"strs,omitempty"`
}
where strs should probably be a []*string.
Some inspection of the code suggests the problem is that AbstractGoCodegen.getTypeDeclaration does not deal with nullability at all, when in reality it must because it is recursive.
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 at AbstractGoCodegen.getTypeDeclaration and reproduce the supplied OpenAPI 3.0.3 schema to trace how nullable array items are modeled. Done means the generated A model represents strs as []*string rather than []string, with appropriate coverage for the recursive nullability case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, java, openapi
- Domain
- api, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100