OpenAPI Generator issue with Destination service API specification

Viewed 165

I want to get all destinations on subaccount and instance level. In SAP API business Hub, I found the API information and "SAP Cloud SDK" tab to generate code by OpenAPI generator.

https://api.sap.com/api/SAP_CP_CF_Connectivity_Destination/overview

I downloaded the API specification and added dependencies into Cloud SDK for Java project. The code is generated successfully with some errors (unknown models)in generated api classes.

For example in DestinationsOnSubaccountLevelApi.class, model OneOfDestinationNameOnly is imported and used in method but it is not generated in model package.

enter image description here enter image description here

I looked into API specification and found that there were two types of response entity. That is the reason why the code could not be generated properly. I can modify the API specification to make it work but it should not be the long term solution. Is there any other way to fix this issue?

enter image description here enter image description here

1 Answers

Unfortunately the SAP Cloud SDK Generator for Open API services is not yet able to understand oneOf relationship that is modeled in the specification.

As an alternative, would you consider using the DestinationAccessor API for resolving single destinations?

You can also directly instantiate an ScpCfDestinationLoader, which allows for querying all destinations:

ScpCfDestinationLoader loader = new ScpCfDestinationLoader();
DestinationOptions options = DestinationOptions
        .builder()
        .augmentBuilder(ScpCfDestinationOptionsAugmenter.augmenter().retrievalStrategy(ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER))
        .build();
Try<Iterable<ScpCfDestination>> destinations = loader.tryGetAllDestinations(options);

Similar to the default behavior of DestinationAccessor API, in the code above only the subscriber account will be considered. Other options are:

ScpCfDestinationRetrievalStrategy.ALWAYS_SUBSCRIBER
ScpCfDestinationRetrievalStrategy.ALWAYS_PROVIDER
ScpCfDestinationRetrievalStrategy.SUBSCRIBER_THEN_PROVIDER
Related