Skip to content

[BUG] [JAVA] Is there currently support for oneOf/anyOf keywords in API spec? #18241

@azadebrahimian

Description

@azadebrahimian

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am trying to generate the necessary models for my API spec in springboot, however I am noticing issues with the generated files that utilize the oneOf keyword. I’d be more than happy to give more information on the specifics I am dealing with, but I’d first like to know if this is fully supported yet in my use case (java/springboot).

openapi-generator version

Most recent version

OpenAPI declaration file content or url
OneOfJobConfigs:
      title: OneOfJobConfigs
      oneOf:
        - $ref: '#/components/schemas/ObjectiveAJobConfig'
        - $ref: '#/components/schemas/ObjectiveBJobConfig'
        - $ref: '#/components/schemas/ObjectiveCJobConfig'
      discriminator:
        propertyName: job_config
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "job_config", visible = true)
@JsonSubTypes({
  @JsonSubTypes.Type(value = JobsConfigCreateInput.class, name = "JobsConfigCreateInput"),
  @JsonSubTypes.Type(value = ObjectiveAJobConfig.class, name = "ObjectiveAJobConfig"),
  @JsonSubTypes.Type(value = ObjectiveBJobConfig.class, name = "ObjectiveBJobConfig"),
  @JsonSubTypes.Type(value = ObjectiveCJobConfig.class, name = "ObjectiveCJobConfig")
})

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class OneOfJobConfigs {
  @JsonProperty("job_config")
  @Valid 
  private ObjectiveBJobConfigJobConfig jobConfig;
  

}

This is the generated model, but I need to be able to access all three Objective#JobConfigs from this.

Generation Details

n/a

Steps to reproduce

Use oneOf somewhere in your openAPI spec, and run the generate mvn command.

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions