Skip to content

Schema field always required when default value is present. #314

Description

@niehaus1301

Hi there!

This is My OAS Schema field:

{
  "UpdateUserDto": {
    "type": "object",
    "properties": {
      "displayName": { "type": "string", "nullable": true },
      "locale": { "type": "string", "default": "DE", "nullable": true }
    }
  }
}


I am generating the client by running the following command
openapi-qraft --plugin tanstack-query-react --plugin openapi-typescript http://localhost:8080/schema --output-dir src/generated/api --explicit-component-exports --service-name-base tags --enum --clean --default-non-nullable false

When I view the generated schema.ts file, I can see that locale is always required to be set. However displayName with the same configuration, but no default value, is not required.

UpdateUserDto: {
    displayName?: string | null;
    /** @default DE */
    locale: string | null;
};

This also happens if I add nullable: false.

Thank you for checking this ! Thumbs up for this great library 👍

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions