OpenAPITools / OpenAPITools/openapi-generator
[BUG] Nullable refs are marked not nullable when unaliasing
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Given the following OAS:
openapi: 3.1.0
info:
version: 1.0.0
title: Example - OpenAPI 3.1
description: Example
components:
schemas:
WrapperType:
type: integer
format: int32
ObjectThing:
type: object
required:
- id
- field2
properties:
id:
type: string
field2:
oneOf:
- $ref: '#/components/schemas/WrapperType'
- type: 'null'
The output is
/**
*
* @export
* @interface ObjectThing
*/
export interface ObjectThing {
/**
*
* @type {string}
* @memberof ObjectThing
*/
'id': string;
/**
*
* @type {number}
* @memberof ObjectThing
*/
'field2': number;
}
Note that field2 should be of type number | null.
openapi-generator version
7.14.0
OpenAPI declaration file content or url
Generation Details
openapi-generator generate --input-spec foo.yaml -g typescript-axios
Steps to reproduce
This occurs in the Python generator as well
Related issues/PRs
Suggest a fix
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 reproducing the issue with the supplied OpenAPI 3.1 schema using the typescript-axios generator, then compare the Python generator output as noted in the report. Trace how the oneOf nullable reference is unaliased; done means field2 is generated as number | null rather than number in the affected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100