Skip to content

[BUG] Nullable refs are marked not nullable when unaliasing #21612

@ben-schreiber

Description

@ben-schreiber

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions