swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Definition for parent interface not generated

Open Blackbaud-JasonBodnar opened this issue 9 months ago • 1 comments

I have:

public class DonationFormResponse {
...
  @Schema(
            description = "The form layout.",
            oneOf = { ClassicFormLayout.class, AdaptiveFormLayout.class }
    )
    private FormLayout formLayout;
...
}

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "layout_type")
@JsonSubTypes({
        @JsonSubTypes.Type(value = ClassicFormLayout.class),
        @JsonSubTypes.Type(value = AdaptiveFormLayout.class)
})
@Schema(description = "The form layout.")
public interface FormLayout {
...
}

@Schema(allOf = FormLayout.class)
public class AdaptiveFormLayout implements FormLayout {
...
}

@Schema(allOf = FormLayout.class)
public class ClassicFormLayout implements FormLayout {
...
}

The JSON generated has:

"DonationFormResponse" : {
...
"form_layout" : {
            "oneOf" : [ {
              "$ref" : "#/components/schemas/AdaptiveFormLayout"
            }, {
              "$ref" : "#/components/schemas/ClassicFormLayout"
            } ]
          },
...
}
...
"AdaptiveFormLayout" : {
        "type" : "object",
        "allOf" : [ {
          "$ref" : "#/components/schemas/FormLayout"
        }, {
          "type" : "object",
          "properties" : {
            "cards" : {
              "type" : "array",
              "items" : {
                "$ref" : "#/components/schemas/Card"
              }
            }
          }
        } ]
      },
...
"ClassicFormLayout" : {
        "type" : "object",
        "allOf" : [ {
          "$ref" : "#/components/schemas/FormLayout"
        } ]
      },

But there is no definition for FormLayout so "$ref" : "#/components/schemas/FormLayout" results in a validation error.

Blackbaud-JasonBodnar avatar Jan 08 '25 16:01 Blackbaud-JasonBodnar