Skip to content

Conversation

@newtork
Copy link
Contributor

@newtork newtork commented Mar 5, 2025

Context

I've noticed the issue while working on this SAP/ai-sdk-java#370

Before

The following spec

  "components": {
    "schemas": {
      "Soda": {
        "type": "object",
        "properties": {
          "diet": {
            "type": "string",
            "enum": ["sugar", "zero", "light"],
            "nullable": true    // <-------
          },

evaluates to

public class Soda 
{
  public enum DietEnum {
    ...

    @JsonCreator
    @Nonnull public static DietEnum fromValue(@Nonnull final String value) {
      for (DietEnum b : DietEnum.values()) {
        if (b.value.equals(value)) {
          return b;
        }
      }
      return null; //  <------- WARNING: returning null on @Nonnull method
    }
  }

After

- @Nonnull
+ @Nullable
             public static DietEnum fromValue(@Nonnull final String value) {

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

@newtork newtork added please merge Request to merge a pull request please review Request to review a pull request labels Mar 5, 2025
Copy link
Member

@rpanackal rpanackal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@newtork newtork merged commit 144c7fd into main Mar 12, 2025
14 checks passed
@newtork newtork deleted the openapi/fix-nullable-innerenum branch March 12, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please merge Request to merge a pull request please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants