Skip to content

transform function changing objects to not-nullable no longer working in v7 #1758

Closed
@IGx89

Description

@IGx89

Description

Hello! When my OpenAPI v3.0 spec has something like this:

  "foo": {
      "allOf": [
          {
              "$ref": "#/components/schemas/Bar"
          }
      ],
      "nullable": true
  },

And my transform is this:

    transform(schemaObject) {
      // Treat optional AND nullable fields as just optional (possibly undefined)
      if (!schemaObject.required && schemaObject.nullable) {
        schemaObject.nullable = false;
      }
    },

with v6 I was getting the following:

foo?: components["schemas"]["Bar"];

but with v7 I'm now getting:

foo?: components["schemas"]["Bar"] | null;

Is this expected behavior? What can I do to make v7 work like v6 did here? The logic appears to still work for primitive type fields, but no longer for object refs.

Name Version
openapi-typescript 7.0.2
Node.js 20.15.1
OS + version Windows 11

Checklist

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions