Skip to content

[BUG][Java] OneOf-Class not generated #10880

Closed
@hidingturtle

Description

@hidingturtle

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

The OpenAPI Generator v5.3.1 & 5.3.0 does not generate a OneOf-Model-Class which results in the code not being able to be built. I found the exact same issue in Java jersey2, Java native (and Rust reqwest). This confuses me as the Java generators are supposed to support OneOf (#10463 (comment) and #7263). I expected the Generator to support OneOf in Java as these two links say.

openapi-generator version

5.3.1 & 5.3.0

OpenAPI declaration file content or url

https://raw.githubusercontent.com/jdegre/5GC_APIs/master/TS29510_Nnrf_NFManagement.yaml

Generation Details

(Jersey2)
java -jar openapi-generator-cli-5.3.1-20211116.151401-16.jar generate -i Desktop/5GC_APIs/TS29510_Nnrf_NFManagement.yaml -g java -o Desktop/NRFManagement_java_jersey2 --library jersey2 --additional-properties=packageName=nfmanagement

OR

(Native)
java -jar openapi-generator-cli-5.3.1-20211116.151401-16.jar generate -i Desktop/5GC_APIs/TS29510_Nnrf_NFManagement.yaml -g java -o Desktop/NRFManagement_java_native --library native --additional-properties=packageName=nfmanagement

Steps to reproduce
  1. Generate Code of NFManagement with OpenAPI Generator (with Generation Details above)
  2. Try to build it
  3. Search for Error "Cannot resolve symbol 'OneOfNfInstanceIdCondNfInstanceIdListCondNfTypeCondServiceNameCondAmfCondGuamiListCondNetworkSliceCondNfGroupCondNfSetCondNfServiceSetCondUpfCondScpDomainCondNwdafCondNefCondDccfCond'"
Related issues/PRs

#9791
#10514
#9981

Suggest a fix

The error is caused by "TS29510_Nnrf_NFManagement.yaml" line 1449-1465. Might be worth looking into.

subscrCond:
          oneOf:
            - $ref: '#/components/schemas/NfInstanceIdCond'
            - $ref: '#/components/schemas/NfInstanceIdListCond'
            - $ref: '#/components/schemas/NfTypeCond'
            - $ref: '#/components/schemas/ServiceNameCond'
            - $ref: '#/components/schemas/AmfCond'
            - $ref: '#/components/schemas/GuamiListCond'
            - $ref: '#/components/schemas/NetworkSliceCond'
            - $ref: '#/components/schemas/NfGroupCond'
            - $ref: '#/components/schemas/NfSetCond'
            - $ref: '#/components/schemas/NfServiceSetCond'
            - $ref: '#/components/schemas/UpfCond'
            - $ref: '#/components/schemas/ScpDomainCond'
            - $ref: '#/components/schemas/NwdafCond'
            - $ref: '#/components/schemas/NefCond'
            - $ref: '#/components/schemas/DccfCond'

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