Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-required properties not set as 'nullable' in the generated OpenAPI spec file #1551

Open
dharmil opened this issue Aug 24, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@dharmil
Copy link

dharmil commented Aug 24, 2023

Hello,

I want to report a bug, where Java variables which are by defaullt Nullable, are not set as nullable in the generated OPENAPI spec file.

I tried looking through the previous issues, but none of them address this bug.

We use this library through Quarkus.

So for example given this Java class:

class DTO {
	private String upc; // I am a nullable String
	
	@NotNull
	private String productName;
}

would result in the following object definition

  DTO:
    required:
    - productName
    type: object
    properties:
      upc:
        type: string
        # nullable declaration is missing here
      productName:
        type: string

So this library correctly sets upc as a non-required field, but doesn't set it explicitly as a nullable field. This makes a difference, because depending on the Serializer in use and its setting, it might either be serialized to JSON as

{upc: null, productName: 'chair'} or {productName: 'chair'}

In Typescript for example, this makes a huge difference because upc: string | null is not the same as upc: string | undefined and what we really want is upc: string | null | undefined

@MikeEdgar
Copy link
Member

This seems like a reasonable feature, but should probably be enabled with a configuration property to allow users to opt-in.

@MikeEdgar MikeEdgar added the enhancement New feature or request label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants