diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 000000000..d9b50e20c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,110 @@ +name: Bug Report +description: Released feature does not work as expected in the SAP Cloud SDK for Java. +labels: + - bug +body: + - type: markdown + attributes: + value: | + This repository is for Java related issues only. Please open [JavaScript / TypeScript issues here](https://github.com/SAP/cloud-sdk-js/issues/new/choose) + - type: textarea + attributes: + label: "Describe the Bug" + description: "A clear and concise description of what the bug is." + validations: + required: true + - type: textarea + attributes: + label: "Steps to Reproduce" + description: "Steps to reproduce the behavior." + placeholder: | + 1. Set up ... + 2. Execute ... + 3. Confirm ... + 4. See error + validations: + required: true + - type: textarea + attributes: + label: "Expected Behavior" + description: "A clear and concise description of what you expected to happen. In case of HTTP requests, a working Postman (or similar) request is very helpful." + validations: + required: true + - type: textarea + attributes: + label: "Screenshots" + description: "Add screenshots to help explain your problem." + validations: + required: false + - type: textarea + attributes: + label: "Used Versions" + description: "Provide versions used in the project." + value: | + - Java and Maven version via `mvn --version`: ... + - SAP Cloud SDK version: ... + - Spring Boot or CAP version: ... + -
Dependency tree via `mvn dependency:tree` + + ``` + Dependency tree here + ``` +
+ validations: + required: true + - type: textarea + attributes: + label: "Code Examples" + description: "Add code snippets as examples to help explain your problem. Please remove sensitive information." + value: | + ```java + // Your code here + ``` + validations: + required: false + - type: textarea + attributes: + label: "Stack Trace" + description: "Add your stack trace here. Please remove sensitive information." + validations: + required: false + - type: textarea + attributes: + label: "Log File" + description: "Add your log file or related error message. Please remove sensitive information." + value: | +
Log file + ... +
+ validations: + required: false + - type: dropdown + attributes: + label: "Affected Development Phase" + description: "Choose the development phase affected by this issue." + multiple: false + options: + - Getting Started + - Development + - Release + - Production + validations: + required: true + - type: dropdown + attributes: + label: "Impact" + description: "Choose the impact severity." + multiple: false + options: + - No Impact + - Inconvenience + - Impaired + - Blocked + validations: + required: true + - type: textarea + attributes: + label: "Timeline" + description: "Please briefly state your timeline, e.g., Go-Live in 12 weeks." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 000000000..17af2e7ba --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,57 @@ +name: Feature Request +description: Request a new feature to help your project using the SAP Cloud SDK for Java. +labels: + - feature request +body: + - type: markdown + attributes: + value: | + This repository is for Java related issues only. Please open [JavaScript / TypeScript issues here](https://github.com/SAP/cloud-sdk-js/issues/new/choose) + - type: textarea + attributes: + label: "Describe the Problem" + description: "A clear and concise description of what the missing feature is" + validations: + required: true + - type: textarea + attributes: + label: "Propose a Solution" + description: "A clear and concise description of what you want to happen. In case of HTTP requests, a working Postman (or similar) request is very helpful." + validations: + required: true + - type: textarea + attributes: + label: "Describe Alternatives" + description: "A clear and concise description of any alternative solutions or features you've considered." + validations: + required: false + - type: dropdown + attributes: + label: "Affected Development Phase" + description: "Choose the development phase affected by this issue." + multiple: false + options: + - Getting Started + - Development + - Release + - Production + validations: + required: true + - type: dropdown + attributes: + label: "Impact" + description: "Choose the impact severity." + multiple: false + options: + - No Impact + - Inconvenience + - Impaired + - Blocked + validations: + required: true + - type: textarea + attributes: + label: "Timeline" + description: "Please briefly state your timeline, e.g., Go-Live in 12 weeks." + validations: + required: false diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml new file mode 100644 index 000000000..a7abed351 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.yml @@ -0,0 +1,15 @@ +name: Question +description: Ask a question about the SAP Cloud SDK for Java. +labels: + - question +body: + - type: markdown + attributes: + value: | + This repository is for Java related issues only. Please open [JavaScript / TypeScript issues here](https://github.com/SAP/cloud-sdk-js/issues/new/choose) + - type: textarea + attributes: + label: "Ask the Question" + description: Give a clear and concise description. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/sdk-issue.md b/.github/ISSUE_TEMPLATE/sdk-issue.md deleted file mode 100644 index 6cda4781e..000000000 --- a/.github/ISSUE_TEMPLATE/sdk-issue.md +++ /dev/null @@ -1,90 +0,0 @@ ---- -name: SAP Cloud SDK for Java issue -about: Report an issue with the SAP Cloud SDK for Java -title: '' -labels: '' -assignees: '' - ---- - - - -## Issue Description - - -Important information: -- Your code -- Expected outcome -- Actual outcome -- Steps attempted to resolve the issue -- In case of issues with any of our VDMs: - - What happens when a request is performed directly via an HTTP client tool such as Postman? - - In case that succeeds please provide details on the request such as URL, query parameters, header parameters, prerequisite requests (e.g. CSRF token), etc. -- Potentially missing information (open questions you might have) - -### Impact / Priority - - -Affected development phase: e.g. Getting Started, Development, Release, Production - -Impact: e.g. No Impact, Inconvenience, Impaired, Blocked - -Timeline: e.g. Go-Live is in 12 weeks. - -## Error Message - -``` -Please paste your stracktrace here within the backticks (replacing this comment) -``` - - - - - -## Project Details - - - -* SDK Version: - -* Link to GitHub repo: -* Project type, for example: - * [ ] CAP Project - * [ ] SDK Maven Archetype - * [ ] None of the above: -* Platform: - * [ ] Cloud Foundry - * [ ] Deploy with Confidence (Cloud Foundry) - * [ ] None of the above: - ------ - -### Checklist - -- [ ] Checked out the [documentation](https://sap.github.io/cloud-sdk/docs/java/sdk-java-troubleshooting-frequent-problems) and [Stack Overflow](https://stackoverflow.com/questions/tagged/sap-cloud-sdk) -- [ ] Description provided with all relevant information -- [ ] Exception and stack trace provided -- [ ] Attached debug logs -- [ ] Attached dependency tree -- [ ] Provided Cloud SDK version & link to relevant source code diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml index ce0c6eb6e..9f5c9d5fa 100644 --- a/.github/dependabot.yaml +++ b/.github/dependabot.yaml @@ -29,6 +29,8 @@ updates: test: dependency-type: "development" ignore: + # updating leads to ignoring our formatting rules + - dependency-name: 'net.revelc.code.formatter:formatter-maven-plugin' # updating leads to unintended formatting of POM files - dependency-name: 'com.github.ekryd.sortpom:sortpom-maven-plugin' # used by deprecated code only, not worth updating for now diff --git a/.github/workflows/main-build.yaml b/.github/workflows/main-build.yaml index a9767764a..03fd4cc08 100644 --- a/.github/workflows/main-build.yaml +++ b/.github/workflows/main-build.yaml @@ -58,7 +58,7 @@ jobs: ci-run-id: ${{ needs.run-ci.outputs.ci-run-id }} repository-url: "https://common.repositories.cloud.sap/artifactory/build-snapshots-cloudsdk" repository-username: ${{ secrets.ARTIFACTORY_USER }} - repository-password: ${{ secrets.ARTIFACTORY_TOKEN }} + repository-password: ${{ secrets.ARTIFACTORY_PASSWORD }} release-artifact-name: ${{ env.RELEASE_ARTIFACT_NAME }} notify-job: diff --git a/.github/workflows/reuse.yaml b/.github/workflows/reuse.yaml index 0b99d1aea..779dee6e5 100644 --- a/.github/workflows/reuse.yaml +++ b/.github/workflows/reuse.yaml @@ -14,4 +14,4 @@ jobs: steps: - uses: actions/checkout@v4 - name: REUSE Compliance Check - uses: fsfe/reuse-action@v4.0.0 + uses: fsfe/reuse-action@v5.0.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1e4d5750d..8d46757d2 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,12 @@ We use GitHub to manage reviews of pull requests. * The team will review the issue and decide whether it should be implemented as a pull request. In that case, they will assign the issue to you. If the team decides against picking up the issue, the team will post a comment with an explanation. +## Contributing with AI-generated code + +As artificial intelligence evolves, AI-generated code is becoming valuable for many software projects, including open-source initiatives. While we recognize the potential benefits of incorporating AI-generated content into our open-source projects there a certain requirements that need to be reflected and adhered to when making contributions. + +Please see our [guideline for AI-generated code contributions to SAP Open Source Software Projects](https://github.com/SAP/.github/blob/main/CONTRIBUTING_USING_GENAI.md) for these requirements. + ## Steps to Contribute Should you wish to work on an issue, please claim it first by commenting on the GitHub issue that you want to work on. This is to prevent duplicated efforts from other contributors on the same issue. diff --git a/README.md b/README.md index 64b739f1e..3d53e6fbc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![build](https://github.com/SAP/cloud-sdk-java/actions/workflows/continuous-integration.yaml/badge.svg?branch=main) [![REUSE status](https://api.reuse.software/badge/github.com/SAP/cloud-sdk-java)](https://api.reuse.software/info/github.com/SAP/cloud-sdk-java) [![Fosstars security rating](https://github.com/SAP/cloud-sdk-java/blob/fosstars-report/fosstars_badge.svg)](https://github.com/SAP/cloud-sdk-java/blob/fosstars-report/fosstars_report.md) -[![Maven Central](https://img.shields.io/badge/maven_central-5.12.0-blue.svg)](https://search.maven.org/search?q=g:com.sap.cloud.sdk%20AND%20a:sdk-core%20AND%20v:5.12.0) +[![Maven Central](https://img.shields.io/badge/maven_central-5.14.0-blue.svg)](https://search.maven.org/search?q=g:com.sap.cloud.sdk%20AND%20a:sdk-core%20AND%20v:5.14.0) # SAP Cloud SDK for Java diff --git a/archetypes/pom.xml b/archetypes/pom.xml index 7ab6b08ef..a4991dfe6 100644 --- a/archetypes/pom.xml +++ b/archetypes/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT com.sap.cloud.sdk.archetypes archetypes-parent @@ -47,7 +47,7 @@ org.apache.maven.archetype archetype-packaging - 3.2.1 + 3.3.1 diff --git a/archetypes/spring-boot3/pom.xml b/archetypes/spring-boot3/pom.xml index 132258add..249ea2f43 100644 --- a/archetypes/spring-boot3/pom.xml +++ b/archetypes/spring-boot3/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.archetypes archetypes-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT spring-boot3 maven-archetype diff --git a/archetypes/spring-boot3/src/main/resources/archetype-resources/pom.xml b/archetypes/spring-boot3/src/main/resources/archetype-resources/pom.xml index 0361c67b7..31cfaee9d 100644 --- a/archetypes/spring-boot3/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/spring-boot3/src/main/resources/archetype-resources/pom.xml @@ -15,7 +15,7 @@ 3.3.0 17 - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT ${java.version} ${java.version} diff --git a/cloudplatform/caching/pom.xml b/cloudplatform/caching/pom.xml index cdbf0a67c..2012e41c4 100644 --- a/cloudplatform/caching/pom.xml +++ b/cloudplatform/caching/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT caching Business Technology Platform - Caching diff --git a/cloudplatform/caching/src/main/java/com/sap/cloud/sdk/cloudplatform/cache/CacheManager.java b/cloudplatform/caching/src/main/java/com/sap/cloud/sdk/cloudplatform/cache/CacheManager.java index 8b7e562f2..d9f12fa5c 100644 --- a/cloudplatform/caching/src/main/java/com/sap/cloud/sdk/cloudplatform/cache/CacheManager.java +++ b/cloudplatform/caching/src/main/java/com/sap/cloud/sdk/cloudplatform/cache/CacheManager.java @@ -12,7 +12,6 @@ import javax.annotation.Nullable; import com.github.benmanes.caffeine.cache.Cache; -import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableList; import com.sap.cloud.sdk.cloudplatform.security.principal.Principal; import com.sap.cloud.sdk.cloudplatform.security.principal.PrincipalAccessor; @@ -70,7 +69,6 @@ public static synchronized Cache register( @Nonnull final Cache * @return The given cache. * @since 4.3.0 */ - @Beta @Nonnull public static synchronized Cache unregister( @Nonnull final Cache cache ) { diff --git a/cloudplatform/cloudplatform-connectivity-scp-cf/pom.xml b/cloudplatform/cloudplatform-connectivity-scp-cf/pom.xml index bdc65b2ae..46b1b5aaf 100644 --- a/cloudplatform/cloudplatform-connectivity-scp-cf/pom.xml +++ b/cloudplatform/cloudplatform-connectivity-scp-cf/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT cloudplatform-connectivity-scp-cf (Deprecated) Cloud Platform - Connectivity SAP BTP Cloud Foundry diff --git a/cloudplatform/cloudplatform-connectivity/pom.xml b/cloudplatform/cloudplatform-connectivity/pom.xml index 2355b5e32..5ca98cf32 100644 --- a/cloudplatform/cloudplatform-connectivity/pom.xml +++ b/cloudplatform/cloudplatform-connectivity/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT cloudplatform-connectivity Business Technology Platform - Connectivity diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/BtpServiceOptions.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/BtpServiceOptions.java index 9bd9f3e62..f3aff4ca4 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/BtpServiceOptions.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/BtpServiceOptions.java @@ -9,7 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.connectivity.ServiceBindingDestinationOptions.OptionsEnhancer; import lombok.AccessLevel; @@ -23,7 +22,6 @@ * * @since 4.20.0 */ -@Beta public final class BtpServiceOptions { /** diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultServiceBindingDestinationLoaderChain.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultServiceBindingDestinationLoaderChain.java index 80d152af8..52da10e52 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultServiceBindingDestinationLoaderChain.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultServiceBindingDestinationLoaderChain.java @@ -11,7 +11,6 @@ import org.apache.commons.lang3.exception.ExceptionUtils; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException; @@ -42,7 +41,6 @@ * @since 4.16.0 */ @Slf4j -@Beta class DefaultServiceBindingDestinationLoaderChain implements ServiceBindingDestinationLoader { @Nonnull diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationProperty.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationProperty.java index b39493302..1bf12efb7 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationProperty.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationProperty.java @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.List; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.servlet.LocaleAccessor; /** @@ -139,7 +138,6 @@ public class DestinationProperty /** * Principal Propagation Strategy of destination, in case of Proxy Type = On-Premise. */ - @Beta public static final DestinationPropertyKey PRINCIPAL_PROPAGATION_MODE = createProperty( "cloudsdk.principalPropagationMode", diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationUtility.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationUtility.java index 513b6fd02..07c3b474e 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationUtility.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationUtility.java @@ -11,8 +11,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.annotations.Beta; - import io.vavr.control.Option; import lombok.extern.slf4j.Slf4j; @@ -23,7 +21,6 @@ * * @since 4.6.0 */ -@Beta @Slf4j public final class DestinationUtility { diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ErpDestinationHeaderProvider.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ErpDestinationHeaderProvider.java index 67e872c62..823521c3c 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ErpDestinationHeaderProvider.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ErpDestinationHeaderProvider.java @@ -10,7 +10,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.servlet.LocaleAccessor; import lombok.extern.slf4j.Slf4j; @@ -23,7 +22,6 @@ * @see DestinationProperty#DYNAMIC_SAP_LANGUAGE * @since 4.16.0 */ -@Beta @Slf4j public class ErpDestinationHeaderProvider implements DestinationHeaderProvider { diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OnBehalfOf.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OnBehalfOf.java index a661666ad..c1cab1f00 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OnBehalfOf.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OnBehalfOf.java @@ -4,14 +4,11 @@ package com.sap.cloud.sdk.cloudplatform.connectivity; -import com.google.common.annotations.Beta; - /** * Represents the behalf upon which an outbound request can be made. * * @since 4.10.0 */ -@Beta public enum OnBehalfOf { /** @@ -32,5 +29,5 @@ public enum OnBehalfOf * * @since 4.10.0 */ - NAMED_USER_CURRENT_TENANT; + NAMED_USER_CURRENT_TENANT } diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/PrincipalPropagationMode.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/PrincipalPropagationMode.java index 9945530ad..47a85d998 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/PrincipalPropagationMode.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/PrincipalPropagationMode.java @@ -4,8 +4,6 @@ package com.sap.cloud.sdk.cloudplatform.connectivity; -import com.google.common.annotations.Beta; - import lombok.RequiredArgsConstructor; /** @@ -14,7 +12,6 @@ * @since 5.0.0 */ @RequiredArgsConstructor -@Beta public enum PrincipalPropagationMode { /** diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/SecurityConfigurationStrategy.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/SecurityConfigurationStrategy.java index ece1e64c3..5d615d6f6 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/SecurityConfigurationStrategy.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/SecurityConfigurationStrategy.java @@ -7,8 +7,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; - import lombok.Getter; /** @@ -60,7 +58,6 @@ public static SecurityConfigurationStrategy getDefault() * @throws IllegalArgumentException * if no {@link SecurityConfigurationStrategy} could be found for the given identifier. */ - @Beta @Nonnull public static SecurityConfigurationStrategy ofIdentifierOrDefault( @Nullable final String identifier ) { diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationLoader.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationLoader.java index f6f59ea50..01f43d77f 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationLoader.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationLoader.java @@ -8,7 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationNotFoundException; @@ -22,7 +21,6 @@ * @since 4.16.0 */ @FunctionalInterface -@Beta public interface ServiceBindingDestinationLoader { /** diff --git a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationOptions.java b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationOptions.java index 09bd6d7f4..b5c3e61a9 100644 --- a/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationOptions.java +++ b/cloudplatform/cloudplatform-connectivity/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ServiceBindingDestinationOptions.java @@ -10,7 +10,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.DefaultServiceBindingAccessor; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; @@ -30,7 +29,6 @@ */ @RequiredArgsConstructor( access = AccessLevel.PRIVATE ) @Slf4j -@Beta public final class ServiceBindingDestinationOptions { /** diff --git a/cloudplatform/cloudplatform-core/pom.xml b/cloudplatform/cloudplatform-core/pom.xml index b1bdaeb7c..abbddf909 100644 --- a/cloudplatform/cloudplatform-core/pom.xml +++ b/cloudplatform/cloudplatform-core/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT cloudplatform-core Cloud Platform - Core diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/PlatformSslContextProvider.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/PlatformSslContextProvider.java index 518a60ca1..54927a24d 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/PlatformSslContextProvider.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/PlatformSslContextProvider.java @@ -7,14 +7,11 @@ import javax.annotation.Nonnull; import javax.net.ssl.SSLContext; -import com.google.common.annotations.Beta; - import io.vavr.control.Try; /** * Creates an SslContext based on properties of the platform. */ -@Beta @FunctionalInterface public interface PlatformSslContextProvider { diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/RequestHeadersAccessException.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/RequestHeadersAccessException.java index 3889000fd..491909a69 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/RequestHeadersAccessException.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/RequestHeadersAccessException.java @@ -6,15 +6,12 @@ import javax.annotation.Nullable; -import com.google.common.annotations.Beta; - import lombok.RequiredArgsConstructor; /** * Thrown if the request headers cannot be accessed. */ @RequiredArgsConstructor -@Beta public class RequestHeadersAccessException extends RuntimeException { private static final long serialVersionUID = -4402302735368094185L; diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderContainer.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderContainer.java index 7e9bcab3f..926138bf6 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderContainer.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderContainer.java @@ -14,7 +14,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; @@ -28,7 +27,6 @@ /** * Default implementation of the {@link RequestHeaderContainer} interface. */ -@Beta @EqualsAndHashCode @RequiredArgsConstructor( access = AccessLevel.PRIVATE ) public final class DefaultRequestHeaderContainer implements RequestHeaderContainer @@ -137,7 +135,6 @@ public String toString() * Implementation of the {@link RequestHeaderContainer.Builder} interface that is able to construct and manipulate * {@link DefaultRequestHeaderContainer}s. */ - @Beta @NoArgsConstructor( access = AccessLevel.PRIVATE ) public static class Builder implements RequestHeaderContainer.Builder { diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderFacade.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderFacade.java index 08bfe72bc..16ff64eb0 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderFacade.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/DefaultRequestHeaderFacade.java @@ -9,7 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextAccessor; import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextExecutor; @@ -18,7 +17,6 @@ /** * Default implementation of the {@link RequestHeaderFacade} interface. */ -@Beta public class DefaultRequestHeaderFacade implements RequestHeaderFacade { @Nonnull diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderAccessor.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderAccessor.java index 66d898e61..7ea1652b2 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderAccessor.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderAccessor.java @@ -12,7 +12,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.exception.RequestHeadersAccessException; import com.sap.cloud.sdk.cloudplatform.thread.Executable; import com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException; @@ -47,7 +46,6 @@ public final class RequestHeaderAccessor * The {@link RequestHeaderFacade} to use, or {@code null} if the default {@link RequestHeaderFacade} * should be used. */ - @Beta public static void setHeaderFacade( @Nullable final RequestHeaderFacade requestHeaderFacade ) { headerFacade = Objects.requireNonNullElseGet(requestHeaderFacade, DefaultRequestHeaderFacade::new); diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderContainer.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderContainer.java index 9b76d8517..5e6f8710d 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderContainer.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderContainer.java @@ -9,8 +9,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * Represents an immutable container for multiple HTTP headers. These headers consist of a {@code name} and * multiple {@code value}s. @@ -101,7 +99,6 @@ public Builder toBuilder() /** * Convenience class for constructing and manipulating {@link RequestHeaderContainer}s. */ - @Beta interface Builder { /** diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderFacade.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderFacade.java index 8b43b783d..dfd95a8fc 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderFacade.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderFacade.java @@ -6,15 +6,12 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import io.vavr.control.Try; /** * This class provides access to the {@link RequestHeaderContainer} for the current context. */ @FunctionalInterface -@Beta public interface RequestHeaderFacade { /** diff --git a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderThreadContextListener.java b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderThreadContextListener.java index a879b51ed..17fc335f2 100644 --- a/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderThreadContextListener.java +++ b/cloudplatform/cloudplatform-core/src/main/java/com/sap/cloud/sdk/cloudplatform/requestheader/RequestHeaderThreadContextListener.java @@ -7,7 +7,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.thread.Property; import com.sap.cloud.sdk.cloudplatform.thread.ThreadContext; import com.sap.cloud.sdk.cloudplatform.thread.ThreadContextListener; @@ -18,7 +17,6 @@ * Implementation of {@link ThreadContextListener} that ensures the correct initialization of the * {@link RequestHeaderContainer} when working with non-container managed threads on all supported Cloud platforms. */ -@Beta @Slf4j public class RequestHeaderThreadContextListener implements ThreadContextListener { diff --git a/cloudplatform/connectivity-apache-httpclient4/pom.xml b/cloudplatform/connectivity-apache-httpclient4/pom.xml index 39ffeb052..a9240a96f 100644 --- a/cloudplatform/connectivity-apache-httpclient4/pom.xml +++ b/cloudplatform/connectivity-apache-httpclient4/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT connectivity-apache-httpclient4 Connectivity - Apache HTTP Client 4 diff --git a/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/AbstractHttpClientCache.java b/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/AbstractHttpClientCache.java index b9a68a126..fa6154352 100644 --- a/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/AbstractHttpClientCache.java +++ b/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/AbstractHttpClientCache.java @@ -76,23 +76,18 @@ private Try tryGetOrCreateHttpClient( final Try> maybeCache = getCache(); if( maybeCache.isFailure() ) { - final String msg = - "Failed to get HttpClientCache. Falling back to creating a new http client instance." - + " This is unexpected and will be changed to fail instead in a future version of Cloud SDK." - + " Please analyze the attached stack trace and resolve the issue."; - log.error(msg, maybeCache.getCause()); - return Try.ofSupplier(createHttpClient); + return Try + .failure(new HttpClientInstantiationException("Failed to get HttpClientCache.", maybeCache.getCause())); } final Try maybeKey = destination != null ? getCacheKey(destination) : getCacheKey(); if( maybeKey.isFailure() ) { - final String msg = - "Failed to create cache key for HttpClient. Falling back to creating a new http client instance." - + " This is unexpected and will be changed to fail instead in a future version of Cloud SDK." - + " Please analyze the attached stack trace and resolve the issue."; - log.error(msg, maybeKey.getCause()); - return Try.ofSupplier(createHttpClient); + return Try + .failure( + new HttpClientInstantiationException( + "Failed to create cache key for HttpClient", + maybeKey.getCause())); } final Cache cache = maybeCache.get(); diff --git a/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCache.java b/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCache.java index ae238f36e..943dd3a8a 100644 --- a/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCache.java +++ b/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCache.java @@ -96,10 +96,8 @@ protected Try getCacheKey( @Nonnull final HttpDestinationProperties de } if( maybeTenant.isFailure() ) { final String msg = - "Tenant and Principal accessors are returning inconsistent results: A principal is defined, but no tenant is defined in the current context." - + " This is unexpected and will be changed to fail instead in a future version of Cloud SDK." - + " Please analyze the attached stack trace and resolve the issue."; - log.error(msg, maybeTenant.getCause()); + "Tenant and Principal accessors are returning inconsistent results: A principal is defined, but no tenant is defined in the current context."; + return Try.failure(new IllegalStateException(msg, maybeTenant.getCause())); } return Try.success(CacheKey.of(maybeTenant.getOrNull(), principal.get()).append(destination)); } diff --git a/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientCache.java b/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientCache.java index 5a1472e45..8a3d1a2ab 100644 --- a/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientCache.java +++ b/cloudplatform/connectivity-apache-httpclient4/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientCache.java @@ -8,7 +8,6 @@ import org.apache.http.client.HttpClient; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; import io.vavr.control.Try; @@ -55,7 +54,6 @@ Try tryGetHttpClient( * Constant implementation of {@see HttpClientCache} with disabled the cache logic. Useful for testing and * troubleshooting. Don't use in production. */ - @Beta @Nonnull HttpClientCache DISABLED = new HttpClientCache() { diff --git a/cloudplatform/connectivity-apache-httpclient4/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCacheTest.java b/cloudplatform/connectivity-apache-httpclient4/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCacheTest.java index 73debc17b..186bc8571 100644 --- a/cloudplatform/connectivity-apache-httpclient4/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCacheTest.java +++ b/cloudplatform/connectivity-apache-httpclient4/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultHttpClientCacheTest.java @@ -5,6 +5,7 @@ package com.sap.cloud.sdk.cloudplatform.connectivity; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.ArrayList; import java.util.Arrays; @@ -24,6 +25,7 @@ import org.junit.jupiter.api.parallel.Isolated; import com.sap.cloud.sdk.cloudplatform.cache.CacheManager; +import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; import com.sap.cloud.sdk.cloudplatform.security.principal.DefaultPrincipal; import com.sap.cloud.sdk.cloudplatform.security.principal.Principal; import com.sap.cloud.sdk.cloudplatform.tenant.DefaultTenant; @@ -125,12 +127,15 @@ void testGetClientWithUserTokenExchangeDestinationUsesPrincipalRequiredForIsolat for( final Tenant tenantToTest : tenants ) { for( final Principal principalToTest : principals ) { - if( principalToTest == null ) { - // covered by the last assertion - continue; - } context.setTenant(tenantToTest); context.setPrincipal(principalToTest); + if( tenantToTest == null || principalToTest == null ) { + assertThatThrownBy(() -> sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) + .describedAs( + "Without a tenant and principal http clients should not be cached for user based destinations") + .isInstanceOf(HttpClientInstantiationException.class); + continue; + } final HttpClient clientWithDestination = sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get(); @@ -144,10 +149,6 @@ void testGetClientWithUserTokenExchangeDestinationUsesPrincipalRequiredForIsolat clients.add(clientWithDestination); } - context.clearPrincipal(); - assertThat(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) - .describedAs("Without a principal http clients should not be cached for user based destinations") - .isNotSameAs(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()); } } @@ -218,7 +219,7 @@ void testGetClientReturnsSameClientForDestinationsWithOnlyDifferentHeaderProvide } @Test - void testGetClientUsesTenantAndPrincipalOptionalForIsolation() + void testGetClientUsesTenantAndPrincipalRequiredForIsolation() { final HttpClientCache sut = new DefaultHttpClientCache(5L, TimeUnit.MINUTES); @@ -226,13 +227,16 @@ void testGetClientUsesTenantAndPrincipalOptionalForIsolation() for( final Tenant tenantToTest : tenants ) { for( final Principal principalToTest : principals ) { - if( principalToTest == null ) { - // covered by the last assertion - continue; - } context.setTenant(tenantToTest); context.setPrincipal(principalToTest); + if( tenantToTest == null || principalToTest == null ) { + assertThatThrownBy(() -> sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) + .describedAs("Without a tenant or principal http clients should not be cached") + .isInstanceOf(HttpClientInstantiationException.class); + continue; + } + final HttpClient clientWithDestination = sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get(); @@ -255,10 +259,6 @@ void testGetClientUsesTenantAndPrincipalOptionalForIsolation() clients.add(clientWithoutDestination); } - context.clearPrincipal(); - assertThat(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) - .describedAs("Without a principal http clients should not be cached for user based destinations") - .isNotSameAs(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()); } } @@ -299,6 +299,7 @@ void testInvalidateTenantCacheEntries() @Test void testInvalidatePrincipalCacheEntries() { + context.setTenant("some-tenant"); context.setPrincipal("some-principal"); final HttpClient unclearedClientWithoutDestination = sut.tryGetHttpClient(FACTORY).get(); @@ -312,7 +313,8 @@ void testInvalidatePrincipalCacheEntries() //Only clientWithoutDestination is cached with the cache key containing principal assertThat( - CacheManager.invalidatePrincipalCaches(null, principal != null ? principal.getPrincipalId() : null)) + CacheManager + .invalidatePrincipalCaches("some-tenant", principal != null ? principal.getPrincipalId() : null)) .isEqualTo(1); assertThat(clientWithoutDestination).isNotSameAs(sut.tryGetHttpClient(FACTORY).get()); @@ -325,6 +327,7 @@ void testInvalidatePrincipalCacheEntries() @Test void testInvalidatePrincipalCacheEntriesWithUserTokenExchangeDestination() { + context.setTenant("some-tenant"); context.setPrincipal("some-principal"); final HttpClient unclearedClientWithDestination = sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get(); @@ -345,7 +348,7 @@ void testInvalidatePrincipalCacheEntriesWithUserTokenExchangeDestination() assertThat(clientWithoutDestination).isSameAs(sut.tryGetHttpClient(FACTORY).get()); //Both clientWithoutDestination and clientWithDestination are cached with the cache key containing principal - assertThat(CacheManager.invalidatePrincipalCaches(null, principalId)).isEqualTo(2); + assertThat(CacheManager.invalidatePrincipalCaches("some-tenant", principalId)).isEqualTo(2); assertThat(clientWithDestination) .isNotSameAs(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()); @@ -367,6 +370,7 @@ void testPrincipalPropagationIsPrincipalIsolated() .authenticationType(AuthenticationType.PRINCIPAL_PROPAGATION) .build(); + context.setTenant(); context.setPrincipal("some-principal"); final HttpClient client = sut.tryGetHttpClient(destination, FACTORY).get(); assertThat(client).isSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); @@ -377,9 +381,8 @@ void testPrincipalPropagationIsPrincipalIsolated() .isSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); context.clearPrincipal(); - assertThat(client).isNotSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); - assertThat(sut.tryGetHttpClient(destination, FACTORY).get()) + assertThatThrownBy(() -> sut.tryGetHttpClient(destination, FACTORY).get()) .describedAs("Without a principal http clients should not be cached for user based destinations") - .isNotSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); + .isInstanceOf(HttpClientInstantiationException.class); } } diff --git a/cloudplatform/connectivity-apache-httpclient5/pom.xml b/cloudplatform/connectivity-apache-httpclient5/pom.xml index 73eb2c590..f5f72cfc3 100644 --- a/cloudplatform/connectivity-apache-httpclient5/pom.xml +++ b/cloudplatform/connectivity-apache-httpclient5/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT connectivity-apache-httpclient5 Apache version 5 Http Client integration @@ -128,5 +128,10 @@ testutil test + + org.junit.jupiter + junit-jupiter-params + test + diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Accessor.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Accessor.java index 84c8361aa..61cf2fd65 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Accessor.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Accessor.java @@ -9,7 +9,6 @@ import org.apache.hc.client5.http.classic.HttpClient; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; @@ -23,7 +22,6 @@ * * @since 4.20.0 */ -@Beta @NoArgsConstructor( access = AccessLevel.PRIVATE ) public final class ApacheHttpClient5Accessor { diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Cache.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Cache.java index ad82d95de..ad1297b27 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Cache.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Cache.java @@ -23,7 +23,6 @@ * * @since 4.20.0 */ -@Beta public interface ApacheHttpClient5Cache { /** @@ -34,6 +33,7 @@ public interface ApacheHttpClient5Cache * @return A new {@code HttpClient5Cache} instance. */ @Nonnull + @Beta static ApacheHttpClient5Cache newDefaultCache( @Nonnull final Duration cacheDuration ) { return new DefaultApacheHttpClient5Cache(cacheDuration); @@ -73,7 +73,6 @@ Try tryGetHttpClient( * Constant implementation of {@see HttpClient5Cache} with disabled the cache logic. Useful for testing and * troubleshooting. Don't use in production. */ - @Beta @Nonnull ApacheHttpClient5Cache DISABLED = new ApacheHttpClient5Cache() { diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5CacheBuilder.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5CacheBuilder.java index b944c36bc..5ded93251 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5CacheBuilder.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5CacheBuilder.java @@ -17,7 +17,6 @@ * * @since 4.20.0 */ -@Beta public class ApacheHttpClient5CacheBuilder { @Nonnull @@ -34,6 +33,7 @@ public class ApacheHttpClient5CacheBuilder * @return This builder. */ @Nonnull + @Beta public ApacheHttpClient5CacheBuilder durationInMilliseconds( final int durationInMilliseconds ) { return duration(Duration.ofMillis(durationInMilliseconds)); diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Factory.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Factory.java index a5ec7846a..3994b961c 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Factory.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Factory.java @@ -9,7 +9,6 @@ import org.apache.hc.client5.http.classic.HttpClient; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; @@ -23,7 +22,6 @@ * * @since 4.20.0 */ -@Beta @FunctionalInterface public interface ApacheHttpClient5Factory { diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5FactoryBuilder.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5FactoryBuilder.java index 0b77ff50a..839fe702c 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5FactoryBuilder.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5FactoryBuilder.java @@ -17,14 +17,36 @@ * * @since 4.20.0 */ -@Beta public class ApacheHttpClient5FactoryBuilder { @Nonnull private Duration timeout = DefaultApacheHttpClient5Factory.DEFAULT_TIMEOUT; + private TlsUpgrade tlsUpgrade = TlsUpgrade.AUTOMATIC; private int maxConnectionsTotal = DefaultApacheHttpClient5Factory.DEFAULT_MAX_CONNECTIONS_TOTAL; private int maxConnectionsPerRoute = DefaultApacheHttpClient5Factory.DEFAULT_MAX_CONNECTIONS_PER_ROUTE; + /** + * Enum to control the automatic TLS upgrade feature for insecure connections. + * + * @since 5.14.0 + */ + @Beta + public enum TlsUpgrade + { + /** + * Automatic TLS upgrade is enabled. + */ + ENABLED, + /** + * Automatic TLS upgrade is disabled. + */ + DISABLED, + /** + * Automatic TLS upgrade is enabled only for {@link ProxyType#INTERNET}, default. + */ + AUTOMATIC; + } + /** * Sets the timeout {@link HttpClient} instances created by the to-be-built {@link ApacheHttpClient5Factory} should * use. This timeout applies to the following concerns: @@ -92,6 +114,19 @@ public ApacheHttpClient5FactoryBuilder maxConnectionsTotal( final int maxConnect return this; } + /** + * Sets the automatic TLS upgrade strategy. This strategy controls whether insecure connections should be + * automatically upgraded. + * + * @since 5.14.0 + */ + @Nonnull + public ApacheHttpClient5FactoryBuilder tlsUpgrade( @Nonnull final TlsUpgrade tlsUpgrade ) + { + this.tlsUpgrade = tlsUpgrade; + return this; + } + /** * Sets the maximum number of parallel connections per route (e.g. per remote host) that can be established * with a {@link HttpClient} created by the to-be-built {@link ApacheHttpClient5Factory}. @@ -119,6 +154,11 @@ public ApacheHttpClient5FactoryBuilder maxConnectionsPerRoute( final int maxConn @Nonnull public ApacheHttpClient5Factory build() { - return new DefaultApacheHttpClient5Factory(timeout, maxConnectionsTotal, maxConnectionsPerRoute, null); + return new DefaultApacheHttpClient5Factory( + timeout, + maxConnectionsTotal, + maxConnectionsPerRoute, + null, + tlsUpgrade); } } diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Wrapper.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Wrapper.java index 139dd6305..ee144d010 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Wrapper.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5Wrapper.java @@ -8,6 +8,8 @@ import java.net.URI; import java.net.URISyntaxException; +import org.apache.hc.client5.http.config.Configurable; +import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; import org.apache.hc.core5.http.ClassicHttpRequest; @@ -30,11 +32,12 @@ * and it will append the url configured in the destination. */ @Slf4j -class ApacheHttpClient5Wrapper extends CloseableHttpClient +class ApacheHttpClient5Wrapper extends CloseableHttpClient implements Configurable { private final CloseableHttpClient httpClient; @Getter( AccessLevel.PACKAGE ) private final HttpDestinationProperties destination; + private final RequestConfig requestConfig; @Override public void close() @@ -49,7 +52,10 @@ public void close( final CloseMode closeMode ) httpClient.close(closeMode); } - ApacheHttpClient5Wrapper( final CloseableHttpClient httpClient, final HttpDestinationProperties destination ) + ApacheHttpClient5Wrapper( + final CloseableHttpClient httpClient, + final HttpDestinationProperties destination, + final RequestConfig requestConfig ) { this.httpClient = httpClient; @@ -62,6 +68,7 @@ public void close( final CloseMode closeMode ) """); } this.destination = destination; + this.requestConfig = requestConfig; } @Override @@ -86,7 +93,7 @@ ApacheHttpClient5Wrapper withDestination( final HttpDestinationProperties destin if( destination == this.destination ) { return this; } - return new ApacheHttpClient5Wrapper(httpClient, destination); + return new ApacheHttpClient5Wrapper(httpClient, destination, requestConfig); } ClassicHttpRequest wrapRequest( final ClassicHttpRequest request ) @@ -119,4 +126,10 @@ ClassicHttpRequest wrapRequest( final ClassicHttpRequest request ) return requestBuilder.build(); } + + @Override + public RequestConfig getConfig() + { + return requestConfig; + } } diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Cache.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Cache.java index 55186393f..16743201f 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Cache.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Cache.java @@ -80,12 +80,7 @@ private Try tryGetOrCreateHttpClient( cacheKey = getCacheKey(destination); } catch( final TenantAccessException | PrincipalAccessException | IllegalStateException e ) { - final String msg = - "Failed to create cache key for HttpClient. Falling back to creating a new http client instance." - + " This is unexpected and will be changed to fail instead in a future version of Cloud SDK." - + " Please analyze the attached stack trace and resolve the issue."; - log.error(msg, e); - return Try.ofSupplier(createHttpClient); + return Try.failure(new HttpClientInstantiationException("Failed to create cache key for HttpClient", e)); } final HttpClient httpClient; @@ -125,10 +120,8 @@ private CacheKey getCacheKey( @Nullable final HttpDestinationProperties destinat } if( maybeTenant.isFailure() ) { final String msg = - "Tenant and Principal accessors are returning inconsistent results: A principal is defined, but no tenant is defined in the current context." - + " This is unexpected and will be changed to fail instead in a future version of Cloud SDK." - + " Please analyze the attached stack trace and resolve the issue."; - log.error(msg, maybeTenant.getCause()); + "Tenant and Principal accessors are returning inconsistent results: A principal is defined, but no tenant is defined in the current context."; + throw new IllegalStateException(msg, maybeTenant.getCause()); } return CacheKey.of(maybeTenant.getOrNull(), principal.get()).append(destination); } diff --git a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Factory.java b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Factory.java index 68248743a..61847cd03 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Factory.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5Factory.java @@ -24,9 +24,10 @@ import org.apache.hc.client5.http.impl.classic.HttpClients; import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy; import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier; import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; -import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.ssl.TlsSocketStrategy; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequestInterceptor; import org.apache.hc.core5.http.io.SocketConfig; @@ -49,28 +50,25 @@ class DefaultApacheHttpClient5Factory implements ApacheHttpClient5Factory private final Timeout timeout; private final int maxConnectionsTotal; private final int maxConnectionsPerRoute; - // for testing purposes + @Nullable private final HttpRequestInterceptor requestInterceptor; - DefaultApacheHttpClient5Factory( - @Nonnull final Duration timeout, - final int maxConnectionsTotal, - final int maxConnectionsPerRoute ) - { - this(timeout, maxConnectionsTotal, maxConnectionsPerRoute, null); - } + @Nonnull + private final ApacheHttpClient5FactoryBuilder.TlsUpgrade tlsUpgrade; DefaultApacheHttpClient5Factory( @Nonnull final Duration timeout, final int maxConnectionsTotal, final int maxConnectionsPerRoute, - @Nullable final HttpRequestInterceptor requestInterceptor ) + @Nullable final HttpRequestInterceptor requestInterceptor, + @Nonnull final ApacheHttpClient5FactoryBuilder.TlsUpgrade tlsUpgrade ) { this.timeout = toTimeout(timeout); this.maxConnectionsTotal = maxConnectionsTotal; this.maxConnectionsPerRoute = maxConnectionsPerRoute; this.requestInterceptor = requestInterceptor; + this.tlsUpgrade = tlsUpgrade; } @Nonnull @@ -79,22 +77,25 @@ public HttpClient createHttpClient( @Nullable final HttpDestinationProperties de throws DestinationAccessException, HttpClientInstantiationException { - final CloseableHttpClient httpClient = buildHttpClient(destination); + final var requestConfig = getRequestConfig(destination); + final CloseableHttpClient httpClient = buildHttpClient(destination, requestConfig); if( destination == null ) { return httpClient; } - return new ApacheHttpClient5Wrapper(httpClient, destination); + return new ApacheHttpClient5Wrapper(httpClient, destination, requestConfig); } @Nonnull - private CloseableHttpClient buildHttpClient( @Nullable final HttpDestinationProperties destination ) + private CloseableHttpClient buildHttpClient( + @Nullable final HttpDestinationProperties destination, + @Nonnull final RequestConfig requestConfig ) { final HttpClientBuilder builder = HttpClients .custom() .setConnectionManager(getConnectionManager(destination)) - .setDefaultRequestConfig(getRequestConfig()) + .setDefaultRequestConfig(requestConfig) .setProxy(getProxy(destination)); if( requestInterceptor != null ) { @@ -110,7 +111,7 @@ private HttpClientConnectionManager getConnectionManager( @Nullable final HttpDe try { return PoolingHttpClientConnectionManagerBuilder .create() - .setSSLSocketFactory(getConnectionSocketFactory(destination)) + .setTlsSocketStrategy(getTlsSocketStrategy(destination)) .setDefaultSocketConfig(SocketConfig.custom().setSoTimeout(timeout).build()) .setDefaultConnectionConfig( ConnectionConfig.custom().setConnectTimeout(timeout).setSocketTimeout(timeout).build()) @@ -130,8 +131,7 @@ private static Timeout toTimeout( @Nonnull final Duration duration ) } @Nullable - private SSLConnectionSocketFactory getConnectionSocketFactory( - @Nullable final HttpDestinationProperties destination ) + private TlsSocketStrategy getTlsSocketStrategy( @Nullable final HttpDestinationProperties destination ) throws GeneralSecurityException, IOException { @@ -144,7 +144,7 @@ private SSLConnectionSocketFactory getConnectionSocketFactory( final HostnameVerifier hostnameVerifier = getHostnameVerifier(destination); - return new SSLConnectionSocketFactory(sslContext, hostnameVerifier); + return new DefaultClientTlsStrategy(sslContext, hostnameVerifier); } private boolean supportsTls( @Nullable final HttpDestinationProperties destination ) @@ -162,9 +162,30 @@ private HostnameVerifier getHostnameVerifier( final HttpDestinationProperties de } @Nonnull - private RequestConfig getRequestConfig() + private RequestConfig getRequestConfig( @Nullable final HttpDestinationProperties destination ) + { + return RequestConfig + .custom() + .setProtocolUpgradeEnabled(isProtocolUpgradeEnabled(destination)) + .setConnectionRequestTimeout(timeout) + .build(); + } + + private boolean isProtocolUpgradeEnabled( @Nullable final HttpDestinationProperties destination ) { - return RequestConfig.custom().setConnectionRequestTimeout(timeout).build(); + return switch( tlsUpgrade ) { + case ENABLED -> true; + case DISABLED -> false; + case AUTOMATIC -> { + if( destination == null ) { + yield true; + } + if( destination.getTlsVersion().isDefined() ) { + yield false; + } + yield !destination.getProxyType().contains(ProxyType.ON_PREMISE); + } + }; } @Nullable diff --git a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5HeaderTest.java b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5HeaderTest.java new file mode 100644 index 000000000..bad5c5a74 --- /dev/null +++ b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ApacheHttpClient5HeaderTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package com.sap.cloud.sdk.cloudplatform.connectivity; + +import static java.util.function.Predicate.not; + +import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; +import static com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.TlsUpgrade; +import static com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.TlsUpgrade.AUTOMATIC; +import static com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.TlsUpgrade.DISABLED; +import static com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.TlsUpgrade.ENABLED; +import static com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination.builder; + +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +import javax.annotation.Nonnull; + +import org.apache.hc.client5.http.classic.methods.HttpGet; +import org.apache.hc.client5.http.impl.classic.BasicHttpClientResponseHandler; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.FieldSource; + +import com.github.tomakehurst.wiremock.http.Request; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; +import com.github.tomakehurst.wiremock.matching.MatchResult; +import com.github.tomakehurst.wiremock.matching.ValueMatcher; +import com.github.tomakehurst.wiremock.stubbing.SubEvent; + +import lombok.RequiredArgsConstructor; +import lombok.SneakyThrows; +import lombok.Value; + +@WireMockTest +class ApacheHttpClient5HeaderTest +{ + @RequiredArgsConstructor + enum TestDestination + { + INTERNET(url -> builder(url).build()), + PROXY(url -> builder(url).proxyType(ProxyType.INTERNET).proxyConfiguration(ProxyConfiguration.of(url)).build()), + ON_PREMISE( + url -> builder(url) + .proxyType(ProxyType.ON_PREMISE) + .proxyConfiguration(ProxyConfiguration.of(url)) + .buildInternal()), + TLS_VERSION(url -> builder(url).tlsVersion("TLSv1.1").build()); + + private final Function destinationBuilder; + } + + @RequiredArgsConstructor + enum TestAssertion + { + DEFAULT(List.of("Connection", "Host", "User-Agent", "Accept-Encoding"), Map.of()), + UPGRADE( + List.of("Connection", "Host", "User-Agent", "Accept-Encoding", "Upgrade"), + Map.of("Connection", "Upgrade", "Upgrade", "TLS/1.2")); + + private final List headersAllowed; + private final Map headersRequired; + } + + @Value + static class TestCase + { + TestDestination destination; + TlsUpgrade tlsFlag; + TestAssertion assertion; + } + + @SuppressWarnings( "unused" ) + private static final TestCase[] TEST_CASES = + { + // Forced HTTP/TLS upgrade + new TestCase(TestDestination.INTERNET, ENABLED, TestAssertion.UPGRADE), + new TestCase(TestDestination.PROXY, ENABLED, TestAssertion.UPGRADE), + new TestCase(TestDestination.ON_PREMISE, ENABLED, TestAssertion.UPGRADE), + new TestCase(TestDestination.TLS_VERSION, ENABLED, TestAssertion.UPGRADE), + + // Disabled HTTP/TLS upgrade + new TestCase(TestDestination.INTERNET, DISABLED, TestAssertion.DEFAULT), + new TestCase(TestDestination.PROXY, DISABLED, TestAssertion.DEFAULT), + new TestCase(TestDestination.ON_PREMISE, DISABLED, TestAssertion.DEFAULT), + new TestCase(TestDestination.TLS_VERSION, DISABLED, TestAssertion.DEFAULT), + + // Automatic HTTP/TLS upgrade + new TestCase(TestDestination.INTERNET, AUTOMATIC, TestAssertion.UPGRADE), + new TestCase(TestDestination.PROXY, AUTOMATIC, TestAssertion.UPGRADE), + new TestCase(TestDestination.ON_PREMISE, AUTOMATIC, TestAssertion.DEFAULT), + new TestCase(TestDestination.TLS_VERSION, AUTOMATIC, TestAssertion.DEFAULT) }; + + @SneakyThrows + @ParameterizedTest + @FieldSource( "TEST_CASES" ) + void testHeader( @Nonnull final TestCase testCase, @Nonnull final WireMockRuntimeInfo server ) + { + stubFor(get(anyUrl()).willReturn(ok())); + + var sut = new ApacheHttpClient5FactoryBuilder().tlsUpgrade(testCase.tlsFlag).build(); + var dest = testCase.destination.destinationBuilder.apply(server.getHttpBaseUrl()); + sut.createHttpClient(dest).execute(new HttpGet("/foo"), new BasicHttpClientResponseHandler()); + + var request = getRequestedFor(anyUrl()).andMatching(allowedHeaders(testCase.assertion.headersAllowed)); + testCase.assertion.headersRequired.forEach(( k, v ) -> request.withHeader(k, equalTo(v))); + verify(request); + } + + static ValueMatcher allowedHeaders( @Nonnull final List headers ) + { + return req -> { + var excess = req.getAllHeaderKeys().stream().filter(not(headers::contains)).map(SubEvent::error).toList(); + return excess.isEmpty() ? MatchResult.exactMatch() : MatchResult.noMatch(excess); + }; + } +} diff --git a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ClientCertificateAuthenticationLocalTest.java b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ClientCertificateAuthenticationLocalTest.java index 1083e803b..c28167c69 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ClientCertificateAuthenticationLocalTest.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/ClientCertificateAuthenticationLocalTest.java @@ -86,7 +86,7 @@ void testClientCorrectlyConfigured() assertThat(context.getUserToken()).isNotNull(); assertThat(context.getUserToken()).isInstanceOf(X500Principal.class); - assertThat(context.getUserToken(X500Principal.class).getName()).contains("CN=localhost"); + assertThat(((X500Principal) context.getUserToken()).getName()).contains("CN=localhost"); // assert keystore methods have been used Mockito.verify(destination).getKeyStorePassword(); diff --git a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5CacheTest.java b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5CacheTest.java index eb84b3cd5..895b58c32 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5CacheTest.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5CacheTest.java @@ -5,6 +5,7 @@ package com.sap.cloud.sdk.cloudplatform.connectivity; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.time.Duration; import java.util.ArrayList; @@ -24,10 +25,19 @@ import org.junit.jupiter.api.extension.RegisterExtension; import com.sap.cloud.sdk.cloudplatform.cache.CacheManager; +import com.sap.cloud.sdk.cloudplatform.connectivity.exception.HttpClientInstantiationException; +import com.sap.cloud.sdk.cloudplatform.security.principal.DefaultPrincipal; +import com.sap.cloud.sdk.cloudplatform.security.principal.Principal; +import com.sap.cloud.sdk.cloudplatform.tenant.DefaultTenant; +import com.sap.cloud.sdk.cloudplatform.tenant.Tenant; import com.sap.cloud.sdk.testutil.TestContext; class DefaultApacheHttpClient5CacheTest { + private static final List TENANTS = + Arrays.asList(new DefaultTenant("tenant#1"), new DefaultTenant("tenant#2"), null); + private static final List PRINCIPALS = + Arrays.asList(new DefaultPrincipal("principal#1"), new DefaultPrincipal("principal#2"), null); @RegisterExtension static final TestContext context = TestContext.withThreadContext(); @@ -42,7 +52,9 @@ class DefaultApacheHttpClient5CacheTest new DefaultApacheHttpClient5Factory( DefaultApacheHttpClient5Factory.DEFAULT_TIMEOUT, DefaultApacheHttpClient5Factory.DEFAULT_MAX_CONNECTIONS_TOTAL, - DefaultApacheHttpClient5Factory.DEFAULT_MAX_CONNECTIONS_PER_ROUTE); + DefaultApacheHttpClient5Factory.DEFAULT_MAX_CONNECTIONS_PER_ROUTE, + null, + ApacheHttpClient5FactoryBuilder.TlsUpgrade.AUTOMATIC); private static final long NANOSECONDS_IN_MINUTE = 60_000_000_000L; private static final Duration TEN_MINUTES = Duration.ofMinutes(10L); @@ -97,22 +109,12 @@ void testGetClientExpiresAfterAccess() @Test void testGetClientWithoutDestinationUsesTenantAndPrincipalOptionalForIsolation() { - final List tenantsToTest = Arrays.asList("tenant#1", "tenant#2", null); - final List principalsToTest = Arrays.asList("principal#1", "principal#2", null); final List clients = new ArrayList<>(); - for( final String tenantId : tenantsToTest ) { - for( final String principalId : principalsToTest ) { - context.clearTenant(); - context.clearPrincipal(); - - if( tenantId != null ) { - context.setTenant(tenantId); - } - - if( principalId != null ) { - context.setPrincipal(principalId); - } + for( final Tenant tenant : TENANTS ) { + for( final Principal principal : PRINCIPALS ) { + context.setTenant(tenant); + context.setPrincipal(principal); final HttpClient clientWithoutDestination = sut.tryGetHttpClient(FACTORY).get(); @@ -130,20 +132,21 @@ void testGetClientWithoutDestinationUsesTenantAndPrincipalOptionalForIsolation() @Test void testGetClientWithUserTokenExchangeDestinationUsesPrincipalRequiredForIsolation() { - final List tenantsToTest = Arrays.asList("tenant#1", "tenant#2", null); - final List principalsToTest = Arrays.asList("principal#1", "principal#2"); final List clients = new ArrayList<>(); - for( final String tenantId : tenantsToTest ) { - for( final String principalId : principalsToTest ) { - context.clearTenant(); + for( final Tenant tenant : TENANTS ) { + for( final Principal principal : PRINCIPALS ) { + context.setTenant(tenant); + context.setPrincipal(principal); - if( tenantId != null ) { - context.setTenant(tenantId); + if( tenant == null || principal == null ) { + assertThatThrownBy(() -> sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) + .describedAs( + "Without a tenant and principal http clients should not be cached for user based destinations") + .isInstanceOf(HttpClientInstantiationException.class); + continue; } - context.setPrincipal(principalId); - final HttpClient clientWithDestination = sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get(); @@ -156,34 +159,19 @@ void testGetClientWithUserTokenExchangeDestinationUsesPrincipalRequiredForIsolat clients.add(clientWithDestination); } - context.clearPrincipal(); - assertThat(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) - .describedAs("Without a principal http clients should not be cached for user based destinations") - .isNotSameAs(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()); } - } @Test void testGetClientWithDestinationUsesTenantOptionalForIsolation() { - final List tenantsToTest = Arrays.asList("tenant#1", "tenant#2", null); - final List principalsToTest = Arrays.asList("principal#1", "principal#2", null); final List clients = new ArrayList<>(); final Set tenantClients = new HashSet<>(); - for( final String tenantId : tenantsToTest ) { - for( final String principalId : principalsToTest ) { - context.clearTenant(); - context.clearPrincipal(); - - if( tenantId != null ) { - context.setTenant(tenantId); - } - - if( principalId != null ) { - context.setPrincipal(principalId); - } + for( final Tenant tenant : TENANTS ) { + for( final Principal principal : PRINCIPALS ) { + context.setTenant(tenant); + context.setPrincipal(principal); final HttpClient clientWithDestination = sut.tryGetHttpClient(DESTINATION, FACTORY).get(); @@ -203,25 +191,20 @@ void testGetClientWithDestinationUsesTenantOptionalForIsolation() } @Test - void testGetClientUsesTenantAndPrincipalOptionalForIsolation() + void testGetClientUsesTenantAndPrincipalRequiredForIsolation() { - final List tenantsToTest = Arrays.asList("tenant#1", "tenant#2", null); - final List principalsToTest = Arrays.asList("principal#1", "principal#2", null); final List clients = new ArrayList<>(); - for( final String tenantId : tenantsToTest ) { - for( final String principalId : principalsToTest ) { - context.clearTenant(); - context.clearPrincipal(); + for( final Tenant tenant : TENANTS ) { + for( final Principal principal : PRINCIPALS ) { + context.setTenant(tenant); + context.setPrincipal(principal); - if( tenantId != null ) { - context.setTenant(tenantId); - } - - if( principalId != null ) { - context.setPrincipal(principalId); - } else { - // covered by the last assertion + if( tenant == null || principal == null ) { + assertThatThrownBy(() -> sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) + .describedAs( + "Without a tenant and principal http clients should not be cached for user based destinations") + .isInstanceOf(HttpClientInstantiationException.class); continue; } @@ -230,7 +213,10 @@ void testGetClientUsesTenantAndPrincipalOptionalForIsolation() // caching works: Requesting a second client with the same parameters yields the exact same instance assertThat(clientWithDestination) - .describedAs("Cache should hit for tenantId: %s, principalId: %s", tenantId, principalId) + .describedAs( + "Cache should hit for tenantId: %s, principalId: %s", + tenant.getTenantId(), + principal.getPrincipalId()) .isSameAs(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()); // isolation works: None of the previously created clients is the same instance @@ -248,10 +234,6 @@ void testGetClientUsesTenantAndPrincipalOptionalForIsolation() clients.add(clientWithoutDestination); } - context.clearPrincipal(); - assertThat(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()) - .describedAs("Without a principal http clients should not be cached for user based destinations") - .isNotSameAs(sut.tryGetHttpClient(USER_TOKEN_EXCHANGE_DESTINATION, FACTORY).get()); } } @@ -418,6 +400,7 @@ void testGetClientReturnsSameClientForDestinationsWithOnlyDifferentHeaderProvide @Test void testPrincipalPropagationIsPrincipalIsolated() { + context.setTenant(); final DefaultHttpDestination destination = DefaultHttpDestination .builder("foo.com") @@ -434,9 +417,8 @@ void testPrincipalPropagationIsPrincipalIsolated() .isSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); context.clearPrincipal(); - assertThat(client).isNotSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); - assertThat(sut.tryGetHttpClient(destination, FACTORY).get()) + assertThatThrownBy(() -> sut.tryGetHttpClient(destination, FACTORY).get()) .describedAs("Without a principal http clients should not be cached for user based destinations") - .isNotSameAs(sut.tryGetHttpClient(destination, FACTORY).get()); + .isInstanceOf(HttpClientInstantiationException.class); } } diff --git a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5FactoryTest.java b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5FactoryTest.java index 1da40e779..e4a14b99a 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5FactoryTest.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultApacheHttpClient5FactoryTest.java @@ -9,6 +9,7 @@ import static com.github.tomakehurst.wiremock.client.WireMock.ok; import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.TlsUpgrade.AUTOMATIC; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; @@ -87,7 +88,8 @@ void setup() CLIENT_TIMEOUT, MAX_CONNECTIONS, MAX_CONNECTIONS_PER_ROUTE, - requestInterceptor); + requestInterceptor, + AUTOMATIC); } @Test @@ -101,14 +103,16 @@ void testHttpClientUsesTimeout() Duration.ofSeconds(3L), MAX_CONNECTIONS, MAX_CONNECTIONS_PER_ROUTE, - requestInterceptor); + requestInterceptor, + AUTOMATIC); final ApacheHttpClient5Factory factoryWithEnoughTimeout = new DefaultApacheHttpClient5Factory( Duration.ofSeconds(7L), MAX_CONNECTIONS, MAX_CONNECTIONS_PER_ROUTE, - requestInterceptor); + requestInterceptor, + AUTOMATIC); final ClassicHttpRequest request = new HttpGet(WIRE_MOCK_SERVER.url("/timeout")); @@ -136,7 +140,8 @@ void testHttpClientUsesMaxConnections() Duration.ofSeconds(3L), // this timeout is also used for the connection lease 1, MAX_CONNECTIONS_PER_ROUTE, - requestInterceptor); + requestInterceptor, + AUTOMATIC); final HttpClient client = sut.createHttpClient(); final ClassicHttpRequest firstRequest = new HttpGet(WIRE_MOCK_SERVER.url("/max-connections-1")); @@ -158,7 +163,8 @@ void testHttpClientUsesMaxConnectionsPerRoute() Duration.ofSeconds(3L), // this timeout is also used for the connection lease MAX_CONNECTIONS, 1, - requestInterceptor); + requestInterceptor, + AUTOMATIC); final ClassicHttpRequest firstRequest = new HttpGet(WIRE_MOCK_SERVER.url("/max-connections-per-route")); final ClassicHttpRequest secondRequest = new HttpGet(SECOND_WIRE_MOCK_SERVER.url("/max-connections-per-route")); diff --git a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientWrapperTest.java b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientWrapperTest.java index 3c667101d..154a584f4 100644 --- a/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientWrapperTest.java +++ b/cloudplatform/connectivity-apache-httpclient5/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/HttpClientWrapperTest.java @@ -6,6 +6,7 @@ import java.util.List; +import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.junit.jupiter.api.Test; @@ -21,7 +22,7 @@ void testDestinationWrapping() DefaultHttpDestination.builder("http://foo.com").headerProviders(c -> List.of()).build(); final DefaultHttpDestination thirdDestination = DefaultHttpDestination.builder("http://bar.com").build(); final ApacheHttpClient5Wrapper sut = - new ApacheHttpClient5Wrapper(mock(CloseableHttpClient.class), firstDestination); + new ApacheHttpClient5Wrapper(mock(CloseableHttpClient.class), firstDestination, mock(RequestConfig.class)); assertThat(sut.withDestination(firstDestination)).isSameAs(sut); assertThat(sut.withDestination(firstDestination)).isNotSameAs(sut.withDestination(secondDestination)); diff --git a/cloudplatform/connectivity-destination-service/pom.xml b/cloudplatform/connectivity-destination-service/pom.xml index 8c57131e4..f98b034c8 100644 --- a/cloudplatform/connectivity-destination-service/pom.xml +++ b/cloudplatform/connectivity-destination-service/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT connectivity-destination-service Cloud Platform - Connectivity SAP BTP Cloud Foundry diff --git a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java index aa2277636..81eb8e53c 100644 --- a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java +++ b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java @@ -22,7 +22,6 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import com.github.benmanes.caffeine.cache.Caffeine; -import com.google.common.annotations.Beta; import com.google.common.collect.Streams; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -389,7 +388,6 @@ private static boolean hasCauseAssignableFrom( @Nonnull final Throwable t, @Nonn * @since 4.3.0 */ @Slf4j - @Beta public static final class Cache { /** @@ -657,7 +655,6 @@ public static void disableExpiration() * * @since 4.7.0 */ - @Beta @Deprecated public static void enableChangeDetection() { @@ -696,7 +693,6 @@ Therefore, the default expiration ({}{}) will be restored.\ * * @since 5.2.0 */ - @Beta public static void disableChangeDetection() { throwIfDisabled(); @@ -905,7 +901,6 @@ private static void throwIfDisabled() * @return A builder to prepare a customised instance. * @since 4.4.0 */ - @Beta @Nonnull public static Builder builder() { @@ -917,7 +912,6 @@ public static Builder builder() * * @since 4.4.0 */ - @Beta @NoArgsConstructor( access = AccessLevel.PRIVATE ) public static final class Builder { diff --git a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceOptionsAugmenter.java b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceOptionsAugmenter.java index e894c5353..86e5a576c 100644 --- a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceOptionsAugmenter.java +++ b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceOptionsAugmenter.java @@ -8,8 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import io.vavr.control.Option; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -79,7 +77,6 @@ public DestinationServiceOptionsAugmenter tokenExchangeStrategy( * @return The same augmenter that called this method. * @since 5.9.0 */ - @Beta @Nonnull public DestinationServiceOptionsAugmenter refreshToken( @Nonnull final String refreshToken ) { @@ -95,7 +92,6 @@ public DestinationServiceOptionsAugmenter refreshToken( @Nonnull final String re * @return The same augmenter that called this method. * @since 5.11.0 */ - @Beta @Nonnull public DestinationServiceOptionsAugmenter fragmentName( @Nonnull final String fragmentName ) { diff --git a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceV1Response.java b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceV1Response.java index 008df381a..5292ea110 100644 --- a/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceV1Response.java +++ b/cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceV1Response.java @@ -11,7 +11,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.google.common.collect.Maps; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; @@ -30,7 +29,6 @@ * Serializable and deserializable response type for SCP CF Destination Service queries. */ @Data -@Beta public class DestinationServiceV1Response { @SerializedName( "owner" ) diff --git a/cloudplatform/connectivity-dwc/pom.xml b/cloudplatform/connectivity-dwc/pom.xml index 9e98690ba..99bb68d30 100644 --- a/cloudplatform/connectivity-dwc/pom.xml +++ b/cloudplatform/connectivity-dwc/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT connectivity-dwc Deploy with Confidence Connectivity diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/DwcHeaderUtils.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/DwcHeaderUtils.java index e1c63a94b..8a3209c17 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/DwcHeaderUtils.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/DwcHeaderUtils.java @@ -9,7 +9,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.google.common.base.Strings; import com.google.gson.Gson; import com.sap.cloud.sdk.cloudplatform.exception.DwcHeaderNotFoundException; @@ -22,7 +21,6 @@ /** * Utility class to extract specific values from the SAP Deploy with Confidence request headers. */ -@Beta public class DwcHeaderUtils { /** diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBinding.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBinding.java index e7530891a..ceab122f1 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBinding.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBinding.java @@ -12,7 +12,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; import com.sap.cloud.sdk.cloudplatform.exception.CloudPlatformException; @@ -54,7 +53,6 @@ * @see MegacliteServiceBindingAccessor#registerServiceBinding(MegacliteServiceBinding) * @since 4.17.0 */ -@Beta @Getter( AccessLevel.PACKAGE ) @RequiredArgsConstructor( access = AccessLevel.PRIVATE ) @EqualsAndHashCode diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingAccessor.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingAccessor.java index 38a769f2c..c85a3718e 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingAccessor.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingAccessor.java @@ -11,7 +11,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.environment.servicebinding.api.ServiceBindingAccessor; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; @@ -30,7 +29,6 @@ * * @since 4.17.0 */ -@Beta @Slf4j public class MegacliteServiceBindingAccessor implements ServiceBindingAccessor { diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingDestinationLoader.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingDestinationLoader.java index bd7d5353d..57b402177 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingDestinationLoader.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/MegacliteServiceBindingDestinationLoader.java @@ -7,7 +7,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; import com.sap.cloud.sdk.cloudplatform.connectivity.ServiceBindingDestinationOptions.Options; @@ -29,7 +28,6 @@ * @see MegacliteServiceBindingAccessor * @since 4.17.0 */ -@Beta @Slf4j public final class MegacliteServiceBindingDestinationLoader implements ServiceBindingDestinationLoader { @@ -147,8 +145,8 @@ MegacliteServiceBinding.MandateConfiguration getMandateConfigurationOrThrow( private MegacliteServiceBinding getBindingOrThrow( @Nonnull final ServiceBindingDestinationOptions options ) { final ServiceBinding serviceBinding = options.getServiceBinding(); - if( serviceBinding instanceof MegacliteServiceBinding ) { - return (MegacliteServiceBinding) serviceBinding; + if( serviceBinding instanceof MegacliteServiceBinding megacliteServiceBinding ) { + return megacliteServiceBinding; } final String msg = "Unable to transform the provided service binding for service '%s' into a Megaclite based destination. Expected the service binding to be of type '%s' but got a '%s' instead."; diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/DwcHeaderNotFoundException.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/DwcHeaderNotFoundException.java index f06980aa8..a3dcfc6e9 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/DwcHeaderNotFoundException.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/exception/DwcHeaderNotFoundException.java @@ -5,12 +5,9 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * Represents an {@link Throwable} that is thrown if a specific Deploy with Confidence header was not found. */ -@Beta public class DwcHeaderNotFoundException extends RuntimeException { private static final long serialVersionUID = 1089454219933367075L; diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/security/DwcPrincipalFacade.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/security/DwcPrincipalFacade.java index 8b72f6920..022b64473 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/security/DwcPrincipalFacade.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/security/DwcPrincipalFacade.java @@ -6,7 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.DwcHeaderUtils; import com.sap.cloud.sdk.cloudplatform.security.principal.DefaultPrincipal; import com.sap.cloud.sdk.cloudplatform.security.principal.DefaultPrincipalFacade; @@ -22,7 +21,6 @@ * Represents a specific {@link DefaultPrincipalFacade} that is used when running on the SAP Deploy with Confidence * stack. */ -@Beta public class DwcPrincipalFacade extends DefaultPrincipalFacade { private static final String PRINCIPAL = PrincipalThreadContextListener.PROPERTY_PRINCIPAL; diff --git a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/tenant/DwcTenantFacade.java b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/tenant/DwcTenantFacade.java index d320dacad..baf895bdf 100644 --- a/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/tenant/DwcTenantFacade.java +++ b/cloudplatform/connectivity-dwc/src/main/java/com/sap/cloud/sdk/cloudplatform/tenant/DwcTenantFacade.java @@ -6,7 +6,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.DwcHeaderUtils; import com.sap.cloud.sdk.cloudplatform.tenant.exception.TenantAccessException; import com.sap.cloud.sdk.cloudplatform.thread.ThreadContext; @@ -17,7 +16,6 @@ /** * Represents a specific {@link DefaultTenantFacade} that is used when running on the SAP Deploy with Confidence stack. */ -@Beta public class DwcTenantFacade extends DefaultTenantFacade { private static final String TENANT = TenantThreadContextListener.PROPERTY_TENANT; diff --git a/cloudplatform/connectivity-oauth/pom.xml b/cloudplatform/connectivity-oauth/pom.xml index d2b7a6469..3d43d9952 100644 --- a/cloudplatform/connectivity-oauth/pom.xml +++ b/cloudplatform/connectivity-oauth/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT connectivity-oauth OAuth2 Connectivity @@ -108,10 +108,6 @@ jcl-over-slf4j runtime - - com.google.guava - guava - com.auth0 java-jwt @@ -196,6 +192,11 @@ testutil test + + com.google.guava + guava + test + diff --git a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultOAuth2PropertySupplier.java b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultOAuth2PropertySupplier.java index c9e3f6bde..70ed68a5a 100644 --- a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultOAuth2PropertySupplier.java +++ b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultOAuth2PropertySupplier.java @@ -15,7 +15,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.TypedMapView; import com.sap.cloud.sdk.cloudplatform.connectivity.SecurityLibWorkarounds.ZtisClientIdentity; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; @@ -37,7 +36,6 @@ * * @since 4.20.0 */ -@Beta @Slf4j public class DefaultOAuth2PropertySupplier implements OAuth2PropertySupplier { diff --git a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/IdentityAuthenticationServiceBindingDestinationLoader.java b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/IdentityAuthenticationServiceBindingDestinationLoader.java index d3fe8771b..17b99d2d1 100644 --- a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/IdentityAuthenticationServiceBindingDestinationLoader.java +++ b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/IdentityAuthenticationServiceBindingDestinationLoader.java @@ -7,7 +7,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; import com.sap.cloud.environment.servicebinding.api.TypedMapView; @@ -25,7 +24,6 @@ * * @since 5.6.0 */ -@Beta @Slf4j public class IdentityAuthenticationServiceBindingDestinationLoader implements ServiceBindingDestinationLoader { diff --git a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2DestinationBuilder.java b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2DestinationBuilder.java index 07f3b5bc7..4a8cab31a 100644 --- a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2DestinationBuilder.java +++ b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2DestinationBuilder.java @@ -8,7 +8,6 @@ import org.apache.http.HttpHeaders; -import com.google.common.annotations.Beta; import com.sap.cloud.security.config.ClientIdentity; import lombok.extern.slf4j.Slf4j; @@ -20,7 +19,6 @@ * @since 4.10.0 */ @Slf4j -@Beta public class OAuth2DestinationBuilder { /** @@ -29,7 +27,6 @@ public class OAuth2DestinationBuilder * @since 4.10.0 */ @FunctionalInterface - @Beta public interface BuilderWithTargetUrl { /** @@ -50,7 +47,6 @@ public interface BuilderWithTargetUrl * @since 4.10.0 */ @FunctionalInterface - @Beta public interface BuilderWithTokenEndpoint { /** diff --git a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2Options.java b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2Options.java index 1d31b45db..494fe0c02 100644 --- a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2Options.java +++ b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2Options.java @@ -8,7 +8,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.cloudplatform.connectivity.ServiceBindingDestinationOptions.OptionsEnhancer; import com.sap.cloud.sdk.cloudplatform.resilience.ResilienceConfiguration.TimeLimiterConfiguration; @@ -24,7 +23,6 @@ * * @since 5.5.0 */ -@Beta @AllArgsConstructor( access = AccessLevel.PRIVATE ) @EqualsAndHashCode public final class OAuth2Options @@ -96,7 +94,6 @@ public static Builder builder() /** * A builder implementation that helps with creating customized {@link OAuth2Options} instances. */ - @Beta @Slf4j public static class Builder { diff --git a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2PropertySupplier.java b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2PropertySupplier.java index 06f53693a..1b0ed2875 100644 --- a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2PropertySupplier.java +++ b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2PropertySupplier.java @@ -8,7 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.security.config.ClientIdentity; /** @@ -17,7 +16,6 @@ * * @since 4.20.0 */ -@Beta public interface OAuth2PropertySupplier { /** diff --git a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2ServiceBindingDestinationLoader.java b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2ServiceBindingDestinationLoader.java index 80e2a249a..ed40f6f9e 100644 --- a/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2ServiceBindingDestinationLoader.java +++ b/cloudplatform/connectivity-oauth/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/OAuth2ServiceBindingDestinationLoader.java @@ -14,7 +14,6 @@ import org.apache.http.HttpHeaders; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; import com.sap.cloud.sdk.cloudplatform.connectivity.ServiceBindingDestinationOptions.Options; import com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException; @@ -34,7 +33,6 @@ * @since 4.16.0 */ @Slf4j -@Beta public class OAuth2ServiceBindingDestinationLoader implements ServiceBindingDestinationLoader { @Nonnull diff --git a/cloudplatform/connectivity-ztis/pom.xml b/cloudplatform/connectivity-ztis/pom.xml index 40353f64e..c4808a514 100644 --- a/cloudplatform/connectivity-ztis/pom.xml +++ b/cloudplatform/connectivity-ztis/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT connectivity-ztis Connectivity - Zero Trust Identity Service @@ -47,7 +47,7 @@ io.grpc grpc-bom - 1.66.0 + 1.68.2 pom import @@ -73,7 +73,7 @@ io.spiffe java-spiffe-core - 0.8.6 + 0.8.11 commons-logging @@ -84,7 +84,7 @@ io.spiffe grpc-netty-linux - 0.8.6 + 0.8.11 runtime @@ -111,10 +111,6 @@ org.slf4j slf4j-api - - com.google.guava - guava - org.projectlombok lombok diff --git a/cloudplatform/connectivity-ztis/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ZeroTrustIdentityService.java b/cloudplatform/connectivity-ztis/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ZeroTrustIdentityService.java index 62ae7c6d0..3bc8da548 100644 --- a/cloudplatform/connectivity-ztis/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ZeroTrustIdentityService.java +++ b/cloudplatform/connectivity-ztis/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/ZeroTrustIdentityService.java @@ -14,7 +14,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.environment.servicebinding.api.DefaultServiceBindingAccessor; import com.sap.cloud.environment.servicebinding.api.ServiceBinding; import com.sap.cloud.environment.servicebinding.api.ServiceIdentifier; @@ -42,7 +41,6 @@ * * @since 5.7.0 */ -@Beta @Slf4j @RequiredArgsConstructor( access = AccessLevel.PRIVATE ) public class ZeroTrustIdentityService diff --git a/cloudplatform/dwc-cf/pom.xml b/cloudplatform/dwc-cf/pom.xml index 1eb472c0b..6666119e6 100644 --- a/cloudplatform/dwc-cf/pom.xml +++ b/cloudplatform/dwc-cf/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT dwc-cf (Deprecated) Cloud Platform - SAP Deploy with Confidence on Cloud Foundry diff --git a/cloudplatform/pom.xml b/cloudplatform/pom.xml index 9a83c4f59..5f7527a7d 100644 --- a/cloudplatform/pom.xml +++ b/cloudplatform/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT com.sap.cloud.sdk.cloudplatform cloudplatform-parent diff --git a/cloudplatform/resilience-api/pom.xml b/cloudplatform/resilience-api/pom.xml index dc514a494..73a63412c 100644 --- a/cloudplatform/resilience-api/pom.xml +++ b/cloudplatform/resilience-api/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT resilience-api Cloud Platform - Resilience API diff --git a/cloudplatform/resilience/pom.xml b/cloudplatform/resilience/pom.xml index 1a4b9a49a..be1a875e4 100644 --- a/cloudplatform/resilience/pom.xml +++ b/cloudplatform/resilience/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT resilience Cloud Platform - Resilience API and Default Implementation diff --git a/cloudplatform/resilience4j/pom.xml b/cloudplatform/resilience4j/pom.xml index ba88c996e..94e918ea1 100644 --- a/cloudplatform/resilience4j/pom.xml +++ b/cloudplatform/resilience4j/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT resilience4j Cloud Platform - Resilience4j diff --git a/cloudplatform/scp-cf/pom.xml b/cloudplatform/scp-cf/pom.xml index d3ad73e08..73599b24c 100644 --- a/cloudplatform/scp-cf/pom.xml +++ b/cloudplatform/scp-cf/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT scp-cf (Deprecated) Business Technology Platform - SAP BTP Cloud Foundry diff --git a/cloudplatform/security/pom.xml b/cloudplatform/security/pom.xml index f30c50c96..5fa43d7d8 100644 --- a/cloudplatform/security/pom.xml +++ b/cloudplatform/security/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT security Business Technology Platform - Security diff --git a/cloudplatform/servlet-jakarta/pom.xml b/cloudplatform/servlet-jakarta/pom.xml index 22f996bbb..298087743 100644 --- a/cloudplatform/servlet-jakarta/pom.xml +++ b/cloudplatform/servlet-jakarta/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT servlet-jakarta Cloud Platform - Servlet Jakarta compatible diff --git a/cloudplatform/tenant/pom.xml b/cloudplatform/tenant/pom.xml index 02eb63023..b42ef910e 100644 --- a/cloudplatform/tenant/pom.xml +++ b/cloudplatform/tenant/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.cloudplatform cloudplatform-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT tenant Cloud Platform - Tenant diff --git a/datamodel/datamodel-metadata-generator/pom.xml b/datamodel/datamodel-metadata-generator/pom.xml index bedc644d2..7e71e059b 100644 --- a/datamodel/datamodel-metadata-generator/pom.xml +++ b/datamodel/datamodel-metadata-generator/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT datamodel-metadata-generator Data Model - Metadata Generator (Beta) diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ApiUsageMetadata.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ApiUsageMetadata.java index 8a01a7186..6a1de87ea 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ApiUsageMetadata.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ApiUsageMetadata.java @@ -11,14 +11,11 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.Value; /** * Metadata about API usage. */ -@Beta public interface ApiUsageMetadata { /** diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataGenerator.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataGenerator.java index 60c7ac538..fa1111e70 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataGenerator.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataGenerator.java @@ -14,7 +14,6 @@ import org.apache.commons.io.FilenameUtils; -import com.google.common.annotations.Beta; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -24,7 +23,6 @@ * Generates metadata about the Virtual Data Model. */ @Slf4j -@Beta public class DatamodelMetadataGenerator { private static final String METADATA_GENERATOR_INPUT_FILENAME = "metadata-generator-properties.json"; diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataInput.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataInput.java index d36e3e0f8..239850ff6 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataInput.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/DatamodelMetadataInput.java @@ -10,8 +10,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.Builder; import lombok.Value; @@ -20,7 +18,6 @@ */ @Value @Builder -@Beta public class DatamodelMetadataInput { boolean codeGenerationSuccessful; diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenCoordinate.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenCoordinate.java index 7fd6a7c04..01b762814 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenCoordinate.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenCoordinate.java @@ -6,8 +6,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.Builder; import lombok.Value; @@ -16,7 +14,6 @@ */ @Value @Builder -@Beta public class MavenCoordinate { @Nonnull diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenRepositoryAccessor.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenRepositoryAccessor.java index 3bfdb294b..0fa212914 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenRepositoryAccessor.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MavenRepositoryAccessor.java @@ -6,11 +6,8 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import io.vavr.control.Try; -@Beta interface MavenRepositoryAccessor { /** diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MetadataGenerationException.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MetadataGenerationException.java index 659b8d985..57aa1e9ab 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MetadataGenerationException.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/MetadataGenerationException.java @@ -4,12 +4,9 @@ package com.sap.cloud.sdk.datamodel.metadata.generator; -import com.google.common.annotations.Beta; - /** * Indicates an error during VDM metadata generation. */ -@Beta public class MetadataGenerationException extends RuntimeException { private static final long serialVersionUID = -199677362491505868L; diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ODataApiUsageMetadata.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ODataApiUsageMetadata.java index c22909601..9d01f8170 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ODataApiUsageMetadata.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ODataApiUsageMetadata.java @@ -8,8 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.Builder; import lombok.Singular; import lombok.Value; @@ -18,7 +16,6 @@ * Metadata about OData API usage. */ @Value -@Beta @Builder public class ODataApiUsageMetadata implements ApiUsageMetadata { diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ProtocolSpecificMetadata.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ProtocolSpecificMetadata.java index f04e62ed3..f20f317ac 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ProtocolSpecificMetadata.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ProtocolSpecificMetadata.java @@ -7,8 +7,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; - import lombok.AccessLevel; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -18,7 +16,6 @@ */ @RequiredArgsConstructor( access = AccessLevel.PRIVATE ) @Getter -@Beta public final class ProtocolSpecificMetadata { @Nonnull diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/RestApiUsageMetadata.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/RestApiUsageMetadata.java index d8cfa2fc9..5e70e678d 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/RestApiUsageMetadata.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/RestApiUsageMetadata.java @@ -8,8 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.Builder; import lombok.Singular; import lombok.Value; @@ -19,7 +17,6 @@ */ @Value @Builder -@Beta public class RestApiUsageMetadata implements ApiUsageMetadata { @Nonnull diff --git a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ServiceType.java b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ServiceType.java index 6da75b0c9..db93e6b64 100644 --- a/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ServiceType.java +++ b/datamodel/datamodel-metadata-generator/src/main/java/com/sap/cloud/sdk/datamodel/metadata/generator/ServiceType.java @@ -4,12 +4,9 @@ package com.sap.cloud.sdk.datamodel.metadata.generator; -import com.google.common.annotations.Beta; - /** * The Service Type denotes the protocol of the service, like OData V2, OData V4, REST or SOAP. */ -@Beta public enum ServiceType { /** diff --git a/datamodel/fluent-result/pom.xml b/datamodel/fluent-result/pom.xml index 0957087a6..eddf659fb 100644 --- a/datamodel/fluent-result/pom.xml +++ b/datamodel/fluent-result/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT fluent-result Data Model - Fluent Result diff --git a/datamodel/odata-client/pom.xml b/datamodel/odata-client/pom.xml index c1dca27e1..7a941c133 100644 --- a/datamodel/odata-client/pom.xml +++ b/datamodel/odata-client/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-client jar diff --git a/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/ODataRequestResultMultipartGeneric.java b/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/ODataRequestResultMultipartGeneric.java index 8e18cfccb..444bef5fe 100644 --- a/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/ODataRequestResultMultipartGeneric.java +++ b/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/ODataRequestResultMultipartGeneric.java @@ -14,7 +14,6 @@ import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.client.exception.ODataDeserializationException; import com.sap.cloud.sdk.datamodel.odata.client.exception.ODataResponseException; import com.sap.cloud.sdk.datamodel.odata.client.exception.ODataServiceErrorException; @@ -164,7 +163,6 @@ private Try>> loadBatchResponses() * * @since 5.5.0 */ - @Beta @Override public void close() { diff --git a/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/UriEncodingStrategy.java b/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/UriEncodingStrategy.java index 3d0ffc257..99151977f 100644 --- a/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/UriEncodingStrategy.java +++ b/datamodel/odata-client/src/main/java/com/sap/cloud/sdk/datamodel/odata/client/request/UriEncodingStrategy.java @@ -3,7 +3,6 @@ */ package com.sap.cloud.sdk.datamodel.odata.client.request; -import com.google.common.annotations.Beta; import com.google.common.escape.Escaper; import com.google.common.escape.Escapers; import com.google.common.net.PercentEscaper; @@ -15,7 +14,6 @@ /** * Encoding strategy. */ -@Beta @RequiredArgsConstructor public enum UriEncodingStrategy { diff --git a/datamodel/odata-generator-utility/pom.xml b/datamodel/odata-generator-utility/pom.xml index 37bf1b244..92360a78e 100644 --- a/datamodel/odata-generator-utility/pom.xml +++ b/datamodel/odata-generator-utility/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-generator-utility OData Utility diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/AbstractNamingStrategy.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/AbstractNamingStrategy.java index a14d57750..c895256e3 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/AbstractNamingStrategy.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/AbstractNamingStrategy.java @@ -14,7 +14,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.annotations.Beta; import com.google.common.base.CaseFormat; import lombok.AllArgsConstructor; @@ -26,7 +25,6 @@ * Represents an abstract base implementation of the {@link NamingStrategy}. It provides convenience methods (such as * {@link AbstractNamingStrategy#convertToJavaClassName(String, String)}) for inheritors to leverage. */ -@Beta @AllArgsConstructor @NoArgsConstructor public abstract class AbstractNamingStrategy implements NamingStrategy diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/EdmxValidator.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/EdmxValidator.java index d403c48d3..67325e889 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/EdmxValidator.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/EdmxValidator.java @@ -18,8 +18,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.annotations.Beta; - import lombok.AccessLevel; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -30,7 +28,6 @@ */ @Slf4j @NoArgsConstructor( access = AccessLevel.PRIVATE ) // utility class -@Beta public class EdmxValidator { diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/LegacyClassScanner.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/LegacyClassScanner.java index 20d92fb65..f44bf3ded 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/LegacyClassScanner.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/LegacyClassScanner.java @@ -19,7 +19,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -42,7 +41,6 @@ @Slf4j @AllArgsConstructor @NoArgsConstructor( access = AccessLevel.PRIVATE ) -@Beta public class LegacyClassScanner { @Nullable diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NameSource.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NameSource.java index c7a405728..b19156128 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NameSource.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NameSource.java @@ -4,13 +4,10 @@ package com.sap.cloud.sdk.datamodel.odata.utility; -import com.google.common.annotations.Beta; - /** * An enum representing the logic to be used by the {@code NamingStrategy} for determining the source for the java * namings. */ -@Beta public enum NameSource { /** diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingStrategy.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingStrategy.java index 0227a1b7d..d760d9b2b 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingStrategy.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingStrategy.java @@ -7,12 +7,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; - /** * Represents a strategy for generating various types of Java names from OData entity/property names and labels. */ -@Beta public interface NamingStrategy { /** diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingUtils.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingUtils.java index 40d2d34ca..d2245886b 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingUtils.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/NamingUtils.java @@ -14,13 +14,11 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.annotations.Beta; import com.google.common.base.CaseFormat; /** * Utility class, that bundles various naming related operations. This class is meant for internal usage only. */ -@Beta public final class NamingUtils { private static final String FLUENT_HELPER_SUFFIX = "FluentHelper"; diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/S4HanaNamingStrategy.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/S4HanaNamingStrategy.java index a7d537fe1..68b844854 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/S4HanaNamingStrategy.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/S4HanaNamingStrategy.java @@ -11,7 +11,6 @@ import org.apache.commons.lang3.StringUtils; -import com.google.common.annotations.Beta; import com.google.common.base.CaseFormat; import com.google.common.collect.ImmutableList; @@ -21,7 +20,6 @@ * Represents a {@link NamingStrategy}, which removes pre- and suffixes from the generated Java identifiers that are * typically used in S4Hana service definitions. */ -@Beta @NoArgsConstructor public final class S4HanaNamingStrategy extends AbstractNamingStrategy { diff --git a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/SimpleNamingStrategy.java b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/SimpleNamingStrategy.java index e731c8bb7..85959fb46 100644 --- a/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/SimpleNamingStrategy.java +++ b/datamodel/odata-generator-utility/src/main/java/com/sap/cloud/sdk/datamodel/odata/utility/SimpleNamingStrategy.java @@ -6,15 +6,12 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.NoArgsConstructor; /** * Represents the default {@link NamingStrategy} implementation, which generates syntactically correct Java names * without doing any additional modifications. */ -@Beta @NoArgsConstructor public class SimpleNamingStrategy extends AbstractNamingStrategy { diff --git a/datamodel/odata-v4/odata-v4-api-sample/pom.xml b/datamodel/odata-v4/odata-v4-api-sample/pom.xml index ee8c350d0..894b17ad4 100644 --- a/datamodel/odata-v4/odata-v4-api-sample/pom.xml +++ b/datamodel/odata-v4/odata-v4-api-sample/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-v4-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-v4-api-sample OData V4 VDM - Sample API diff --git a/datamodel/odata-v4/odata-v4-core/pom.xml b/datamodel/odata-v4/odata-v4-core/pom.xml index fca214318..18e475701 100644 --- a/datamodel/odata-v4/odata-v4-core/pom.xml +++ b/datamodel/odata-v4/odata-v4-core/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-v4-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-v4-core jar diff --git a/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/BatchResponse.java b/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/BatchResponse.java index ec5caa5ab..2446d2160 100644 --- a/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/BatchResponse.java +++ b/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/core/BatchResponse.java @@ -9,7 +9,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.client.exception.ODataResponseException; import com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestGeneric; import com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric; @@ -265,7 +264,6 @@ public ActionResponseCollection getModificationResult( * * @since 4.15.0 */ - @Beta @Override public void close() { diff --git a/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/expression/FilterableBoolean.java b/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/expression/FilterableBoolean.java index 323486977..caf209fbe 100644 --- a/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/expression/FilterableBoolean.java +++ b/datamodel/odata-v4/odata-v4-core/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/expression/FilterableBoolean.java @@ -6,7 +6,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.client.expression.Expressions; import com.sap.cloud.sdk.datamodel.odata.client.expression.FilterExpression; import com.sap.cloud.sdk.datamodel.odata.client.expression.FilterExpressionLogical; @@ -55,7 +54,6 @@ class Expression implements FilterableBoolean, FilterExpressio * * @since 4.8.0 */ - @Beta @Nonnull static FilterableBoolean fromCustomFilter( @Nonnull final ValueBoolean delegateExpression, diff --git a/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml b/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml index 5ee9d5c94..ca7668b47 100644 --- a/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml +++ b/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-v4-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-v4-generator-maven-plugin maven-plugin @@ -95,10 +95,6 @@ maven-compat test - - com.google.guava - guava - diff --git a/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojo.java b/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojo.java index 14d908301..f2023deae 100644 --- a/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojo.java +++ b/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojo.java @@ -13,7 +13,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.utility.NameSource; import com.sap.cloud.sdk.datamodel.odata.utility.NamingStrategy; import com.sap.cloud.sdk.datamodel.odata.utility.S4HanaNamingStrategy; @@ -21,7 +20,6 @@ /** * Mojo used in the OData V4 Generator Maven Plugin. */ -@Beta @Mojo( name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresProject = false ) public class DataModelGeneratorMojo extends AbstractMojo { diff --git a/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml b/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml index a3cbcbd7e..2d6e7bd5a 100644 --- a/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml +++ b/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/odata-v4/odata-v4-generator/pom.xml b/datamodel/odata-v4/odata-v4-generator/pom.xml index 100d1e899..853e032a1 100644 --- a/datamodel/odata-v4/odata-v4-generator/pom.xml +++ b/datamodel/odata-v4/odata-v4-generator/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-v4-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-v4-generator jar diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGenerator.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGenerator.java index 16c80a4cf..d3a6d2402 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGenerator.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGenerator.java @@ -13,7 +13,6 @@ import org.slf4j.Logger; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.utility.NameSource; import com.sap.cloud.sdk.datamodel.odata.utility.NamingStrategy; import com.sap.cloud.sdk.datamodel.odata.utility.S4HanaNamingStrategy; @@ -25,7 +24,6 @@ * Builder for the {@code ODataToVdmGenerator}, gathering all relevant parameter or providing default values for * unspecified ones. */ -@Beta @Getter public class DataModelGenerator implements DataModelGeneratorConfig { diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DefaultNameFormattingStrategy.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DefaultNameFormattingStrategy.java index 6236c83b3..600e713b5 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DefaultNameFormattingStrategy.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DefaultNameFormattingStrategy.java @@ -6,13 +6,10 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * NameFormattingStrategy used by default in the {@link NamingContext}. This strategy does nothing, i.e. simply returns * the input. */ -@Beta public class DefaultNameFormattingStrategy implements NameFormattingStrategy { @Nonnull diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/EdmUtils.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/EdmUtils.java index 9b9367fd0..d9df4978e 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/EdmUtils.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/EdmUtils.java @@ -20,17 +20,12 @@ static Multiplicity convertMultiplicity( final EdmTyped edmTyped ) static TypeKind convertTypeKind( final EdmTypeKind typeKind ) { - switch( typeKind ) { - case PRIMITIVE: - return TypeKind.PRIMITIVE; - case COMPLEX: - return TypeKind.COMPLEX; - case ENTITY: - return TypeKind.ENTITY; - case ENUM: - return TypeKind.ENUM; - default: - throw new ODataGeneratorException("Encountered unknown type kind: " + typeKind); - } + return switch( typeKind ) { + case PRIMITIVE, DEFINITION -> TypeKind.PRIMITIVE; + case COMPLEX -> TypeKind.COMPLEX; + case ENTITY -> TypeKind.ENTITY; + case ENUM -> TypeKind.ENUM; + default -> throw new ODataGeneratorException("Encountered unknown type kind: " + typeKind); + }; } } diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/LowercaseNameFormattingStrategy.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/LowercaseNameFormattingStrategy.java index 3a2eee57c..1ea3e2c24 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/LowercaseNameFormattingStrategy.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/LowercaseNameFormattingStrategy.java @@ -8,12 +8,9 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * The NameFormattingStrategy used when processing an entity's properties. Used in {@link NamingContext}. */ -@Beta public class LowercaseNameFormattingStrategy implements NameFormattingStrategy { @Nonnull diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/MessageCollector.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/MessageCollector.java index 08413602f..4acb7576b 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/MessageCollector.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/MessageCollector.java @@ -20,12 +20,9 @@ import org.slf4j.Marker; import org.slf4j.helpers.MessageFormatter; -import com.google.common.annotations.Beta; - /** * Wrapper for the {@code LoggerFactory}, collecting all logged messages. */ -@Beta public class MessageCollector { /** diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/NameFormattingStrategy.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/NameFormattingStrategy.java index 28f715169..c3c53d0cb 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/NameFormattingStrategy.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/NameFormattingStrategy.java @@ -6,13 +6,10 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * NameFormattingStrategy that can be used in the {@link NamingContext} in the OData VDM generator. Implement this * interface to create a custom NameFormattingStrategy and set in the NamingContext's constructor. */ -@Beta public interface NameFormattingStrategy { /** diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/ODataGeneratorException.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/ODataGeneratorException.java index 097eaf062..77b192296 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/ODataGeneratorException.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/ODataGeneratorException.java @@ -6,12 +6,9 @@ import javax.annotation.Nullable; -import com.google.common.annotations.Beta; - /** * Custom runtime exception that is thrown in cases of unrecoverable errors. */ -@Beta public class ODataGeneratorException extends RuntimeException { private static final long serialVersionUID = 6937287713485851338L; diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationDefinition.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationDefinition.java index 5799fd752..bb8776d5f 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationDefinition.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationDefinition.java @@ -11,8 +11,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.EqualsAndHashCode; import lombok.Getter; @@ -22,7 +20,6 @@ * generated Java code. */ @EqualsAndHashCode -@Beta public class AnnotationDefinition { @Getter diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationParameter.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationParameter.java index 258eb329f..9b211b104 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationParameter.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationParameter.java @@ -6,8 +6,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - import lombok.Getter; /** @@ -16,7 +14,6 @@ * add parameters to annotations while generating Java code. NOTE: Only primitive types, {@link String}, {@link Enum} * , and {@link Class} are supported. */ -@Beta public class AnnotationParameter { @Getter diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationStrategy.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationStrategy.java index eb8692e32..d73f6275e 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationStrategy.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/AnnotationStrategy.java @@ -8,8 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * Implementations of this interface instruct the VDM generator on which annotations to apply to the generated Java * code. @@ -23,7 +21,6 @@ *
  • Member variables representing OData properties of complex types.
  • * */ -@Beta public interface AnnotationStrategy { /** diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/DefaultAnnotationStrategy.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/DefaultAnnotationStrategy.java index 5351cfaea..27c3f14ec 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/DefaultAnnotationStrategy.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/DefaultAnnotationStrategy.java @@ -17,7 +17,6 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.google.common.annotations.Beta; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import com.sap.cloud.sdk.datamodel.odatav4.adapter.GsonVdmAdapterFactory; @@ -39,7 +38,6 @@ * generated VDM classes (POJOs, fluent helpers, service classes, etc.), which uses the SAP Cloud SDK to access OData * services. */ -@Beta public class DefaultAnnotationStrategy implements AnnotationStrategy { private static final Logger logger = MessageCollector.getLogger(DefaultAnnotationStrategy.class); diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityAnnotationModel.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityAnnotationModel.java index ce895205a..f8f89584b 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityAnnotationModel.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityAnnotationModel.java @@ -6,12 +6,9 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * Data structure representing an OData entity or complex type. */ -@Beta public interface EntityAnnotationModel { /** diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityPropertyAnnotationModel.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityPropertyAnnotationModel.java index b7ce67d95..edbf1835c 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityPropertyAnnotationModel.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/EntityPropertyAnnotationModel.java @@ -7,12 +7,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; - /** * Data structure representing an OData property of an entity or complex type. */ -@Beta public interface EntityPropertyAnnotationModel { /** diff --git a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/NavigationPropertyAnnotationModel.java b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/NavigationPropertyAnnotationModel.java index a8b312840..ebc20683e 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/NavigationPropertyAnnotationModel.java +++ b/datamodel/odata-v4/odata-v4-generator/src/main/java/com/sap/cloud/sdk/datamodel/odatav4/generator/annotation/NavigationPropertyAnnotationModel.java @@ -6,12 +6,9 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; - /** * Data structure representing an OData navigation property. */ -@Beta public interface NavigationPropertyAnnotationModel { /** diff --git a/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/input/actionsAndFunctions.edmx b/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/input/actionsAndFunctions.edmx index ae31a18f8..661fbf33e 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/input/actionsAndFunctions.edmx +++ b/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/input/actionsAndFunctions.edmx @@ -64,6 +64,12 @@ + + + + + + + deleteSimplePerson( @Nonnull SingleValueFunctionRequestBuilder functionWithNewResultType(); + /** + *

    Creates a request builder for the FunctionWithTypeDef OData function.

    + * + * @param functionParameter + * Constraints: Nullable

    Original parameter name from the Odata EDM: FunctionParameter

    + * @return + * A request builder object that will execute the FunctionWithTypeDef OData function with the provided parameters. To perform execution, call the {@link com.sap.cloud.sdk.datamodel.odatav4.core.SingleValueFunctionRequestBuilder#execute execute} method on the request builder object. + */ + @Nonnull + SingleValueFunctionRequestBuilder functionWithTypeDef( + @Nullable + final String functionParameter); + /** *

    Creates a request builder for the NoArgAction OData action.

    * diff --git a/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/output/testcomparison/services/DefaultActionsAndFunctionsService.java b/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/output/testcomparison/services/DefaultActionsAndFunctionsService.java index 475d42717..4ddc5302e 100644 --- a/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/output/testcomparison/services/DefaultActionsAndFunctionsService.java +++ b/datamodel/odata-v4/odata-v4-generator/src/test/resources/oDataGeneratorIntegrationTest/actionsAndFunctionsTest/output/testcomparison/services/DefaultActionsAndFunctionsService.java @@ -5,8 +5,10 @@ package testcomparison.services; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import com.sap.cloud.sdk.datamodel.odatav4.core.BatchRequestBuilder; import com.sap.cloud.sdk.datamodel.odatav4.core.CountRequestBuilder; import com.sap.cloud.sdk.datamodel.odatav4.core.CreateRequestBuilder; @@ -125,6 +127,16 @@ public SingleValueFunctionRequestBuilder functionWithNewResult return new SingleValueFunctionRequestBuilder(servicePath, "FunctionWithNewResultType", NewComplexResult.class); } + @Override + @Nonnull + public SingleValueFunctionRequestBuilder functionWithTypeDef( + @Nullable + final String functionParameter) { + final LinkedHashMap parameters = new LinkedHashMap(); + parameters.put("FunctionParameter", functionParameter); + return new SingleValueFunctionRequestBuilder(servicePath, "FunctionWithTypeDef", parameters, Integer.class); + } + @Override @Nonnull public SingleValueActionRequestBuilder noArgAction() { diff --git a/datamodel/odata-v4/pom.xml b/datamodel/odata-v4/pom.xml index 114858fc2..f8ea82005 100644 --- a/datamodel/odata-v4/pom.xml +++ b/datamodel/odata-v4/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-v4-parent pom diff --git a/datamodel/odata/odata-api-sample/pom.xml b/datamodel/odata/odata-api-sample/pom.xml index ef7371ec0..490149aa9 100644 --- a/datamodel/odata/odata-api-sample/pom.xml +++ b/datamodel/odata/odata-api-sample/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-api-sample OData VDM - Sample API diff --git a/datamodel/odata/odata-core/pom.xml b/datamodel/odata/odata-core/pom.xml index b96a6dd27..bb4616424 100644 --- a/datamodel/odata/odata-core/pom.xml +++ b/datamodel/odata/odata-core/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-core jar diff --git a/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/BatchResponse.java b/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/BatchResponse.java index 9077d430d..be5c1023b 100644 --- a/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/BatchResponse.java +++ b/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/BatchResponse.java @@ -8,7 +8,6 @@ import javax.annotation.Nonnull; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.helper.CollectionValuedFluentHelperFunction; import com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperByKey; import com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperRead; @@ -102,7 +101,6 @@ default List getReadResult( * * @since 4.15.0 */ - @Beta @Override void close(); } diff --git a/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/DefaultBatchResponseResult.java b/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/DefaultBatchResponseResult.java index 1d0c512cc..241bb8765 100644 --- a/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/DefaultBatchResponseResult.java +++ b/datamodel/odata/odata-core/src/main/java/com/sap/cloud/sdk/datamodel/odata/helper/batch/DefaultBatchResponseResult.java @@ -10,7 +10,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import com.google.common.annotations.Beta; import com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestGeneric; import com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultMultipartGeneric; import com.sap.cloud.sdk.datamodel.odata.helper.CollectionValuedFluentHelperFunction; @@ -131,7 +130,6 @@ private T getRequestPartByTypeAndIndex( final * * @since 4.15.0 */ - @Beta @Override public void close() { diff --git a/datamodel/odata/odata-generator-maven-plugin/pom.xml b/datamodel/odata/odata-generator-maven-plugin/pom.xml index af3702c48..605c86197 100644 --- a/datamodel/odata/odata-generator-maven-plugin/pom.xml +++ b/datamodel/odata/odata-generator-maven-plugin/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-generator-maven-plugin maven-plugin diff --git a/datamodel/odata/odata-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml b/datamodel/odata/odata-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml index e94c85442..bff186c59 100644 --- a/datamodel/odata/odata-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml +++ b/datamodel/odata/odata-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoTest/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/odata/odata-generator/pom.xml b/datamodel/odata/odata-generator/pom.xml index 154d53878..e0a897777 100644 --- a/datamodel/odata/odata-generator/pom.xml +++ b/datamodel/odata/odata-generator/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel odata-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-generator jar diff --git a/datamodel/odata/pom.xml b/datamodel/odata/pom.xml index b444ea7b6..c73b9cc74 100644 --- a/datamodel/odata/pom.xml +++ b/datamodel/odata/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT odata-parent pom diff --git a/datamodel/openapi/openapi-api-sample/pom.xml b/datamodel/openapi/openapi-api-sample/pom.xml index 40914163d..daa140a78 100644 --- a/datamodel/openapi/openapi-api-sample/pom.xml +++ b/datamodel/openapi/openapi-api-sample/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel openapi-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT openapi-api-sample Data Model - OpenAPI Services - Sample API @@ -93,6 +93,11 @@ jackson-databind test + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + test + @@ -108,7 +113,7 @@ - ${project.basedir}/src/main/resources/sodastore.json + ${project.basedir}/src/main/resources/sodastore.yaml com.sap.cloud.sdk.datamodel.openapi.sample.api com.sap.cloud.sdk.datamodel.openapi.sample.model released @@ -119,6 +124,7 @@ create protected + true true diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/SodasApi.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/SodasApi.java index adbe72a0e..ebf06d60d 100644 --- a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/SodasApi.java +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/SodasApi.java @@ -178,9 +178,9 @@ public SodaWithId sodasIdGet( @Nonnull final Long id ) *

    * 200 - The updated soda product *

    - * 404 - Soda product not found - *

    * 204 - Nothing has changed + *

    + * 404 - Soda product not found * * @param sodaWithId * The updated soda product diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AllOf.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AllOf.java new file mode 100644 index 000000000..67884d8a2 --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AllOf.java @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * AllOf + */ +// CHECKSTYLE:OFF +public class AllOf +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "caffeine" ) + private Boolean caffeine; + + @JsonProperty( "color" ) + private String color; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for AllOf. + */ + protected AllOf() + { + } + + /** + * Set the sodaType of this {@link AllOf} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link AllOf} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link AllOf} instance. + * + * @param sodaType + * The sodaType of this {@link AllOf} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the caffeine of this {@link AllOf} instance and return the same instance. + * + * @param caffeine + * The caffeine of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf caffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + return this; + } + + /** + * Get caffeine + * + * @return caffeine The caffeine of this {@link AllOf} instance. + */ + @Nonnull + public Boolean isCaffeine() + { + return caffeine; + } + + /** + * Set the caffeine of this {@link AllOf} instance. + * + * @param caffeine + * The caffeine of this {@link AllOf} + */ + public void setCaffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + } + + /** + * Set the color of this {@link AllOf} instance and return the same instance. + * + * @param color + * The color of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull + public AllOf color( @Nullable final String color ) + { + this.color = color; + return this; + } + + /** + * Get color + * + * @return color The color of this {@link AllOf} instance. + */ + @Nonnull + public String getColor() + { + return color; + } + + /** + * Set the color of this {@link AllOf} instance. + * + * @param color + * The color of this {@link AllOf} + */ + public void setColor( @Nullable final String color ) + { + this.color = color; + } + + /** + * Get the names of the unrecognizable properties of the {@link AllOf}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AllOf} instance. + * + * @param name + * The name of the property + * @return The value of the property + * @throws NoSuchElementException + * If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) + throws NoSuchElementException + { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AllOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AllOf} instance. If the map previously contained a mapping for the + * key, the old value is replaced by the specified value. + * + * @param customFieldName + * The name of the property + * @param customFieldValue + * The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals( @Nullable final java.lang.Object o ) + { + if( this == o ) { + return true; + } + if( o == null || getClass() != o.getClass() ) { + return false; + } + final AllOf allOf = (AllOf) o; + return Objects.equals(this.cloudSdkCustomFields, allOf.cloudSdkCustomFields) + && Objects.equals(this.sodaType, allOf.sodaType) + && Objects.equals(this.caffeine, allOf.caffeine) + && Objects.equals(this.color, allOf.color); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, caffeine, color, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class AllOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + cloudSdkCustomFields + .forEach(( k, v ) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString( final java.lang.Object o ) + { + if( o == null ) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a new {@link AllOf} instance. No arguments are required. + */ + public static AllOf create() + { + return new AllOf(); + } + +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AnyOf.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AnyOf.java new file mode 100644 index 000000000..5c40e1e68 --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/AnyOf.java @@ -0,0 +1,270 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * AnyOf + */ +// CHECKSTYLE:OFF +public class AnyOf +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "caffeine" ) + private Boolean caffeine; + + @JsonProperty( "color" ) + private String color; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for AnyOf. + */ + protected AnyOf() + { + } + + /** + * Set the sodaType of this {@link AnyOf} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link AnyOf} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link AnyOf} instance. + * + * @param sodaType + * The sodaType of this {@link AnyOf} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the caffeine of this {@link AnyOf} instance and return the same instance. + * + * @param caffeine + * The caffeine of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf caffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + return this; + } + + /** + * Get caffeine + * + * @return caffeine The caffeine of this {@link AnyOf} instance. + */ + @Nonnull + public Boolean isCaffeine() + { + return caffeine; + } + + /** + * Set the caffeine of this {@link AnyOf} instance. + * + * @param caffeine + * The caffeine of this {@link AnyOf} + */ + public void setCaffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + } + + /** + * Set the color of this {@link AnyOf} instance and return the same instance. + * + * @param color + * The color of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull + public AnyOf color( @Nullable final String color ) + { + this.color = color; + return this; + } + + /** + * Get color + * + * @return color The color of this {@link AnyOf} instance. + */ + @Nonnull + public String getColor() + { + return color; + } + + /** + * Set the color of this {@link AnyOf} instance. + * + * @param color + * The color of this {@link AnyOf} + */ + public void setColor( @Nullable final String color ) + { + this.color = color; + } + + /** + * Get the names of the unrecognizable properties of the {@link AnyOf}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AnyOf} instance. + * + * @param name + * The name of the property + * @return The value of the property + * @throws NoSuchElementException + * If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) + throws NoSuchElementException + { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AnyOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AnyOf} instance. If the map previously contained a mapping for the + * key, the old value is replaced by the specified value. + * + * @param customFieldName + * The name of the property + * @param customFieldValue + * The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals( @Nullable final java.lang.Object o ) + { + if( this == o ) { + return true; + } + if( o == null || getClass() != o.getClass() ) { + return false; + } + final AnyOf anyOf = (AnyOf) o; + return Objects.equals(this.cloudSdkCustomFields, anyOf.cloudSdkCustomFields) + && Objects.equals(this.sodaType, anyOf.sodaType) + && Objects.equals(this.caffeine, anyOf.caffeine) + && Objects.equals(this.color, anyOf.color); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, caffeine, color, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + cloudSdkCustomFields + .forEach(( k, v ) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString( final java.lang.Object o ) + { + if( o == null ) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a new {@link AnyOf} instance. No arguments are required. + */ + public static AnyOf create() + { + return new AnyOf(); + } + +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Cola.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Cola.java new file mode 100644 index 000000000..80cab38dd --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Cola.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Cola + */ +// CHECKSTYLE:OFF +public class Cola implements OneOf, OneOfWithDiscriminator, OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "caffeine" ) + private Boolean caffeine; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Cola. + */ + protected Cola() + { + } + + /** + * Set the sodaType of this {@link Cola} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull + public Cola sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link Cola} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link Cola} instance. + * + * @param sodaType + * The sodaType of this {@link Cola} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the caffeine of this {@link Cola} instance and return the same instance. + * + * @param caffeine + * The caffeine of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull + public Cola caffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + return this; + } + + /** + * Get caffeine + * + * @return caffeine The caffeine of this {@link Cola} instance. + */ + @Nonnull + public Boolean isCaffeine() + { + return caffeine; + } + + /** + * Set the caffeine of this {@link Cola} instance. + * + * @param caffeine + * The caffeine of this {@link Cola} + */ + public void setCaffeine( @Nullable final Boolean caffeine ) + { + this.caffeine = caffeine; + } + + /** + * Get the names of the unrecognizable properties of the {@link Cola}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Cola} instance. + * + * @param name + * The name of the property + * @return The value of the property + * @throws NoSuchElementException + * If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) + throws NoSuchElementException + { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Cola has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Cola} instance. If the map previously contained a mapping for the + * key, the old value is replaced by the specified value. + * + * @param customFieldName + * The name of the property + * @param customFieldValue + * The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals( @Nullable final java.lang.Object o ) + { + if( this == o ) { + return true; + } + if( o == null || getClass() != o.getClass() ) { + return false; + } + final Cola cola = (Cola) o; + return Objects.equals(this.cloudSdkCustomFields, cola.cloudSdkCustomFields) + && Objects.equals(this.sodaType, cola.sodaType) + && Objects.equals(this.caffeine, cola.caffeine); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, caffeine, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Cola {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" caffeine: ").append(toIndentedString(caffeine)).append("\n"); + cloudSdkCustomFields + .forEach(( k, v ) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString( final java.lang.Object o ) + { + if( o == null ) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a new {@link Cola} instance. No arguments are required. + */ + public static Cola create() + { + return new Cola(); + } + +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Fanta.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Fanta.java new file mode 100644 index 000000000..5a14ed75b --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Fanta.java @@ -0,0 +1,229 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Fanta + */ +// CHECKSTYLE:OFF +public class Fanta implements OneOf, OneOfWithDiscriminator, OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty( "sodaType" ) + private String sodaType; + + @JsonProperty( "color" ) + private String color; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Default constructor for Fanta. + */ + protected Fanta() + { + } + + /** + * Set the sodaType of this {@link Fanta} instance and return the same instance. + * + * @param sodaType + * The sodaType of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull + public Fanta sodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * + * @return sodaType The sodaType of this {@link Fanta} instance. + */ + @Nonnull + public String getSodaType() + { + return sodaType; + } + + /** + * Set the sodaType of this {@link Fanta} instance. + * + * @param sodaType + * The sodaType of this {@link Fanta} + */ + public void setSodaType( @Nullable final String sodaType ) + { + this.sodaType = sodaType; + } + + /** + * Set the color of this {@link Fanta} instance and return the same instance. + * + * @param color + * The color of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull + public Fanta color( @Nullable final String color ) + { + this.color = color; + return this; + } + + /** + * Get color + * + * @return color The color of this {@link Fanta} instance. + */ + @Nonnull + public String getColor() + { + return color; + } + + /** + * Set the color of this {@link Fanta} instance. + * + * @param color + * The color of this {@link Fanta} + */ + public void setColor( @Nullable final String color ) + { + this.color = color; + } + + /** + * Get the names of the unrecognizable properties of the {@link Fanta}. + * + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() + { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Fanta} instance. + * + * @param name + * The name of the property + * @return The value of the property + * @throws NoSuchElementException + * If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) + throws NoSuchElementException + { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Fanta has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Fanta} instance. If the map previously contained a mapping for the + * key, the old value is replaced by the specified value. + * + * @param customFieldName + * The name of the property + * @param customFieldValue + * The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + @Override + public boolean equals( @Nullable final java.lang.Object o ) + { + if( this == o ) { + return true; + } + if( o == null || getClass() != o.getClass() ) { + return false; + } + final Fanta fanta = (Fanta) o; + return Objects.equals(this.cloudSdkCustomFields, fanta.cloudSdkCustomFields) + && Objects.equals(this.sodaType, fanta.sodaType) + && Objects.equals(this.color, fanta.color); + } + + @Override + public int hashCode() + { + return Objects.hash(sodaType, color, cloudSdkCustomFields); + } + + @Override + @Nonnull + public String toString() + { + final StringBuilder sb = new StringBuilder(); + sb.append("class Fanta {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).append("\n"); + cloudSdkCustomFields + .forEach(( k, v ) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString( final java.lang.Object o ) + { + if( o == null ) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Create a new {@link Fanta} instance. No arguments are required. + */ + public static Fanta create() + { + return new Fanta(); + } + +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOf.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOf.java new file mode 100644 index 000000000..47e69617e --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOf.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * OneOf + */ +@JsonTypeInfo( use = JsonTypeInfo.Id.DEDUCTION ) +@JsonSubTypes( { @JsonSubTypes.Type( value = Cola.class ), @JsonSubTypes.Type( value = Fanta.class ), } ) + +public interface OneOf +{ +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOfWithDiscriminator.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOfWithDiscriminator.java new file mode 100644 index 000000000..9c31dbc7a --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOfWithDiscriminator.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * OneOfWithDiscriminator + */ +@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true ) +@JsonSubTypes( { + @JsonSubTypes.Type( value = Cola.class, name = "Cola" ), + @JsonSubTypes.Type( value = Fanta.class, name = "Fanta" ), } ) + +public interface OneOfWithDiscriminator +{ + String getSodaType(); +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOfWithDiscriminatorAndMapping.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOfWithDiscriminatorAndMapping.java new file mode 100644 index 000000000..987be2d11 --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OneOfWithDiscriminatorAndMapping.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.datamodel.openapi.sample.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * OneOfWithDiscriminatorAndMapping + */ +@JsonTypeInfo( use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true ) +@JsonSubTypes( { + @JsonSubTypes.Type( value = Cola.class, name = "cool_cola" ), + @JsonSubTypes.Type( value = Fanta.class, name = "fancy_fanta" ), + @JsonSubTypes.Type( value = Cola.class, name = "Cola" ), + @JsonSubTypes.Type( value = Fanta.class, name = "Fanta" ), } ) + +public interface OneOfWithDiscriminatorAndMapping +{ + String getSodaType(); +} diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Order.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Order.java index 8f73cef29..3faac6654 100644 --- a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Order.java +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Order.java @@ -56,6 +56,9 @@ public class Order @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for Order. + */ protected Order() { } diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OrderWithTimestamp.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OrderWithTimestamp.java index b0ff17115..7c44c844a 100644 --- a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OrderWithTimestamp.java +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/OrderWithTimestamp.java @@ -60,6 +60,9 @@ public class OrderWithTimestamp @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for OrderWithTimestamp. + */ protected OrderWithTimestamp() { } diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Soda.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Soda.java index 3cef9af06..41b756de7 100644 --- a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Soda.java +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/Soda.java @@ -134,6 +134,9 @@ public static PackagingEnum fromValue( @Nonnull final String value ) @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for Soda. + */ protected Soda() { } diff --git a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/SodaWithId.java b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/SodaWithId.java index 9d9731fb5..2f4ef17c1 100644 --- a/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/SodaWithId.java +++ b/datamodel/openapi/openapi-api-sample/src/main/java/com/sap/cloud/sdk/datamodel/openapi/sample/model/SodaWithId.java @@ -137,6 +137,9 @@ public static PackagingEnum fromValue( @Nonnull final String value ) @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for SodaWithId. + */ protected SodaWithId() { } diff --git a/datamodel/openapi/openapi-api-sample/src/main/resources/sodastore.yaml b/datamodel/openapi/openapi-api-sample/src/main/resources/sodastore.yaml new file mode 100644 index 000000000..286817bc2 --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/main/resources/sodastore.yaml @@ -0,0 +1,224 @@ +openapi: 3.0.3 +info: + title: SodaStore API + version: 1.0.0 + description: API for managing soda products and orders in SodaStore. +tags: + - name: Sodas + description: Everything about our Sodas + - name: user + description: Operations about user + - name: Orders + description: Access to Sodastore orders +components: + securitySchemes: + apiKeyAuth: + type: apiKey + in: header + name: X-API-Key + bearerAuth: + type: http + scheme: bearer + schemas: + Soda: + type: object + required: + - name + - brand + - quantity + - price + properties: + name: + type: string + example: Cola + brand: + type: string + example: Coca-Cola + quantity: + type: integer + format: int32 + example: 100 + packaging: + type: string + enum: + - glass + - carton + - can + nullable: false + price: + type: number + format: float + example: 1.5 + SodaWithId: + allOf: + - $ref: '#/components/schemas/Soda' + - type: object + properties: + id: + type: integer + format: int64 + example: 123 + Order: + type: object + required: + - productId + - quantity + properties: + productId: + type: integer + format: int64 + example: 1 + quantity: + type: integer + format: int32 + example: 2 + totalPrice: + type: number + format: float + example: 3 + typelessProperty: + description: >- + Some typeless property, interpreted by the generator as nullable by + default (because typeless) + nullableProperty: + type: string + description: Some typed property that is deliberately made nullable + nullable: true + OrderWithTimestamp: + allOf: + - $ref: '#/components/schemas/Order' + - type: object + properties: + timestamp: + type: string + format: date-time + OneOfWithDiscriminatorAndMapping: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + mapping: + cool_cola: '#/components/schemas/Cola' + fancy_fanta: '#/components/schemas/Fanta' + OneOfWithDiscriminator: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + OneOf: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AnyOf: + anyOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AllOf: + allOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + Cola: + type: object + properties: + sodaType: + type: string + caffeine: + type: boolean + Fanta: + type: object + properties: + sodaType: + type: string + color: + type: string +paths: + /sodas: + get: + summary: Get all soda products + tags: + - Sodas + security: + - apiKeyAuth: [] + responses: + '200': + description: A list of soda products + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SodaWithId' + put: + summary: Update a specific soda product by ID + tags: + - Sodas + security: + - apiKeyAuth: [] + requestBody: + description: The updated soda product + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/SodaWithId' + responses: + '200': + description: The updated soda product + content: + application/json: + schema: + $ref: '#/components/schemas/Soda' + '204': + description: Nothing has changed + '404': + description: Soda product not found + /sodas/{id}: + get: + summary: Get a specific soda product by ID + tags: + - Sodas + security: + - apiKeyAuth: [] + parameters: + - name: id + in: path + description: ID of the soda product to retrieve + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: The soda product + content: + application/json: + schema: + $ref: '#/components/schemas/SodaWithId' + '404': + description: Soda product not found + /orders: + post: + summary: Create a new order + tags: + - Orders + security: + - apiKeyAuth: [] + requestBody: + description: The order details + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Order' + responses: + '201': + description: The created order + content: + application/json: + schema: + $ref: '#/components/schemas/Order' +security: + - apiKeyAuth: [] + - bearerAuth: [] diff --git a/datamodel/openapi/openapi-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/OneOfDeserializationTest.java b/datamodel/openapi/openapi-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/OneOfDeserializationTest.java new file mode 100644 index 000000000..011356a3b --- /dev/null +++ b/datamodel/openapi/openapi-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/OneOfDeserializationTest.java @@ -0,0 +1,183 @@ +package com.sap.cloud.sdk.datamodel.openapi.sample.api; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.AssertionsForClassTypes.assertThat; + +import javax.annotation.Nonnull; + +import org.junit.jupiter.api.Test; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.AllOf; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.AnyOf; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.Cola; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.Fanta; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.OneOf; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.OneOfWithDiscriminator; +import com.sap.cloud.sdk.datamodel.openapi.sample.model.OneOfWithDiscriminatorAndMapping; + +class OneOfDeserializationTest +{ + private static final ObjectMapper objectMapper = newDefaultObjectMapper(); + + private static final Cola COLA_OBJECT = Cola.create().caffeine(true).sodaType("Cola"); + private static final Fanta FANTA_OBJECT = Fanta.create().color("orange").sodaType("Fanta"); + private static final String COLA_JSON = """ + { + "sodaType": "Cola", + "caffeine": true + }"""; + private static final String FANTA_JSON = """ + { + "sodaType": "Fanta", + "color": "orange" + }"""; + private static final String UNKNOWN_JSON = """ + { + "sodaType": "Sprite", + "someProperty": "someValue" + }"""; + + @Test + void oneOf() + throws JsonProcessingException + { + var actual = objectMapper.readValue(COLA_JSON, OneOf.class); + assertThat(actual) + .describedAs("Object should automatically be deserialized as Cola with JSON subtype deduction") + .isInstanceOf(Cola.class) + .isEqualTo(COLA_OBJECT); + + actual = objectMapper.readValue(FANTA_JSON, OneOf.class); + assertThat(actual) + .describedAs("Object should automatically be deserialized as Fanta with JSON subtype deduction") + .isInstanceOf(Fanta.class) + .isEqualTo(FANTA_OBJECT); + + assertThatThrownBy(() -> objectMapper.readValue(UNKNOWN_JSON, OneOf.class)) + .isInstanceOf(JsonProcessingException.class); + } + + @Test + void oneOfWithDiscriminator() + throws JsonProcessingException + { + var actual = objectMapper.readValue(COLA_JSON, OneOfWithDiscriminator.class); + assertThat(actual) + .describedAs( + "Object should automatically be deserialized as Cola using the class names as discriminator mapping values") + .isInstanceOf(Cola.class) + .isEqualTo(COLA_OBJECT); + + actual = objectMapper.readValue(FANTA_JSON, OneOfWithDiscriminator.class); + assertThat(actual) + .describedAs( + "Object should automatically be deserialized as Fanta using the class names as discriminator mapping values") + .isInstanceOf(Fanta.class) + .isEqualTo(FANTA_OBJECT); + + assertThatThrownBy(() -> objectMapper.readValue(UNKNOWN_JSON, OneOfWithDiscriminator.class)); + } + + @Test + void oneOfWithDiscriminatorAndMapping() + throws JsonProcessingException + { + var jsonWithCustomMapping = """ + { + "sodaType": "cool_cola", + "caffeine": true + }"""; + var actual = objectMapper.readValue(jsonWithCustomMapping, OneOfWithDiscriminatorAndMapping.class); + assertThat(actual) + .describedAs( + "Object should automatically be deserialized as Cola using the explicit discriminator mapping values") + .isInstanceOf(Cola.class) + .isEqualTo(Cola.create().caffeine(true).sodaType("cool_cola")); + + jsonWithCustomMapping = """ + { + "sodaType": "fancy_fanta", + "color": "orange" + }"""; + actual = objectMapper.readValue(jsonWithCustomMapping, OneOfWithDiscriminatorAndMapping.class); + assertThat(actual) + .describedAs( + "Object should automatically be deserialized as Fanta using the explicit discriminator mapping values") + .isInstanceOf(Fanta.class) + .isEqualTo(Fanta.create().color("orange").sodaType("fancy_fanta")); + + assertThatThrownBy(() -> objectMapper.readValue(UNKNOWN_JSON, OneOfWithDiscriminatorAndMapping.class)) + .isInstanceOf(JsonProcessingException.class); + + } + + @Test + void anyOf() + throws JsonProcessingException + { + AnyOf anyOfCola = objectMapper.readValue(COLA_JSON, AnyOf.class); + assertThat(anyOfCola.getSodaType()).isEqualTo("Cola"); + assertThat(anyOfCola.isCaffeine()).isTrue(); + assertThat(anyOfCola.getColor()).isNull(); + + AnyOf anyOfFanta = objectMapper.readValue(FANTA_JSON, AnyOf.class); + assertThat(anyOfFanta.getSodaType()).isEqualTo("Fanta"); + assertThat(anyOfFanta.getColor()).isEqualTo("orange"); + assertThat(anyOfFanta.isCaffeine()).isNull(); + } + + @Test + void allOf() + throws JsonProcessingException + { + AllOf allOfCola = objectMapper.readValue(COLA_JSON, AllOf.class); + assertThat(allOfCola.getSodaType()).isEqualTo("Cola"); + assertThat(allOfCola.isCaffeine()).isTrue(); + assertThat(allOfCola.getColor()).isNull(); + + AllOf allOfFanta = objectMapper.readValue(FANTA_JSON, AllOf.class); + assertThat(allOfFanta.getSodaType()).isEqualTo("Fanta"); + assertThat(allOfFanta.getColor()).isEqualTo("orange"); + assertThat(allOfFanta.isCaffeine()).isNull(); + } + + @Test + void testColaSerialization() + throws JsonProcessingException + { + var expected = objectMapper.readValue(COLA_JSON, JsonNode.class); + var actual = objectMapper.valueToTree(expected); + + assertThat(actual).isEqualTo(expected); + } + + @Test + void testFantaSerialization() + throws JsonProcessingException + { + var expected = objectMapper.readValue(FANTA_JSON, JsonNode.class); + var actual = objectMapper.valueToTree(expected); + + assertThat(actual).isEqualTo(expected); + } + + /** + * Taken from {@link com.sap.cloud.sdk.services.openapi.apiclient.ApiClient} + */ + @Nonnull + private static ObjectMapper newDefaultObjectMapper() + { + return new Jackson2ObjectMapperBuilder() + .modules(new JavaTimeModule()) + .visibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE) + .visibility(PropertyAccessor.SETTER, JsonAutoDetect.Visibility.NONE) + .build(); + } +} diff --git a/datamodel/openapi/openapi-core/pom.xml b/datamodel/openapi/openapi-core/pom.xml index 7ccfa3659..2b8fd93d5 100644 --- a/datamodel/openapi/openapi-core/pom.xml +++ b/datamodel/openapi/openapi-core/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel openapi-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT openapi-core Data Model - OpenAPI Services - Core diff --git a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClient.java b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClient.java index 49e691979..d99849374 100644 --- a/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClient.java +++ b/datamodel/openapi/openapi-core/src/main/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClient.java @@ -693,6 +693,7 @@ public T invokeAPI( // auth headers are added automatically by the SDK // updateParamsForAuth(authNames, queryParams, headerParams); + @SuppressWarnings( "deprecation" ) // spring-web:6.2.0 and later, works until <7.0.0 final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path); if( queryParams != null ) { //encode the query parameters in case they contain unsafe characters diff --git a/datamodel/openapi/openapi-core/src/test/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClientViaConstructorTest.java b/datamodel/openapi/openapi-core/src/test/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClientViaConstructorTest.java index a7ab44c06..2d3f02791 100644 --- a/datamodel/openapi/openapi-core/src/test/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClientViaConstructorTest.java +++ b/datamodel/openapi/openapi-core/src/test/java/com/sap/cloud/sdk/services/openapi/apiclient/ApiClientViaConstructorTest.java @@ -4,6 +4,13 @@ package com.sap.cloud.sdk.services.openapi.apiclient; +import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; +import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor; +import static com.github.tomakehurst.wiremock.client.WireMock.ok; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.verify; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; @@ -18,6 +25,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.test.web.client.ExpectedCount; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.test.web.client.response.MockRestResponseCreators; @@ -27,8 +35,14 @@ import org.springframework.web.util.UriComponentsBuilder; import com.fasterxml.jackson.annotation.JsonProperty; +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; +import com.github.tomakehurst.wiremock.junit5.WireMockTest; +import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder; +import com.sap.cloud.sdk.cloudplatform.connectivity.ApacheHttpClient5FactoryBuilder.TlsUpgrade; +import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpDestination; import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +@WireMockTest class ApiClientViaConstructorTest { private static final String RELATIVE_PATH = "/apiEndpoint"; @@ -121,6 +135,45 @@ void testApiClientWithQueryParams() server.verify(); } + @Test + void testHttpRequestConfigIsTransmitted( WireMockRuntimeInfo wm ) + { + httpRequest(TlsUpgrade.DISABLED, wm.getHttpBaseUrl()); + verify(getRequestedFor(anyUrl()).withoutHeader("Upgrade")); + + httpRequest(TlsUpgrade.ENABLED, wm.getHttpBaseUrl()); + verify(getRequestedFor(anyUrl()).withHeader("Upgrade", equalTo("TLS/1.2"))); + } + + private static void httpRequest( TlsUpgrade toggle, String url ) + { + var sut = new ApacheHttpClient5FactoryBuilder().tlsUpgrade(toggle).build(); + var httpClient = sut.createHttpClient(DefaultHttpDestination.builder(url).build()); + var clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpClient); + var restTemplate = new RestTemplate(clientHttpRequestFactory); + var apiClient = new ApiClient(restTemplate); + apiClient.setBasePath(url); + + stubFor(get(anyUrl()).willReturn(ok("success"))); + + assertThat( + apiClient + .invokeAPI( + "/apiEndpoint", + HttpMethod.GET, + null, + null, + new HttpHeaders(), + null, + null, + null, + null, + new ParameterizedTypeReference() + { + })) + .isEqualTo("success"); + } + private static class MyDto { @JsonProperty( "Return" ) diff --git a/datamodel/openapi/openapi-generator-maven-plugin/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/pom.xml index edaa6ecad..45626cdb1 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel openapi-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT openapi-generator-maven-plugin maven-plugin diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojo.java b/datamodel/openapi/openapi-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojo.java index b1e2f7714..3de241031 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojo.java +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojo.java @@ -118,6 +118,18 @@ public class DataModelGeneratorMojo extends AbstractMojo @Parameter( property = "openapi.generate.enableOneOfAnyOfGeneration", defaultValue = "false" ) private boolean enableOneOfAnyOfGeneration; + /** + * Generate model classes. Default is true. + */ + @Parameter( property = "openapi.generate.generateModels", defaultValue = "true" ) + private boolean generateModels; + + /** + * Generate API classes (client classes). Default is true. + */ + @Parameter( property = "openapi.generate.generateApis", defaultValue = "true" ) + private boolean generateApis; + /** * Defines a list of additional properties that will be passed to the Java generator. */ @@ -179,6 +191,8 @@ Try retrieveGenerationConfiguration() .deleteOutputDirectory(deleteOutputDirectory) .additionalProperties(additionalProperties) .oneOfAnyOfGenerationEnabled(enableOneOfAnyOfGeneration) + .generateModels(generateModels) + .generateApis(generateApis) .build()); } diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/input/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/input/pom.xml index 42393b95a..cd9ae73f0 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/input/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/input/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/NewSoda.java b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/NewSoda.java index 9cd21bc5c..9d804a8b2 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/NewSoda.java +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/NewSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.datamodel.rest.sodastore.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -75,7 +73,8 @@ public class NewSoda * Get name * @return name The name of this {@link NewSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -103,7 +102,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link NewSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -131,7 +131,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link NewSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -159,7 +160,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link NewSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,6 +256,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/Soda.java b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/Soda.java index 86b6a86cf..ce1a59379 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/Soda.java +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/Soda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.datamodel.rest.sodastore.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -78,7 +76,8 @@ public class Soda * Get id * @return id The id of this {@link Soda} instance. */ - @Nonnull public Long getId() { + @Nonnull + public Long getId() { return id; } @@ -106,7 +105,8 @@ public void setId( @Nullable final Long id) { * Get name * @return name The name of this {@link Soda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -134,7 +134,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link Soda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -162,7 +163,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link Soda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -190,7 +192,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link Soda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -287,6 +290,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/UpdateSoda.java b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/UpdateSoda.java index 80c92dc10..46a6d284a 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/UpdateSoda.java +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/output/com/sap/cloud/sdk/datamodel/rest/sodastore/model/UpdateSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.datamodel.rest.sodastore.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -75,7 +73,8 @@ public class UpdateSoda * Get name * @return name The name of this {@link UpdateSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -103,7 +102,8 @@ public void setName( @Nullable final String name) { * Get brand * @return brand The brand of this {@link UpdateSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -131,7 +131,8 @@ public void setBrand( @Nullable final String brand) { * Get flavor * @return flavor The flavor of this {@link UpdateSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -159,7 +160,8 @@ public void setFlavor( @Nullable final String flavor) { * Get price * @return price The price of this {@link UpdateSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,6 +256,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testAdditionalPropertiesAndEnablingAnyOfOneOf/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testAdditionalPropertiesAndEnablingAnyOfOneOf/pom.xml index 81ad96d68..daa70e691 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testAdditionalPropertiesAndEnablingAnyOfOneOf/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testAdditionalPropertiesAndEnablingAnyOfOneOf/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testEmptyRequiredParameter/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testEmptyRequiredParameter/pom.xml index 657408844..3d872f3c9 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testEmptyRequiredParameter/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testEmptyRequiredParameter/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithAllParameters/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithAllParameters/pom.xml index 87b5c6433..c6d284a42 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithAllParameters/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithAllParameters/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithMandatoryParameters/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithMandatoryParameters/pom.xml index 6e1322369..d02f3be3a 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithMandatoryParameters/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithMandatoryParameters/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithUnexpectedApiMaturity/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithUnexpectedApiMaturity/pom.xml index 8276d8586..9c33727cb 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithUnexpectedApiMaturity/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testInvocationWithUnexpectedApiMaturity/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testSkipExecution/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testSkipExecution/pom.xml index 69d7c2814..a09d055c8 100644 --- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testSkipExecution/pom.xml +++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/resources/DataModelGeneratorMojoUnitTest/testSkipExecution/pom.xml @@ -5,7 +5,7 @@ com.company application - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/datamodel/openapi/openapi-generator/pom.xml b/datamodel/openapi/openapi-generator/pom.xml index 8df94a95e..7077b00b4 100644 --- a/datamodel/openapi/openapi-generator/pom.xml +++ b/datamodel/openapi/openapi-generator/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel openapi-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT openapi-generator jar diff --git a/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/GenerationConfigurationConverter.java b/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/GenerationConfigurationConverter.java index 0ffa68832..8f1744a68 100644 --- a/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/GenerationConfigurationConverter.java +++ b/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/GenerationConfigurationConverter.java @@ -56,7 +56,7 @@ static ClientOptInput convertGenerationConfiguration( @Nonnull final GenerationConfiguration generationConfiguration, @Nonnull final Path inputSpec ) { - setGlobalSettings(); + setGlobalSettings(generationConfiguration); final var inputSpecFile = inputSpec.toString(); final var config = createCodegenConfig(); @@ -96,10 +96,17 @@ public OperationsMap postProcessOperationsWithModels( }; } - private static void setGlobalSettings() + private static void setGlobalSettings( @Nonnull final GenerationConfiguration configuration ) { - GlobalSettings.setProperty(CodegenConstants.APIS, ""); - GlobalSettings.setProperty(CodegenConstants.MODELS, ""); + if( configuration.isGenerateApis() ) { + GlobalSettings.setProperty(CodegenConstants.APIS, getAllowedIds(configuration, "apisToGenerate")); + } + if( configuration.isGenerateModels() ) { + GlobalSettings.setProperty(CodegenConstants.MODELS, getAllowedIds(configuration, "modelsToGenerate")); + } + if( configuration.isDebugModels() ) { + GlobalSettings.setProperty("debugModels", "true"); + } GlobalSettings.setProperty(CodegenConstants.MODEL_TESTS, Boolean.FALSE.toString()); GlobalSettings.setProperty(CodegenConstants.MODEL_DOCS, Boolean.FALSE.toString()); GlobalSettings.setProperty(CodegenConstants.API_TESTS, Boolean.FALSE.toString()); @@ -108,6 +115,15 @@ private static void setGlobalSettings() GlobalSettings.setProperty(CodegenConstants.HIDE_GENERATION_TIMESTAMP, Boolean.TRUE.toString()); } + private static String getAllowedIds( @Nonnull final GenerationConfiguration config, @Nonnull final String property ) + { + final var allowIds = config.getAdditionalProperties().get(property); + if( allowIds == null || allowIds.isBlank() ) { + return ""; + } + return String.join(",", allowIds.trim().split("\\s+")); + } + private static OpenAPI parseOpenApiSpec( @Nonnull final String inputSpecFile ) { final List authorizationValues = List.of(); @@ -136,7 +152,7 @@ private static Map getAdditionalProperties( @Nonnull final Gener if( !Strings.isNullOrEmpty(copyrightHeader) ) { result.put(COPYRIGHT_PROPERTY_KEY, copyrightHeader); } - result.put(CodegenConstants.SERIALIZABLE_MODEL, "true"); + result.put(CodegenConstants.SERIALIZABLE_MODEL, "false"); result.put(JAVA_8_PROPERTY_KEY, "true"); result.put(DATE_LIBRARY_PROPERTY_KEY, "java8"); result.put(BOOLEAN_GETTER_PREFIX_PROPERTY_KEY, "is"); diff --git a/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/PreprocessingStepOrchestrator.java b/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/PreprocessingStepOrchestrator.java index 8b3d6ca3b..e33d3225e 100644 --- a/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/PreprocessingStepOrchestrator.java +++ b/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/PreprocessingStepOrchestrator.java @@ -5,7 +5,6 @@ package com.sap.cloud.sdk.datamodel.openapi.generator; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -51,17 +50,14 @@ class PreprocessingStepOrchestrator * {@code anyOfOneOfGenerationEnabled} * * @param anyOfOneOfGenerationEnabled + * true if clients should be generated for input specification with oneOf, anyOf * * @return this */ - PreprocessingStepOrchestrator enableAnyOfOneOfGeneration( @Nonnull final boolean anyOfOneOfGenerationEnabled ) + PreprocessingStepOrchestrator enableAnyOfOneOfGeneration( final boolean anyOfOneOfGenerationEnabled ) { if( !anyOfOneOfGenerationEnabled ) { steps.add(ValidationKeywordsPreprocessor::new); - } else { - log - .warn( - "oneOf/anyOf keywords processing is turned on, the generated client may not be feature complete and work as expected for all cases involving anyOf/oneOf"); } return this; } @@ -115,7 +111,7 @@ private Path writeProcessedSpecToTempFile( @Nonnull final JsonNode rootNode, @No "." + fileFormat.getFileExtensions().get(0)); final String content = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rootNode); - Files.write(path, content.getBytes(StandardCharsets.UTF_8)); + Files.writeString(path, content); return path.normalize().toAbsolutePath(); } diff --git a/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/model/GenerationConfiguration.java b/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/model/GenerationConfiguration.java index 8ad9bb9b8..881a01295 100644 --- a/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/model/GenerationConfiguration.java +++ b/datamodel/openapi/openapi-generator/src/main/java/com/sap/cloud/sdk/datamodel/openapi/generator/model/GenerationConfiguration.java @@ -56,6 +56,15 @@ public class GenerationConfiguration @Builder.Default boolean oneOfAnyOfGenerationEnabled = false; + @Builder.Default + boolean generateModels = true; + + @Builder.Default + boolean generateApis = true; + + @Builder.Default + boolean debugModels = false; + /** * Indicates whether to use the default SAP copyright header for generated files. * diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/resttemplate/api.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/resttemplate/api.mustache index e11846e89..a654ec271 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/resttemplate/api.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/libraries/resttemplate/api.mustache @@ -30,7 +30,10 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import com.google.common.annotations.Beta; -import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; +{{^aiSdkConstructor}}import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; +{{/aiSdkConstructor}} +{{#aiSdkConstructor}}import com.sap.ai.sdk.core.AiCoreService; +{{/aiSdkConstructor}} /** * {{appName}} in version {{version}}. @@ -40,6 +43,7 @@ import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; @Beta{{/isReleased}} {{#operations}} public class {{classname}} extends AbstractOpenApiService { +{{^aiSdkConstructor}} /** * Instantiates this API class to invoke operations on the {{appName}}. * @@ -61,6 +65,27 @@ public class {{classname}} extends AbstractOpenApiService { { super(apiClient); } +{{/aiSdkConstructor}} +{{#aiSdkConstructor}} + + /** + * Instantiates this API class to invoke operations on the {{appName}} + */ + public {{classname}}() + { + super(new AiCoreService().getApiClient()); + } + + /** + * Instantiates this API class to invoke operations on the {{appName}} + * + * @param aiCoreService The configured connectivity instance to AI Core + */ + public {{classname}}( @Nonnull final AiCoreService aiCoreService ) + { + super(aiCoreService.getApiClient()); + } +{{/aiSdkConstructor}} {{#operation}}{{#hasOptionalParams}} /** diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/model.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/model.mustache index 11bc4795e..1ce0b522e 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/model.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/model.mustache @@ -10,11 +10,11 @@ package {{package}}; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; {{/useReflectionEqualsHashCode}} +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; {{#imports}} import {{import}}; @@ -27,14 +27,33 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; {{#withXml}} import com.fasterxml.jackson.dataformat.xml.annotation.*; {{/withXml}} +{{#vendorExtensions.x-has-readonly-properties}} +import com.fasterxml.jackson.annotation.JsonCreator; +{{/vendorExtensions.x-has-readonly-properties}} {{/jackson}} {{#withXml}} import {{javaxPackage}}.xml.bind.annotation.*; +import {{javaxPackage}}.xml.bind.annotation.adapters.*; +import io.github.threetenjaxb.core.*; {{/withXml}} +{{#jsonb}} +import java.lang.reflect.Type; +import {{javaxPackage}}.json.bind.annotation.JsonbTypeDeserializer; +import {{javaxPackage}}.json.bind.annotation.JsonbTypeSerializer; +import {{javaxPackage}}.json.bind.serializer.DeserializationContext; +import {{javaxPackage}}.json.bind.serializer.JsonbDeserializer; +import {{javaxPackage}}.json.bind.serializer.JsonbSerializer; +import {{javaxPackage}}.json.bind.serializer.SerializationContext; +import {{javaxPackage}}.json.stream.JsonGenerator; +import {{javaxPackage}}.json.stream.JsonParser; +import {{javaxPackage}}.json.bind.annotation.JsonbProperty; +{{#vendorExtensions.x-has-readonly-properties}} +import {{javaxPackage}}.json.bind.annotation.JsonbCreator; +{{/vendorExtensions.x-has-readonly-properties}} +{{/jsonb}} {{#parcelableModel}} import android.os.Parcelable; import android.os.Parcel; @@ -57,6 +76,6 @@ import {{javaxPackage}}.annotation.Nullable; {{#models}} {{#model}} -{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{>pojo}}{{/isEnum}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#vendorExtensions.x-is-one-of-interface}}{{>oneof_interface}}{{/vendorExtensions.x-is-one-of-interface}}{{^vendorExtensions.x-is-one-of-interface}}{{>pojo}}{{/vendorExtensions.x-is-one-of-interface}}{{/isEnum}} {{/model}} {{/models}} diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelEnum.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelEnum.mustache index 6de2249ab..af40d5209 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelEnum.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelEnum.mustache @@ -2,10 +2,27 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; {{/jackson}} +{{#gson}} +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +{{/gson}} +{{#isUri}} +import java.net.URI; +{{/isUri}} /** * {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} */ +{{#gson}} +@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class) +{{/gson}} +{{#jsonb}} +@JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class) +@JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class) +{{/jsonb}} {{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { {{#allowableValues}}{{#enumVars}} {{#enumDescription}} @@ -61,6 +78,42 @@ import com.fasterxml.jackson.annotation.JsonValue; } {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}} } +{{#gson}} + + public static class Adapter extends TypeAdapter<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> { + @Override + public void write(final JsonWriter jsonWriter, final {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} enumeration) throws IOException { + jsonWriter.value(enumeration.getValue(){{#isUri}}.toASCIIString(){{/isUri}}); + } + + @Override + public {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException { + {{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = {{#isFloat}}(float){{/isFloat}}{{#isUri}}URI.create({{/isUri}}jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{#isUri}}nextString()){{/isUri}}{{^isNumber}}{{^isInteger}}{{^isUri}}{{#isFloat}}nextDouble{{/isFloat}}{{^isFloat}}next{{{dataType}}}{{/isFloat}}(){{/isUri}}{{/isInteger}}{{/isNumber}}; + return {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}}); + } + } +{{/gson}} +{{#jsonb}} + + public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> { + @Override + public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'");{{/useNullForUnknownEnumValue}} + } + } + + public static final class Serializer implements JsonbSerializer<{{datatypeWithEnum}}> { + @Override + public void serialize({{datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } +{{/jsonb}} {{#supportUrlQuery}} /** diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache index 7785a086a..2472a72c4 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/modelInnerEnum.mustache @@ -1,6 +1,13 @@ /** * {{description}}{{^description}}Gets or Sets {{{name}}}{{/description}} */ +{{#gson}} + @JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.Adapter.class) +{{/gson}} +{{#jsonb}} + @JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class) + @JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class) +{{/jsonb}} {{#withXml}} @XmlType(name="{{datatypeWithEnum}}") @XmlEnum({{dataType}}.class) @@ -66,4 +73,39 @@ } {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}{{#enumUnknownDefaultCase}}{{#allowableValues}}{{#enumVars}}{{#-last}}return {{{name}}};{{/-last}}{{/enumVars}}{{/allowableValues}}{{/enumUnknownDefaultCase}}{{^enumUnknownDefaultCase}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/enumUnknownDefaultCase}}{{/isNullable}} } +{{#gson}} + + public static class Adapter extends TypeAdapter<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}> { + @Override + public void write(final JsonWriter jsonWriter, final {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} enumeration) throws IOException { + jsonWriter.value(enumeration.getValue(){{#isUri}}.toASCIIString(){{/isUri}}); + } + + @Override + public {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException { + {{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = {{#isFloat}}(float){{/isFloat}} {{#isUri}}URI.create({{/isUri}}jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{#isUri}}nextString()){{/isUri}}{{^isNumber}}{{^isInteger}}{{^isUri}}{{#isFloat}}nextDouble{{/isFloat}}{{^isFloat}}next{{{dataType}}}{{/isFloat}}(){{/isUri}}{{/isInteger}}{{/isNumber}}; + return {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}}); + } + } +{{/gson}} +{{#jsonb}} + public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> { + @Override + public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'");{{/useNullForUnknownEnumValue}} + } + } + + public static final class Serializer implements JsonbSerializer<{{datatypeWithEnum}}> { + @Override + public void serialize({{datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } +{{/jsonb}} } diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/oneof_interface.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/oneof_interface.mustache new file mode 100644 index 000000000..874a1ba63 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/oneof_interface.mustache @@ -0,0 +1,11 @@ +/** + * {{description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + */{{#isDeprecated}} +@Deprecated{{/isDeprecated}} +{{>additionalOneOfTypeAnnotations}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} +public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { + {{#discriminator}} + {{propertyType}} {{propertyGetter}}(); + {{/discriminator}} +} diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/pojo.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/pojo.mustache index 43d82e905..3f43f0bad 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/pojo.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/pojo.mustache @@ -2,13 +2,30 @@ * {{description}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}} * @deprecated{{/isDeprecated}} */{{#isDeprecated}} -@Deprecated{{/isDeprecated}}{{#discriminator}} -{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}{{^isReleased}} -@Beta{{/isReleased}} -// CHECKSTYLE:OFF -public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcelableModel}}implements Parcelable {{/parcelableModel}}{{^parcelableModel}}{{/parcelableModel}} +@Deprecated{{/isDeprecated}} +{{#swagger1AnnotationLibrary}} +{{#description}} +@ApiModel(description = "{{{.}}}") +{{/description}} +{{/swagger1AnnotationLibrary}} +{{#swagger2AnnotationLibrary}} +{{#description}} +@Schema(description = "{{{.}}}") +{{/description}} +{{/swagger2AnnotationLibrary}} +{{#jackson}} +{{#isClassnameSanitized}} +{{/isClassnameSanitized}} +{{/jackson}} +{{>additionalModelTypeAnnotations}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}{{^isReleased}} +@Beta{{/isReleased}}// CHECKSTYLE:OFF +public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}} // CHECKSTYLE:ON { +{{#serializableModel}} + private static final long serialVersionUID = 1L; + +{{/serializableModel}} {{#vars}} {{#isEnum}} {{^isContainer}} @@ -22,40 +39,40 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela {{/isEnum}} {{#jackson}} @JsonProperty("{{baseName}}") - {{#withXml}} - {{^isContainer}} - @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") - {{/isContainer}} - {{#isContainer}} - {{#isXmlWrapped}} - // items.xmlName={{items.xmlName}} - @JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}") - {{/isXmlWrapped}} - {{/isContainer}} - {{/withXml}} {{/jackson}} {{#withXml}} - {{#isXmlAttribute}} - @XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") - {{/isXmlAttribute}} - {{^isXmlAttribute}} - {{^isContainer}} - @XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") - {{/isContainer}} - {{#isContainer}} - // Is a container wrapped={{isXmlWrapped}} - {{#items}} - // items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}} - // items.example={{example}} items.type={{dataType}} - @XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") - {{/items}} - {{#isXmlWrapped}} - @XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") - {{/isXmlWrapped}} - {{/isContainer}} - {{/isXmlAttribute}} + @Xml{{#isXmlAttribute}}Attribute{{/isXmlAttribute}}{{^isXmlAttribute}}Element{{/isXmlAttribute}}(name = "{{items.xmlName}}{{^items.xmlName}}{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}{{/items.xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}}) + {{#isXmlWrapped}} + @XmlElementWrapper(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}"{{#xmlNamespace}}, namespace = "{{.}}"{{/xmlNamespace}}) + {{/isXmlWrapped}} + {{^isXmlAttribute}} + {{#isDateTime}} + @XmlJavaTypeAdapter(OffsetDateTimeXmlAdapter.class) + {{/isDateTime}} + {{/isXmlAttribute}} {{/withXml}} - private {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}; + {{#gson}} + @SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}}) + {{/gson}} + {{#vendorExtensions.x-field-extra-annotation}} + {{{vendorExtensions.x-field-extra-annotation}}} + {{/vendorExtensions.x-field-extra-annotation}} + {{#vendorExtensions.x-is-jackson-optional-nullable}} + {{#isContainer}} + {{#hasChildren}}protected{{/hasChildren}}{{^hasChildren}}private{{/hasChildren}} JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined(); + {{/isContainer}} + {{^isContainer}} + {{#hasChildren}}protected{{/hasChildren}}{{^hasChildren}}private{{/hasChildren}} JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}}; + {{/isContainer}} + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + {{#isContainer}} + {{#hasChildren}}protected{{/hasChildren}}{{^hasChildren}}private{{/hasChildren}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}; + {{/isContainer}} + {{^isContainer}} + {{#hasChildren}}protected{{/hasChildren}}{{^hasChildren}}private{{/hasChildren}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}; + {{/isContainer}} + {{/vendorExtensions.x-is-jackson-optional-nullable}} {{/vars}} @JsonAnySetter @@ -63,13 +80,24 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela private final Map cloudSdkCustomFields = new LinkedHashMap<>(); {{#parcelableModel}} public {{classname}}() { - {{#parent}} - super(); - {{/parent}} + {{#parent}} + {{#parcelableModel}} + super();{{/parcelableModel}} + {{/parent}} + {{#gson}} + {{#discriminator}} + {{#discriminator.isEnum}} + this.{{{discriminatorName}}} = this.getClass().getSimpleName(); + {{/discriminator.isEnum}} + {{/discriminator}} + {{/gson}} } {{/parcelableModel}} {{^parcelableModel}} {{#pojoConstructorVisibility}} + /** + * Default constructor for {{classname}}. + */ {{pojoConstructorVisibility}} {{classname}}() { {{#parent}}super();{{/parent}} } {{/pojoConstructorVisibility}} {{/parcelableModel}} @@ -99,11 +127,24 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela * @return The same instance of type {@link {{classname}}} */ @Nonnull public {{classname}} add{{nameInPascalCase}}Item( @Nonnull final {{{items.datatypeWithEnum}}} {{name}}Item) { + {{#vendorExtensions.x-is-jackson-optional-nullable}} + if (this.{{name}} == null || !this.{{name}}.isPresent()) { + this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}); + } + try { + this.{{name}}.get().add({{name}}Item); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } + return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} if (this.{{name}} == null) { this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new {{#uniqueItems}}LinkedHashSet{{/uniqueItems}}{{^uniqueItems}}ArrayList{{/uniqueItems}}<>(){{/defaultValue}}; } this.{{name}}.add({{name}}Item); return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} } {{/isArray}} {{#isMap}} @@ -115,9 +156,26 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela * @return The same instance of type {@link {{classname}}} */ @Nonnull public {{classname}} put{{nameInCamelCase}}Item( @Nonnull final String key, {{#items.isNullable}}@Nullable{{/items.isNullable}}{{^items.isNullable}}@Nonnull{{/items.isNullable}} final {{{items.datatypeWithEnum}}} {{name}}Item) { - this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}; + {{#vendorExtensions.x-is-jackson-optional-nullable}} + if (this.{{name}} == null || !this.{{name}}.isPresent()) { + this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}); + } + try { + this.{{name}}.get().put(key, {{name}}Item); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } + return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + {{^required}} + if (this.{{name}} == null) { + this.{{name}} = {{{defaultValue}}}{{^defaultValue}}new HashMap<>(){{/defaultValue}}; + } + {{/required}} this.{{name}}.put(key, {{name}}Item); return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} } {{/isMap}} @@ -136,17 +194,35 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela * maximum: {{.}} {{/maximum}} * @return {{name}} The {{name}} of this {@link {{classname}}} instance. - {{#deprecated}} + {{#deprecated}} * @deprecated - {{/deprecated}} + {{/deprecated}} */ - {{#deprecated}} +{{#deprecated}} @Deprecated - {{/deprecated}} -{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}}{{#vendorExtensions.extraAnnotation}} - {{{vendorExtensions.extraAnnotation}}} -{{/vendorExtensions.extraAnnotation}} - {{#isNullable}}@Nullable{{/isNullable}}{{^isNullable}}@Nonnull{{/isNullable}} public {{{datatypeWithEnum}}} {{getter}}() { +{{/deprecated}} +{{#isNullable}} + @Nullable +{{/isNullable}} +{{^isNullable}} + @Nonnull +{{/isNullable}} +{{#jsonb}} + @JsonbProperty("{{baseName}}") +{{/jsonb}} +{{#useBeanValidation}} +{{>beanValidation}} +{{/useBeanValidation}} +{{#swagger1AnnotationLibrary}} + @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") +{{/swagger1AnnotationLibrary}} +{{#swagger2AnnotationLibrary}} + @Schema({{#example}}example = "{{{.}}}", {{/example}}requiredMode = {{#required}}Schema.RequiredMode.REQUIRED{{/required}}{{^required}}Schema.RequiredMode.NOT_REQUIRED{{/required}}, description = "{{{description}}}") +{{/swagger2AnnotationLibrary}} +{{#vendorExtensions.x-extra-annotation}} + {{{vendorExtensions.x-extra-annotation}}} +{{/vendorExtensions.x-extra-annotation}} + public {{{datatypeWithEnum}}} {{getter}}() { return {{name}}{{#isByteArray}}.clone(){{/isByteArray}}; } {{^isReadOnly}} @@ -206,7 +282,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela {{#parent}} - {{#allVars}} + {{#readWriteVars}} {{#isOverridden}} @Override public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { @@ -220,7 +296,7 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela } {{/isOverridden}} - {{/allVars}} + {{/readWriteVars}} {{/parent}} @Override public boolean equals(@Nullable final java.lang.Object o) { @@ -271,12 +347,23 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela sb.append(" ").append(toIndentedString(super.toString())).append("\n"); {{/parent}} {{#vars}} - sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); + sb.append(" {{name}}: ").append({{#isPassword}}"*"{{/isPassword}}{{^isPassword}}toIndentedString({{name}}){{/isPassword}}).append("\n"); {{/vars}} cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); sb.append("}"); return sb.toString(); } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } {{#supportUrlQuery}} /** @@ -471,18 +558,6 @@ public class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{{#parcela return joiner.toString(); } {{/supportUrlQuery}} - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - {{#parcelableModel}} public void writeToParcel(Parcel out, int flags) { diff --git a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/typeInfoAnnotation.mustache b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/typeInfoAnnotation.mustache index b7f87b12c..a04bcf4fc 100644 --- a/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/typeInfoAnnotation.mustache +++ b/datamodel/openapi/openapi-generator/src/main/resources/openapi-generator/mustache-templates/typeInfoAnnotation.mustache @@ -1,16 +1,18 @@ {{#jackson}} - -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true) -{{#discriminator.mappedModels}} -{{#-first}} +{{#discriminator}} +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "{{{discriminator.propertyBaseName}}}", visible = true) +{{/discriminator}} +{{^discriminator}} +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +{{/discriminator}} @JsonSubTypes({ -{{/-first}} - @JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), -{{#-last}} -}) -{{/-last}} +{{#discriminator.mappedModels}} + @JsonSubTypes.Type(value = {{modelName}}.class{{#discriminator}}, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"{{/discriminator}}), {{/discriminator.mappedModels}} -{{#isClassnameSanitized}} -@JsonTypeName("{{name}}") -{{/isClassnameSanitized}} +{{^discriminator.mappedModels}} +{{#model.oneOf}} + @JsonSubTypes.Type(value = {{.}}.class), +{{/model.oneOf}} +{{/discriminator.mappedModels}} +}) {{/jackson}} \ No newline at end of file diff --git a/datamodel/openapi/openapi-generator/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorIntegrationTest.java b/datamodel/openapi/openapi-generator/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorIntegrationTest.java index 2410f22ff..c2d75fe9f 100644 --- a/datamodel/openapi/openapi-generator/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorIntegrationTest.java +++ b/datamodel/openapi/openapi-generator/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorIntegrationTest.java @@ -9,6 +9,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Map; import java.util.function.Predicate; import org.junit.jupiter.api.io.TempDir; @@ -20,16 +21,24 @@ import com.sap.cloud.sdk.datamodel.openapi.generator.model.GenerationResult; import io.vavr.control.Try; -import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; class DataModelGeneratorIntegrationTest { @RequiredArgsConstructor - @AllArgsConstructor private enum TestCase { + API_CLASS_FOR_AI_SDK( + "api-class-for-ai-sdk", + "sodastore.json", + "com.sap.cloud.sdk.services.builder.api", + "com.sap.cloud.sdk.services.builder.model", + ApiMaturity.RELEASED, + true, + true, + 6, + Map.of("aiSdkConstructor", "true")), API_CLASS_VENDOR_EXTENSION_YAML( "api-class-vendor-extension-yaml", "sodastore.yaml", @@ -37,7 +46,9 @@ private enum TestCase "com.sap.cloud.sdk.services.apiclassvendorextension.model", ApiMaturity.RELEASED, false, - 4), + true, + 4, + Map.of()), API_CLASS_VENDOR_EXTENSION_JSON( "api-class-vendor-extension-json", "sodastore.json", @@ -45,7 +56,9 @@ private enum TestCase "com.sap.cloud.sdk.services.apiclassvendorextension.model", ApiMaturity.RELEASED, false, - 6), + true, + 6, + Map.of()), INPUT_SPEC_WITH_UPPERCASE_FILE_EXTENSION( "input-spec-with-uppercase-file-extension", "sodastore.JSON", @@ -53,15 +66,29 @@ private enum TestCase "com.sap.cloud.sdk.services.uppercasefileextension.model", ApiMaturity.RELEASED, false, - 6), - INPUT_SPEC_WITH_ANYOF_ONEOF( - "input-spec-with-anyof-oneof", - "AggregatorNestedSchemaChild.json", - "com.sap.cloud.sdk.services.anyofoneof.api", - "com.sap.cloud.sdk.services.anyofoneof.model", + true, + 6, + Map.of()), + ONE_OF_INTERFACES_DISABLED( + "oneof-interfaces-disabled", + "sodastore.yaml", + "test", + "test", ApiMaturity.RELEASED, + false, true, - 7), + 8, + Map.of()), + ONE_OF_INTERFACES_ENABLED( + "oneof-interfaces-enabled", + "sodastore.yaml", + "test", + "test", + ApiMaturity.RELEASED, + true, + true, + 8, + Map.of("useOneOfInterfaces", "true")), INPUT_SPEC_WITH_BUILDER( "input-spec-with-builder", "sodastore.JSON", @@ -69,10 +96,43 @@ private enum TestCase "com.sap.cloud.sdk.services.builder.model", ApiMaturity.RELEASED, true, + true, 6, - "builder", - "build", - "private"); + Map + .of( + "pojoBuilderMethodName", + "builder", + "pojoBuildMethodName", + "build", + "pojoConstructorVisibility", + "private")), + REMOVE_OPERATION_ID_PREFIX( + "remove-operation-id-prefix", + "sodastore.json", + "com.sap.cloud.sdk.services.builder.api", + "com.sap.cloud.sdk.services.builder.model", + ApiMaturity.RELEASED, + true, + true, + 6, + Map + .of( + "removeOperationIdPrefix", + "true", + "removeOperationIdPrefixDelimiter", + "\\.", + "removeOperationIdPrefixCount", + "3")), + GENERATE_APIS( + "generate-apis", + "sodastore.yaml", + "test", + "test", + ApiMaturity.RELEASED, + true, + false, + 7, + Map.of()); final String testCaseName; final String inputSpecFileName; @@ -80,10 +140,9 @@ private enum TestCase final String modelPackageName; final ApiMaturity apiMaturity; final boolean anyOfOneOfGenerationEnabled; + final boolean generateApis; final int expectedNumberOfGeneratedFiles; - String methodBuilder = null; - String methodBuild = null; - String constructorVisibility = null; + final Map additionalProperties; } @ParameterizedTest @@ -101,24 +160,23 @@ void integrationTests( final TestCase testCase, @TempDir final Path path ) assertThat(tempOutputDirectory).exists().isReadable().isDirectory(); assertThat(comparisonDirectory).exists().isReadable().isDirectory(); - final GenerationConfiguration generationConfiguration = + final var generationConfiguration = GenerationConfiguration .builder() + // .debugModels(true) enable this for better mustache file debugging .apiPackage(testCase.apiPackageName) + .generateApis(testCase.generateApis) .modelPackage(testCase.modelPackageName) .inputSpec(inputDirectory.resolve(testCase.inputSpecFileName).toAbsolutePath().toString()) .apiMaturity(testCase.apiMaturity) .outputDirectory(tempOutputDirectory.toAbsolutePath().toString()) .withSapCopyrightHeader(true) .oneOfAnyOfGenerationEnabled(testCase.anyOfOneOfGenerationEnabled) - .additionalProperty("useAbstractionForFiles", "true") - .additionalProperty("pojoBuilderMethodName", testCase.methodBuilder) - .additionalProperty("pojoBuildMethodName", testCase.methodBuild) - .additionalProperty("pojoConstructorVisibility", testCase.constructorVisibility) - .build(); + .additionalProperty("useAbstractionForFiles", "true"); + testCase.additionalProperties.forEach(generationConfiguration::additionalProperty); final Try maybeGenerationResult = - new DataModelGenerator().generateDataModel(generationConfiguration); + new DataModelGenerator().generateDataModel(generationConfiguration.build()); assertThat(maybeGenerationResult.get().getGeneratedFiles()).hasSize(testCase.expectedNumberOfGeneratedFiles); @@ -135,12 +193,13 @@ void generateDataModelForComparison( final TestCase testCase ) final Path outputDirectory = getComparisonDirectory(testCase); assertThat(inputDirectory).exists().isReadable().isDirectory(); - assertThat(inputDirectory).exists().isReadable().isDirectory(); + assertThat(outputDirectory).exists().isReadable().isDirectory(); - final GenerationConfiguration generationConfiguration = + final var generationConfiguration = GenerationConfiguration .builder() .apiPackage(testCase.apiPackageName) + .generateApis(testCase.generateApis) .modelPackage(testCase.modelPackageName) .inputSpec(inputDirectory.resolve(testCase.inputSpecFileName).toAbsolutePath().toString()) .apiMaturity(testCase.apiMaturity) @@ -148,13 +207,11 @@ void generateDataModelForComparison( final TestCase testCase ) .deleteOutputDirectory(true) .withSapCopyrightHeader(true) .oneOfAnyOfGenerationEnabled(testCase.anyOfOneOfGenerationEnabled) - .additionalProperty("useAbstractionForFiles", "true") - .additionalProperty("pojoBuilderMethodName", testCase.methodBuilder) - .additionalProperty("pojoBuildMethodName", testCase.methodBuild) - .additionalProperty("pojoConstructorVisibility", testCase.constructorVisibility) - .build(); + .additionalProperty("useAbstractionForFiles", "true"); + testCase.additionalProperties.forEach(generationConfiguration::additionalProperty); - new DataModelGenerator().generateDataModel(generationConfiguration); + GenerationConfiguration build = generationConfiguration.build(); + new DataModelGenerator().generateDataModel(build); } private static Path getInputDirectory( final TestCase testCase ) diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json new file mode 100644 index 000000000..f10d46994 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/input/sodastore.json @@ -0,0 +1,235 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "Soda Store API", + "version": "1.0.0", + "description": "API for managing sodas in a soda store" + }, + "paths": { + "/sodas": { + "get": { + "summary": "Get a list of all sodas", + "x-sap-cloud-sdk-api-name": "AwesomeSodas", + "operationId": "getSodas", + "responses": { + "200": { + "description": "A list of sodas", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Soda" + } + } + } + } + } + } + }, + "post": { + "summary": "Add a new soda to the store", + "x-sap-cloud-sdk-api-name": "AwesomeSoda", + "operationId": "addSoda", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewSoda" + } + } + } + }, + "responses": { + "201": { + "description": "The newly added soda", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Soda" + } + } + } + } + } + } + }, + "/sodas/{sodaId}": { + "get": { + "summary": "Get details of a specific soda", + "operationId": "getSodaById", + "parameters": [ + { + "name": "sodaId", + "in": "path", + "description": "ID of the soda to retrieve", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "The requested soda", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Soda" + } + } + } + }, + "404": { + "description": "Soda not found" + } + } + }, + "put": { + "summary": "Update details of a specific soda", + "operationId": "updateSodaById", + "parameters": [ + { + "name": "sodaId", + "in": "path", + "description": "ID of the soda to update", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateSoda" + } + } + } + }, + "responses": { + "200": { + "description": "The updated soda", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Soda" + } + } + } + }, + "404": { + "description": "Soda not found" + } + } + }, + "delete": { + "summary": "Delete a specific soda from the store", + "operationId": "deleteSodaById", + "parameters": [ + { + "name": "sodaId", + "in": "path", + "description": "ID of the soda to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "Soda successfully deleted" + }, + "404": { + "description": "Soda not found" + } + } + } + } + }, + "components": { + "schemas": { + "Soda": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "brand": { + "type": "string" + }, + "flavor": { + "type": "string" + }, + "price": { + "type": "number", + "format": "float" + } + }, + "required": ["name", "brand", "flavor", "price"] + }, + "NewSoda": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "brand": { + "type": "string" + }, + "zero": { + "type": "boolean" + }, + "since": { + "type": "string", + "format": "date" + }, + "flavor": { + "type": "string" + }, + "price": { + "type": "number", + "format": "float" + } + }, + "required": ["name", "brand", "flavor", "price"] + }, + "UpdateSoda": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "zero": { + "type": "boolean" + }, + "since": { + "type": "string", + "format": "date" + }, + "brand": { + "type": "string" + }, + "flavor": { + "type": "string" + }, + "price": { + "type": "number", + "format": "float" + } + } + } + } + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodaApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodaApi.java new file mode 100644 index 000000000..8f6d7482f --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodaApi.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package com.sap.cloud.sdk.services.builder.api; + +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; +import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; + +import com.sap.cloud.sdk.services.builder.model.NewSoda; +import com.sap.cloud.sdk.services.builder.model.Soda; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import com.google.common.annotations.Beta; + +import com.sap.ai.sdk.core.AiCoreService; + +/** + * Soda Store API in version 1.0.0. + * + * API for managing sodas in a soda store + */ +public class AwesomeSodaApi extends AbstractOpenApiService { + + /** + * Instantiates this API class to invoke operations on the Soda Store API + */ + public AwesomeSodaApi() + { + super(new AiCoreService().getApiClient()); + } + + /** + * Instantiates this API class to invoke operations on the Soda Store API + * + * @param aiCoreService The configured connectivity instance to AI Core + */ + public AwesomeSodaApi( @Nonnull final AiCoreService aiCoreService ) + { + super(aiCoreService.getApiClient()); + } + + /** + *

    Add a new soda to the store

    + *

    + *

    201 - The newly added soda + * @param newSoda + * The value for the parameter newSoda + * @return Soda + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public Soda addSoda( @Nonnull final NewSoda newSoda) throws OpenApiRequestException { + final Object localVarPostBody = newSoda; + + // verify the required parameter 'newSoda' is set + if (newSoda == null) { + throw new OpenApiRequestException("Missing the required parameter 'newSoda' when calling addSoda"); + } + + final String localVarPath = UriComponentsBuilder.fromPath("/sodas").build().toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodasApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodasApi.java new file mode 100644 index 000000000..de3d15ef0 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/AwesomeSodasApi.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package com.sap.cloud.sdk.services.builder.api; + +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; +import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; + +import com.sap.cloud.sdk.services.builder.model.Soda; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import com.google.common.annotations.Beta; + +import com.sap.ai.sdk.core.AiCoreService; + +/** + * Soda Store API in version 1.0.0. + * + * API for managing sodas in a soda store + */ +public class AwesomeSodasApi extends AbstractOpenApiService { + + /** + * Instantiates this API class to invoke operations on the Soda Store API + */ + public AwesomeSodasApi() + { + super(new AiCoreService().getApiClient()); + } + + /** + * Instantiates this API class to invoke operations on the Soda Store API + * + * @param aiCoreService The configured connectivity instance to AI Core + */ + public AwesomeSodasApi( @Nonnull final AiCoreService aiCoreService ) + { + super(aiCoreService.getApiClient()); + } + + /** + *

    Get a list of all sodas

    + *

    + *

    200 - A list of sodas + * @return List<Soda> + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public List getSodas() throws OpenApiRequestException { + final Object localVarPostBody = null; + + final String localVarPath = UriComponentsBuilder.fromPath("/sodas").build().toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference>() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/DefaultApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/DefaultApi.java new file mode 100644 index 000000000..90ca1b254 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/api/DefaultApi.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package com.sap.cloud.sdk.services.builder.api; + +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; +import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; + +import com.sap.cloud.sdk.services.builder.model.Soda; +import com.sap.cloud.sdk.services.builder.model.UpdateSoda; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import com.google.common.annotations.Beta; + +import com.sap.ai.sdk.core.AiCoreService; + +/** + * Soda Store API in version 1.0.0. + * + * API for managing sodas in a soda store + */ +public class DefaultApi extends AbstractOpenApiService { + + /** + * Instantiates this API class to invoke operations on the Soda Store API + */ + public DefaultApi() + { + super(new AiCoreService().getApiClient()); + } + + /** + * Instantiates this API class to invoke operations on the Soda Store API + * + * @param aiCoreService The configured connectivity instance to AI Core + */ + public DefaultApi( @Nonnull final AiCoreService aiCoreService ) + { + super(aiCoreService.getApiClient()); + } + + /** + *

    Delete a specific soda from the store

    + *

    + *

    204 - Soda successfully deleted + *

    404 - Soda not found + * @param sodaId + * ID of the soda to delete + * @return An OpenApiResponse containing the status code of the HttpResponse. + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public OpenApiResponse deleteSodaById( @Nonnull final Long sodaId) throws OpenApiRequestException { + final Object localVarPostBody = null; + + // verify the required parameter 'sodaId' is set + if (sodaId == null) { + throw new OpenApiRequestException("Missing the required parameter 'sodaId' when calling deleteSodaById"); + } + + // create path and map variables + final Map localVarPathParams = new HashMap(); + localVarPathParams.put("sodaId", sodaId); + final String localVarPath = UriComponentsBuilder.fromPath("/sodas/{sodaId}").buildAndExpand(localVarPathParams).toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + apiClient.invokeAPI(localVarPath, HttpMethod.DELETE, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + return new OpenApiResponse(apiClient); + } + /** + *

    Get details of a specific soda

    + *

    + *

    200 - The requested soda + *

    404 - Soda not found + * @param sodaId + * ID of the soda to retrieve + * @return Soda + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public Soda getSodaById( @Nonnull final Long sodaId) throws OpenApiRequestException { + final Object localVarPostBody = null; + + // verify the required parameter 'sodaId' is set + if (sodaId == null) { + throw new OpenApiRequestException("Missing the required parameter 'sodaId' when calling getSodaById"); + } + + // create path and map variables + final Map localVarPathParams = new HashMap(); + localVarPathParams.put("sodaId", sodaId); + final String localVarPath = UriComponentsBuilder.fromPath("/sodas/{sodaId}").buildAndExpand(localVarPathParams).toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + *

    Update details of a specific soda

    + *

    + *

    200 - The updated soda + *

    404 - Soda not found + * @param sodaId + * ID of the soda to update + * @param updateSoda + * The value for the parameter updateSoda + * @return Soda + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public Soda updateSodaById( @Nonnull final Long sodaId, @Nonnull final UpdateSoda updateSoda) throws OpenApiRequestException { + final Object localVarPostBody = updateSoda; + + // verify the required parameter 'sodaId' is set + if (sodaId == null) { + throw new OpenApiRequestException("Missing the required parameter 'sodaId' when calling updateSodaById"); + } + + // verify the required parameter 'updateSoda' is set + if (updateSoda == null) { + throw new OpenApiRequestException("Missing the required parameter 'updateSoda' when calling updateSodaById"); + } + + // create path and map variables + final Map localVarPathParams = new HashMap(); + localVarPathParams.put("sodaId", sodaId); + final String localVarPath = UriComponentsBuilder.fromPath("/sodas/{sodaId}").buildAndExpand(localVarPathParams).toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java new file mode 100644 index 000000000..98a68c017 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.LocalDate; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * NewSoda + */ +// CHECKSTYLE:OFF +public class NewSoda +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("brand") + private String brand; + + @JsonProperty("zero") + private Boolean zero; + + @JsonProperty("since") + private LocalDate since; + + @JsonProperty("flavor") + private String flavor; + + @JsonProperty("price") + private Float price; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link NewSoda} instance and return the same instance. + * + * @param name The name of this {@link NewSoda} + * @return The same instance of this {@link NewSoda} class + */ + @Nonnull public NewSoda name( @Nonnull final String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name The name of this {@link NewSoda} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link NewSoda} instance. + * + * @param name The name of this {@link NewSoda} + */ + public void setName( @Nonnull final String name) { + this.name = name; + } + + /** + * Set the brand of this {@link NewSoda} instance and return the same instance. + * + * @param brand The brand of this {@link NewSoda} + * @return The same instance of this {@link NewSoda} class + */ + @Nonnull public NewSoda brand( @Nonnull final String brand) { + this.brand = brand; + return this; + } + + /** + * Get brand + * @return brand The brand of this {@link NewSoda} instance. + */ + @Nonnull + public String getBrand() { + return brand; + } + + /** + * Set the brand of this {@link NewSoda} instance. + * + * @param brand The brand of this {@link NewSoda} + */ + public void setBrand( @Nonnull final String brand) { + this.brand = brand; + } + + /** + * Set the zero of this {@link NewSoda} instance and return the same instance. + * + * @param zero The zero of this {@link NewSoda} + * @return The same instance of this {@link NewSoda} class + */ + @Nonnull public NewSoda zero( @Nullable final Boolean zero) { + this.zero = zero; + return this; + } + + /** + * Get zero + * @return zero The zero of this {@link NewSoda} instance. + */ + @Nonnull + public Boolean isZero() { + return zero; + } + + /** + * Set the zero of this {@link NewSoda} instance. + * + * @param zero The zero of this {@link NewSoda} + */ + public void setZero( @Nullable final Boolean zero) { + this.zero = zero; + } + + /** + * Set the since of this {@link NewSoda} instance and return the same instance. + * + * @param since The since of this {@link NewSoda} + * @return The same instance of this {@link NewSoda} class + */ + @Nonnull public NewSoda since( @Nullable final LocalDate since) { + this.since = since; + return this; + } + + /** + * Get since + * @return since The since of this {@link NewSoda} instance. + */ + @Nonnull + public LocalDate getSince() { + return since; + } + + /** + * Set the since of this {@link NewSoda} instance. + * + * @param since The since of this {@link NewSoda} + */ + public void setSince( @Nullable final LocalDate since) { + this.since = since; + } + + /** + * Set the flavor of this {@link NewSoda} instance and return the same instance. + * + * @param flavor The flavor of this {@link NewSoda} + * @return The same instance of this {@link NewSoda} class + */ + @Nonnull public NewSoda flavor( @Nonnull final String flavor) { + this.flavor = flavor; + return this; + } + + /** + * Get flavor + * @return flavor The flavor of this {@link NewSoda} instance. + */ + @Nonnull + public String getFlavor() { + return flavor; + } + + /** + * Set the flavor of this {@link NewSoda} instance. + * + * @param flavor The flavor of this {@link NewSoda} + */ + public void setFlavor( @Nonnull final String flavor) { + this.flavor = flavor; + } + + /** + * Set the price of this {@link NewSoda} instance and return the same instance. + * + * @param price The price of this {@link NewSoda} + * @return The same instance of this {@link NewSoda} class + */ + @Nonnull public NewSoda price( @Nonnull final Float price) { + this.price = price; + return this; + } + + /** + * Get price + * @return price The price of this {@link NewSoda} instance. + */ + @Nonnull + public Float getPrice() { + return price; + } + + /** + * Set the price of this {@link NewSoda} instance. + * + * @param price The price of this {@link NewSoda} + */ + public void setPrice( @Nonnull final Float price) { + this.price = price; + } + + /** + * Get the names of the unrecognizable properties of the {@link NewSoda}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link NewSoda} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("NewSoda has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link NewSoda} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final NewSoda newSoda = (NewSoda) o; + return Objects.equals(this.cloudSdkCustomFields, newSoda.cloudSdkCustomFields) && + Objects.equals(this.name, newSoda.name) && + Objects.equals(this.brand, newSoda.brand) && + Objects.equals(this.zero, newSoda.zero) && + Objects.equals(this.since, newSoda.since) && + Objects.equals(this.flavor, newSoda.flavor) && + Objects.equals(this.price, newSoda.price); + } + + @Override + public int hashCode() { + return Objects.hash(name, brand, zero, since, flavor, price, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class NewSoda {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" zero: ").append(toIndentedString(zero)).append("\n"); + sb.append(" since: ").append(toIndentedString(since)).append("\n"); + sb.append(" flavor: ").append(toIndentedString(flavor)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java new file mode 100644 index 000000000..86941bb48 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/Soda.java @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Soda + */ +// CHECKSTYLE:OFF +public class Soda +// CHECKSTYLE:ON +{ + @JsonProperty("id") + private Long id; + + @JsonProperty("name") + private String name; + + @JsonProperty("brand") + private String brand; + + @JsonProperty("flavor") + private String flavor; + + @JsonProperty("price") + private Float price; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the id of this {@link Soda} instance and return the same instance. + * + * @param id The id of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda id( @Nullable final Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id The id of this {@link Soda} instance. + */ + @Nonnull + public Long getId() { + return id; + } + + /** + * Set the id of this {@link Soda} instance. + * + * @param id The id of this {@link Soda} + */ + public void setId( @Nullable final Long id) { + this.id = id; + } + + /** + * Set the name of this {@link Soda} instance and return the same instance. + * + * @param name The name of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda name( @Nonnull final String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name The name of this {@link Soda} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link Soda} instance. + * + * @param name The name of this {@link Soda} + */ + public void setName( @Nonnull final String name) { + this.name = name; + } + + /** + * Set the brand of this {@link Soda} instance and return the same instance. + * + * @param brand The brand of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda brand( @Nonnull final String brand) { + this.brand = brand; + return this; + } + + /** + * Get brand + * @return brand The brand of this {@link Soda} instance. + */ + @Nonnull + public String getBrand() { + return brand; + } + + /** + * Set the brand of this {@link Soda} instance. + * + * @param brand The brand of this {@link Soda} + */ + public void setBrand( @Nonnull final String brand) { + this.brand = brand; + } + + /** + * Set the flavor of this {@link Soda} instance and return the same instance. + * + * @param flavor The flavor of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda flavor( @Nonnull final String flavor) { + this.flavor = flavor; + return this; + } + + /** + * Get flavor + * @return flavor The flavor of this {@link Soda} instance. + */ + @Nonnull + public String getFlavor() { + return flavor; + } + + /** + * Set the flavor of this {@link Soda} instance. + * + * @param flavor The flavor of this {@link Soda} + */ + public void setFlavor( @Nonnull final String flavor) { + this.flavor = flavor; + } + + /** + * Set the price of this {@link Soda} instance and return the same instance. + * + * @param price The price of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda price( @Nonnull final Float price) { + this.price = price; + return this; + } + + /** + * Get price + * @return price The price of this {@link Soda} instance. + */ + @Nonnull + public Float getPrice() { + return price; + } + + /** + * Set the price of this {@link Soda} instance. + * + * @param price The price of this {@link Soda} + */ + public void setPrice( @Nonnull final Float price) { + this.price = price; + } + + /** + * Get the names of the unrecognizable properties of the {@link Soda}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Soda} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Soda has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Soda} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Soda soda = (Soda) o; + return Objects.equals(this.cloudSdkCustomFields, soda.cloudSdkCustomFields) && + Objects.equals(this.id, soda.id) && + Objects.equals(this.name, soda.name) && + Objects.equals(this.brand, soda.brand) && + Objects.equals(this.flavor, soda.flavor) && + Objects.equals(this.price, soda.price); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, brand, flavor, price, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Soda {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" flavor: ").append(toIndentedString(flavor)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java new file mode 100644 index 000000000..bad1c631c --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-for-ai-sdk/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.LocalDate; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * UpdateSoda + */ +// CHECKSTYLE:OFF +public class UpdateSoda +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("zero") + private Boolean zero; + + @JsonProperty("since") + private LocalDate since; + + @JsonProperty("brand") + private String brand; + + @JsonProperty("flavor") + private String flavor; + + @JsonProperty("price") + private Float price; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link UpdateSoda} instance and return the same instance. + * + * @param name The name of this {@link UpdateSoda} + * @return The same instance of this {@link UpdateSoda} class + */ + @Nonnull public UpdateSoda name( @Nullable final String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name The name of this {@link UpdateSoda} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link UpdateSoda} instance. + * + * @param name The name of this {@link UpdateSoda} + */ + public void setName( @Nullable final String name) { + this.name = name; + } + + /** + * Set the zero of this {@link UpdateSoda} instance and return the same instance. + * + * @param zero The zero of this {@link UpdateSoda} + * @return The same instance of this {@link UpdateSoda} class + */ + @Nonnull public UpdateSoda zero( @Nullable final Boolean zero) { + this.zero = zero; + return this; + } + + /** + * Get zero + * @return zero The zero of this {@link UpdateSoda} instance. + */ + @Nonnull + public Boolean isZero() { + return zero; + } + + /** + * Set the zero of this {@link UpdateSoda} instance. + * + * @param zero The zero of this {@link UpdateSoda} + */ + public void setZero( @Nullable final Boolean zero) { + this.zero = zero; + } + + /** + * Set the since of this {@link UpdateSoda} instance and return the same instance. + * + * @param since The since of this {@link UpdateSoda} + * @return The same instance of this {@link UpdateSoda} class + */ + @Nonnull public UpdateSoda since( @Nullable final LocalDate since) { + this.since = since; + return this; + } + + /** + * Get since + * @return since The since of this {@link UpdateSoda} instance. + */ + @Nonnull + public LocalDate getSince() { + return since; + } + + /** + * Set the since of this {@link UpdateSoda} instance. + * + * @param since The since of this {@link UpdateSoda} + */ + public void setSince( @Nullable final LocalDate since) { + this.since = since; + } + + /** + * Set the brand of this {@link UpdateSoda} instance and return the same instance. + * + * @param brand The brand of this {@link UpdateSoda} + * @return The same instance of this {@link UpdateSoda} class + */ + @Nonnull public UpdateSoda brand( @Nullable final String brand) { + this.brand = brand; + return this; + } + + /** + * Get brand + * @return brand The brand of this {@link UpdateSoda} instance. + */ + @Nonnull + public String getBrand() { + return brand; + } + + /** + * Set the brand of this {@link UpdateSoda} instance. + * + * @param brand The brand of this {@link UpdateSoda} + */ + public void setBrand( @Nullable final String brand) { + this.brand = brand; + } + + /** + * Set the flavor of this {@link UpdateSoda} instance and return the same instance. + * + * @param flavor The flavor of this {@link UpdateSoda} + * @return The same instance of this {@link UpdateSoda} class + */ + @Nonnull public UpdateSoda flavor( @Nullable final String flavor) { + this.flavor = flavor; + return this; + } + + /** + * Get flavor + * @return flavor The flavor of this {@link UpdateSoda} instance. + */ + @Nonnull + public String getFlavor() { + return flavor; + } + + /** + * Set the flavor of this {@link UpdateSoda} instance. + * + * @param flavor The flavor of this {@link UpdateSoda} + */ + public void setFlavor( @Nullable final String flavor) { + this.flavor = flavor; + } + + /** + * Set the price of this {@link UpdateSoda} instance and return the same instance. + * + * @param price The price of this {@link UpdateSoda} + * @return The same instance of this {@link UpdateSoda} class + */ + @Nonnull public UpdateSoda price( @Nullable final Float price) { + this.price = price; + return this; + } + + /** + * Get price + * @return price The price of this {@link UpdateSoda} instance. + */ + @Nonnull + public Float getPrice() { + return price; + } + + /** + * Set the price of this {@link UpdateSoda} instance. + * + * @param price The price of this {@link UpdateSoda} + */ + public void setPrice( @Nullable final Float price) { + this.price = price; + } + + /** + * Get the names of the unrecognizable properties of the {@link UpdateSoda}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link UpdateSoda} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("UpdateSoda has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link UpdateSoda} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final UpdateSoda updateSoda = (UpdateSoda) o; + return Objects.equals(this.cloudSdkCustomFields, updateSoda.cloudSdkCustomFields) && + Objects.equals(this.name, updateSoda.name) && + Objects.equals(this.zero, updateSoda.zero) && + Objects.equals(this.since, updateSoda.since) && + Objects.equals(this.brand, updateSoda.brand) && + Objects.equals(this.flavor, updateSoda.flavor) && + Objects.equals(this.price, updateSoda.price); + } + + @Override + public int hashCode() { + return Objects.hash(name, zero, since, brand, flavor, price, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class UpdateSoda {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" zero: ").append(toIndentedString(zero)).append("\n"); + sb.append(" since: ").append(toIndentedString(since)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" flavor: ").append(toIndentedString(flavor)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java index fcd71eef3..65ae0c16d 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java @@ -16,11 +16,11 @@ package com.sap.cloud.sdk.services.apiclassvendorextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -28,12 +28,10 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import java.time.LocalDate; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -82,7 +80,8 @@ public class NewSoda * Get name * @return name The name of this {@link NewSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -110,7 +109,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link NewSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -138,7 +138,8 @@ public void setBrand( @Nonnull final String brand) { * Get zero * @return zero The zero of this {@link NewSoda} instance. */ - @Nonnull public Boolean isZero() { + @Nonnull + public Boolean isZero() { return zero; } @@ -166,7 +167,8 @@ public void setZero( @Nullable final Boolean zero) { * Get since * @return since The since of this {@link NewSoda} instance. */ - @Nonnull public LocalDate getSince() { + @Nonnull + public LocalDate getSince() { return since; } @@ -194,7 +196,8 @@ public void setSince( @Nullable final LocalDate since) { * Get flavor * @return flavor The flavor of this {@link NewSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -222,7 +225,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link NewSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -321,6 +325,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java index febbd2475..fb29e78ee 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.apiclassvendorextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -78,7 +76,8 @@ public class Soda * Get id * @return id The id of this {@link Soda} instance. */ - @Nonnull public Long getId() { + @Nonnull + public Long getId() { return id; } @@ -106,7 +105,8 @@ public void setId( @Nullable final Long id) { * Get name * @return name The name of this {@link Soda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -134,7 +134,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link Soda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -162,7 +163,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link Soda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -190,7 +192,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link Soda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -287,6 +290,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java index 0beed4af4..8a543cf92 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-json/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java @@ -16,11 +16,11 @@ package com.sap.cloud.sdk.services.apiclassvendorextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -28,12 +28,10 @@ import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; import java.time.LocalDate; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -82,7 +80,8 @@ public class UpdateSoda * Get name * @return name The name of this {@link UpdateSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -110,7 +109,8 @@ public void setName( @Nullable final String name) { * Get zero * @return zero The zero of this {@link UpdateSoda} instance. */ - @Nonnull public Boolean isZero() { + @Nonnull + public Boolean isZero() { return zero; } @@ -138,7 +138,8 @@ public void setZero( @Nullable final Boolean zero) { * Get since * @return since The since of this {@link UpdateSoda} instance. */ - @Nonnull public LocalDate getSince() { + @Nonnull + public LocalDate getSince() { return since; } @@ -166,7 +167,8 @@ public void setSince( @Nullable final LocalDate since) { * Get brand * @return brand The brand of this {@link UpdateSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -194,7 +196,8 @@ public void setBrand( @Nullable final String brand) { * Get flavor * @return flavor The flavor of this {@link UpdateSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -222,7 +225,8 @@ public void setFlavor( @Nullable final String flavor) { * Get price * @return price The price of this {@link UpdateSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -321,6 +325,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java index ec3318c33..2622c27a6 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/NewSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.apiclassvendorextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -75,7 +73,8 @@ public class NewSoda * Get name * @return name The name of this {@link NewSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -103,7 +102,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link NewSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -131,7 +131,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link NewSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -159,7 +160,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link NewSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,6 +256,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java index febbd2475..fb29e78ee 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/Soda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.apiclassvendorextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -78,7 +76,8 @@ public class Soda * Get id * @return id The id of this {@link Soda} instance. */ - @Nonnull public Long getId() { + @Nonnull + public Long getId() { return id; } @@ -106,7 +105,8 @@ public void setId( @Nullable final Long id) { * Get name * @return name The name of this {@link Soda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -134,7 +134,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link Soda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -162,7 +163,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link Soda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -190,7 +192,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link Soda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -287,6 +290,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java index cde2b37e7..28ab26bc0 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/api-class-vendor-extension-yaml/output/com/sap/cloud/sdk/services/apiclassvendorextension/model/UpdateSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.apiclassvendorextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -75,7 +73,8 @@ public class UpdateSoda * Get name * @return name The name of this {@link UpdateSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -103,7 +102,8 @@ public void setName( @Nullable final String name) { * Get brand * @return brand The brand of this {@link UpdateSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -131,7 +131,8 @@ public void setBrand( @Nullable final String brand) { * Get flavor * @return flavor The flavor of this {@link UpdateSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -159,7 +160,8 @@ public void setFlavor( @Nullable final String flavor) { * Get price * @return price The price of this {@link UpdateSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,6 +256,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/input/sodastore.yaml b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/input/sodastore.yaml new file mode 100644 index 000000000..470276795 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/input/sodastore.yaml @@ -0,0 +1,58 @@ +openapi: 3.0.0 +info: + title: Soda Store API + version: 1.0.0 + description: API for managing sodas in a soda store +paths: + /sodas: + get: + summary: Get a list of all sodas + operationId: getSodas + responses: + '200': + description: A list of sodas + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/OneOf' +components: + schemas: + OneOfWithDiscriminatorAndMapping: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + mapping: + Cola: '#/components/schemas/Cola' + Fanta: '#/components/schemas/Fanta' + OneOfWithDiscriminator: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + OneOf: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AnyOf: + anyOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AllOf: + allOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + Cola: + type: object + properties: + sodaType: + type: string + Fanta: + type: object + properties: + sodaType: + type: string diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/RootObject.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/AllOf.java similarity index 57% rename from datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/RootObject.java rename to datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/AllOf.java index ab58f486e..a2c60509f 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/RootObject.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/AllOf.java @@ -3,8 +3,8 @@ */ /* - * Sample API - * API for managing root and child objects + * Soda Store API + * API for managing sodas in a soda store * * The version of the OpenAPI document: 1.0.0 * @@ -14,89 +14,72 @@ * Do not edit the class manually. */ -package com.sap.cloud.sdk.services.anyofoneof.model; +package test; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import com.sap.cloud.sdk.services.anyofoneof.model.RootObjectQuestionsInner; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; /** - * RootObject + * AllOf */ // CHECKSTYLE:OFF -public class RootObject +public class AllOf // CHECKSTYLE:ON { - @JsonProperty("questions") - private List questions = new ArrayList<>(); + @JsonProperty("sodaType") + private String sodaType; @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); /** - * Set the questions of this {@link RootObject} instance and return the same instance. + * Set the sodaType of this {@link AllOf} instance and return the same instance. * - * @param questions The questions of this {@link RootObject} - * @return The same instance of this {@link RootObject} class + * @param sodaType The sodaType of this {@link AllOf} + * @return The same instance of this {@link AllOf} class */ - @Nonnull public RootObject questions( @Nullable final List questions) { - this.questions = questions; - return this; - } - /** - * Add one questions instance to this {@link RootObject}. - * @param questionsItem The questions that should be added - * @return The same instance of type {@link RootObject} - */ - @Nonnull public RootObject addQuestionsItem( @Nonnull final RootObjectQuestionsInner questionsItem) { - if (this.questions == null) { - this.questions = new ArrayList<>(); - } - this.questions.add(questionsItem); + @Nonnull public AllOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; return this; } /** - * Get questions - * @return questions The questions of this {@link RootObject} instance. + * Get sodaType + * @return sodaType The sodaType of this {@link AllOf} instance. */ - @Nonnull public List getQuestions() { - return questions; + @Nonnull + public String getSodaType() { + return sodaType; } /** - * Set the questions of this {@link RootObject} instance. + * Set the sodaType of this {@link AllOf} instance. * - * @param questions The questions of this {@link RootObject} + * @param sodaType The sodaType of this {@link AllOf} */ - public void setQuestions( @Nullable final List questions) { - this.questions = questions; + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; } /** - * Get the names of the unrecognizable properties of the {@link RootObject}. + * Get the names of the unrecognizable properties of the {@link AllOf}. * @return The set of properties names */ @JsonIgnore @@ -106,7 +89,7 @@ public Set getCustomFieldNames() { } /** - * Get the value of an unrecognizable property of this {@link RootObject} instance. + * Get the value of an unrecognizable property of this {@link AllOf} instance. * @param name The name of the property * @return The value of the property * @throws NoSuchElementException If no property with the given name could be found. @@ -114,13 +97,13 @@ public Set getCustomFieldNames() { @Nullable public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { if( !cloudSdkCustomFields.containsKey(name) ) { - throw new NoSuchElementException("RootObject has no field with name '" + name + "'."); + throw new NoSuchElementException("AllOf has no field with name '" + name + "'."); } return cloudSdkCustomFields.get(name); } /** - * Set an unrecognizable property of this {@link RootObject} instance. If the map previously contained a mapping + * Set an unrecognizable property of this {@link AllOf} instance. If the map previously contained a mapping * for the key, the old value is replaced by the specified value. * @param customFieldName The name of the property * @param customFieldValue The value of the property @@ -140,21 +123,21 @@ public boolean equals(@Nullable final java.lang.Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final RootObject rootObject = (RootObject) o; - return Objects.equals(this.cloudSdkCustomFields, rootObject.cloudSdkCustomFields) && - Objects.equals(this.questions, rootObject.questions); + final AllOf allOf = (AllOf) o; + return Objects.equals(this.cloudSdkCustomFields, allOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, allOf.sodaType); } @Override public int hashCode() { - return Objects.hash(questions, cloudSdkCustomFields); + return Objects.hash(sodaType, cloudSdkCustomFields); } @Override @Nonnull public String toString() { final StringBuilder sb = new StringBuilder(); - sb.append("class RootObject {\n"); - sb.append(" questions: ").append(toIndentedString(questions)).append("\n"); + sb.append("class AllOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); sb.append("}"); return sb.toString(); @@ -171,6 +154,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/AnyOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/AnyOf.java new file mode 100644 index 000000000..879569438 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/AnyOf.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * AnyOf + */ +// CHECKSTYLE:OFF +public class AnyOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link AnyOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull public AnyOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link AnyOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link AnyOf} instance. + * + * @param sodaType The sodaType of this {@link AnyOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link AnyOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AnyOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AnyOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AnyOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AnyOf anyOf = (AnyOf) o; + return Objects.equals(this.cloudSdkCustomFields, anyOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, anyOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/Cola.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/Cola.java new file mode 100644 index 000000000..a2adbf686 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/Cola.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Cola + */ +// CHECKSTYLE:OFF +public class Cola +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link Cola} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull public Cola sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link Cola} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link Cola} instance. + * + * @param sodaType The sodaType of this {@link Cola} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link Cola}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Cola} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Cola has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Cola} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Cola cola = (Cola) o; + return Objects.equals(this.cloudSdkCustomFields, cola.cloudSdkCustomFields) && + Objects.equals(this.sodaType, cola.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Cola {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/Fanta.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/Fanta.java new file mode 100644 index 000000000..c6359bba1 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/Fanta.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Fanta + */ +// CHECKSTYLE:OFF +public class Fanta +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link Fanta} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull public Fanta sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link Fanta} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link Fanta} instance. + * + * @param sodaType The sodaType of this {@link Fanta} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link Fanta}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Fanta} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Fanta has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Fanta} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Fanta fanta = (Fanta) o; + return Objects.equals(this.cloudSdkCustomFields, fanta.cloudSdkCustomFields) && + Objects.equals(this.sodaType, fanta.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Fanta {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOf.java new file mode 100644 index 000000000..7ad1e3e0a --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOf.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOf + */ +// CHECKSTYLE:OFF +public class OneOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link OneOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link OneOf} + * @return The same instance of this {@link OneOf} class + */ + @Nonnull public OneOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link OneOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link OneOf} instance. + * + * @param sodaType The sodaType of this {@link OneOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link OneOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OneOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OneOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OneOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OneOf oneOf = (OneOf) o; + return Objects.equals(this.cloudSdkCustomFields, oneOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, oneOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OneOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOfWithDiscriminator.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOfWithDiscriminator.java new file mode 100644 index 000000000..883ee607c --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOfWithDiscriminator.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOfWithDiscriminator + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class, name = "Cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "Fanta"), +}) +// CHECKSTYLE:OFF +public class OneOfWithDiscriminator +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link OneOfWithDiscriminator} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminator} + * @return The same instance of this {@link OneOfWithDiscriminator} class + */ + @Nonnull public OneOfWithDiscriminator sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link OneOfWithDiscriminator} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link OneOfWithDiscriminator} instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminator} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link OneOfWithDiscriminator}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OneOfWithDiscriminator} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OneOfWithDiscriminator has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OneOfWithDiscriminator} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OneOfWithDiscriminator oneOfWithDiscriminator = (OneOfWithDiscriminator) o; + return Objects.equals(this.cloudSdkCustomFields, oneOfWithDiscriminator.cloudSdkCustomFields) && + Objects.equals(this.sodaType, oneOfWithDiscriminator.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OneOfWithDiscriminator {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOfWithDiscriminatorAndMapping.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOfWithDiscriminatorAndMapping.java new file mode 100644 index 000000000..f5f8c4ebc --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/generate-apis/output/test/OneOfWithDiscriminatorAndMapping.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOfWithDiscriminatorAndMapping + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class, name = "Cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "Fanta"), +}) +// CHECKSTYLE:OFF +public class OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link OneOfWithDiscriminatorAndMapping} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminatorAndMapping} + * @return The same instance of this {@link OneOfWithDiscriminatorAndMapping} class + */ + @Nonnull public OneOfWithDiscriminatorAndMapping sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link OneOfWithDiscriminatorAndMapping} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link OneOfWithDiscriminatorAndMapping} instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminatorAndMapping} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link OneOfWithDiscriminatorAndMapping}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OneOfWithDiscriminatorAndMapping} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OneOfWithDiscriminatorAndMapping has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OneOfWithDiscriminatorAndMapping} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OneOfWithDiscriminatorAndMapping oneOfWithDiscriminatorAndMapping = (OneOfWithDiscriminatorAndMapping) o; + return Objects.equals(this.cloudSdkCustomFields, oneOfWithDiscriminatorAndMapping.cloudSdkCustomFields) && + Objects.equals(this.sodaType, oneOfWithDiscriminatorAndMapping.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OneOfWithDiscriminatorAndMapping {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/input/AggregatorNestedSchemaChild.json b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/input/AggregatorNestedSchemaChild.json deleted file mode 100644 index bfa73118b..000000000 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/input/AggregatorNestedSchemaChild.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "x-sap-api-type": "REST", - "x-sap-shortText": "This is a sample API to test the Cloud SDK's OpenAPI generator.", - "x-sap-stateInfo": { - "state": "Active" - }, - "openapi": "3.0.3", - "info": { - "title": "Sample API", - "version": "1.0.0", - "description": "API for managing root and child objects" - }, - "paths": { - "/some/endpoint": { - "post": { - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RootObject" - } - } - } - }, - "responses": { - "201": { - "description": "Something was created.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RootObject" - } - } - } - }, - "400": { - "description": "Request was invalid." - }, - "401": { - "description": "Authentication Error" - } - } - } - } - }, - "components": { - "schemas": { - "RootObject": { - "type": "object", - "properties": { - "questions": { - "type": "array", - "items": { - "oneOf": [ - { - "$ref": "#/components/schemas/ChildObject1" - }, - { - "$ref": "#/components/schemas/ChildObject2" - }, - { - "$ref": "#/components/schemas/ChildObject3" - } - ] - } - } - } - }, - "ChildObject1": { - "allOf": [ - { - "$ref": "#/components/schemas/NestedChildObject" - }, - { - "type": "string" - } - ] - }, - "ChildObject2": { - "oneOf": [ - { - "$ref": "#/components/schemas/NestedChildObject" - }, - { - "type": "string" - } - ] - }, - "ChildObject3": { - "anyOf": [ - { - "$ref": "#/components/schemas/NestedChildObject" - }, - { - "type": "string" - } - ] - }, - "NestedChildObject": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "type": { - "type": "string" - }, - "text": { - "type": "string" - } - } - } - } - } -} \ No newline at end of file diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject1.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject1.java deleted file mode 100644 index cc169338f..000000000 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject1.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. - */ - -/* - * Sample API - * API for managing root and child objects - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sap.cloud.sdk.services.anyofoneof.model; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * ChildObject1 - */ -// CHECKSTYLE:OFF -public class ChildObject1 -// CHECKSTYLE:ON -{ - @JsonProperty("id") - private String id; - - @JsonProperty("type") - private String type; - - @JsonProperty("text") - private String text; - - @JsonAnySetter - @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** - * Set the id of this {@link ChildObject1} instance and return the same instance. - * - * @param id The id of this {@link ChildObject1} - * @return The same instance of this {@link ChildObject1} class - */ - @Nonnull public ChildObject1 id( @Nullable final String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id The id of this {@link ChildObject1} instance. - */ - @Nonnull public String getId() { - return id; - } - - /** - * Set the id of this {@link ChildObject1} instance. - * - * @param id The id of this {@link ChildObject1} - */ - public void setId( @Nullable final String id) { - this.id = id; - } - - /** - * Set the type of this {@link ChildObject1} instance and return the same instance. - * - * @param type The type of this {@link ChildObject1} - * @return The same instance of this {@link ChildObject1} class - */ - @Nonnull public ChildObject1 type( @Nullable final String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type The type of this {@link ChildObject1} instance. - */ - @Nonnull public String getType() { - return type; - } - - /** - * Set the type of this {@link ChildObject1} instance. - * - * @param type The type of this {@link ChildObject1} - */ - public void setType( @Nullable final String type) { - this.type = type; - } - - /** - * Set the text of this {@link ChildObject1} instance and return the same instance. - * - * @param text The text of this {@link ChildObject1} - * @return The same instance of this {@link ChildObject1} class - */ - @Nonnull public ChildObject1 text( @Nullable final String text) { - this.text = text; - return this; - } - - /** - * Get text - * @return text The text of this {@link ChildObject1} instance. - */ - @Nonnull public String getText() { - return text; - } - - /** - * Set the text of this {@link ChildObject1} instance. - * - * @param text The text of this {@link ChildObject1} - */ - public void setText( @Nullable final String text) { - this.text = text; - } - - /** - * Get the names of the unrecognizable properties of the {@link ChildObject1}. - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link ChildObject1} instance. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { - if( !cloudSdkCustomFields.containsKey(name) ) { - throw new NoSuchElementException("ChildObject1 has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Set an unrecognizable property of this {@link ChildObject1} instance. If the map previously contained a mapping - * for the key, the old value is replaced by the specified value. - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) - { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ChildObject1 childObject1 = (ChildObject1) o; - return Objects.equals(this.cloudSdkCustomFields, childObject1.cloudSdkCustomFields) && - Objects.equals(this.id, childObject1.id) && - Objects.equals(this.type, childObject1.type) && - Objects.equals(this.text, childObject1.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, text, cloudSdkCustomFields); - } - - @Override - @Nonnull public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class ChildObject1 {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" text: ").append(toIndentedString(text)).append("\n"); - cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - -} - diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject2.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject2.java deleted file mode 100644 index 32affc7cc..000000000 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject2.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. - */ - -/* - * Sample API - * API for managing root and child objects - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sap.cloud.sdk.services.anyofoneof.model; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import com.sap.cloud.sdk.services.anyofoneof.model.NestedChildObject; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * ChildObject2 - */ -// CHECKSTYLE:OFF -public class ChildObject2 -// CHECKSTYLE:ON -{ - @JsonProperty("id") - private String id; - - @JsonProperty("type") - private String type; - - @JsonProperty("text") - private String text; - - @JsonAnySetter - @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** - * Set the id of this {@link ChildObject2} instance and return the same instance. - * - * @param id The id of this {@link ChildObject2} - * @return The same instance of this {@link ChildObject2} class - */ - @Nonnull public ChildObject2 id( @Nullable final String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id The id of this {@link ChildObject2} instance. - */ - @Nonnull public String getId() { - return id; - } - - /** - * Set the id of this {@link ChildObject2} instance. - * - * @param id The id of this {@link ChildObject2} - */ - public void setId( @Nullable final String id) { - this.id = id; - } - - /** - * Set the type of this {@link ChildObject2} instance and return the same instance. - * - * @param type The type of this {@link ChildObject2} - * @return The same instance of this {@link ChildObject2} class - */ - @Nonnull public ChildObject2 type( @Nullable final String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type The type of this {@link ChildObject2} instance. - */ - @Nonnull public String getType() { - return type; - } - - /** - * Set the type of this {@link ChildObject2} instance. - * - * @param type The type of this {@link ChildObject2} - */ - public void setType( @Nullable final String type) { - this.type = type; - } - - /** - * Set the text of this {@link ChildObject2} instance and return the same instance. - * - * @param text The text of this {@link ChildObject2} - * @return The same instance of this {@link ChildObject2} class - */ - @Nonnull public ChildObject2 text( @Nullable final String text) { - this.text = text; - return this; - } - - /** - * Get text - * @return text The text of this {@link ChildObject2} instance. - */ - @Nonnull public String getText() { - return text; - } - - /** - * Set the text of this {@link ChildObject2} instance. - * - * @param text The text of this {@link ChildObject2} - */ - public void setText( @Nullable final String text) { - this.text = text; - } - - /** - * Get the names of the unrecognizable properties of the {@link ChildObject2}. - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link ChildObject2} instance. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { - if( !cloudSdkCustomFields.containsKey(name) ) { - throw new NoSuchElementException("ChildObject2 has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Set an unrecognizable property of this {@link ChildObject2} instance. If the map previously contained a mapping - * for the key, the old value is replaced by the specified value. - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) - { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ChildObject2 childObject2 = (ChildObject2) o; - return Objects.equals(this.cloudSdkCustomFields, childObject2.cloudSdkCustomFields) && - Objects.equals(this.id, childObject2.id) && - Objects.equals(this.type, childObject2.type) && - Objects.equals(this.text, childObject2.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, text, cloudSdkCustomFields); - } - - @Override - @Nonnull public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class ChildObject2 {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" text: ").append(toIndentedString(text)).append("\n"); - cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - -} - diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject3.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject3.java deleted file mode 100644 index 1d5f13a2b..000000000 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/ChildObject3.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. - */ - -/* - * Sample API - * API for managing root and child objects - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sap.cloud.sdk.services.anyofoneof.model; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import com.sap.cloud.sdk.services.anyofoneof.model.NestedChildObject; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * ChildObject3 - */ -// CHECKSTYLE:OFF -public class ChildObject3 -// CHECKSTYLE:ON -{ - @JsonProperty("id") - private String id; - - @JsonProperty("type") - private String type; - - @JsonProperty("text") - private String text; - - @JsonAnySetter - @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** - * Set the id of this {@link ChildObject3} instance and return the same instance. - * - * @param id The id of this {@link ChildObject3} - * @return The same instance of this {@link ChildObject3} class - */ - @Nonnull public ChildObject3 id( @Nullable final String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id The id of this {@link ChildObject3} instance. - */ - @Nonnull public String getId() { - return id; - } - - /** - * Set the id of this {@link ChildObject3} instance. - * - * @param id The id of this {@link ChildObject3} - */ - public void setId( @Nullable final String id) { - this.id = id; - } - - /** - * Set the type of this {@link ChildObject3} instance and return the same instance. - * - * @param type The type of this {@link ChildObject3} - * @return The same instance of this {@link ChildObject3} class - */ - @Nonnull public ChildObject3 type( @Nullable final String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type The type of this {@link ChildObject3} instance. - */ - @Nonnull public String getType() { - return type; - } - - /** - * Set the type of this {@link ChildObject3} instance. - * - * @param type The type of this {@link ChildObject3} - */ - public void setType( @Nullable final String type) { - this.type = type; - } - - /** - * Set the text of this {@link ChildObject3} instance and return the same instance. - * - * @param text The text of this {@link ChildObject3} - * @return The same instance of this {@link ChildObject3} class - */ - @Nonnull public ChildObject3 text( @Nullable final String text) { - this.text = text; - return this; - } - - /** - * Get text - * @return text The text of this {@link ChildObject3} instance. - */ - @Nonnull public String getText() { - return text; - } - - /** - * Set the text of this {@link ChildObject3} instance. - * - * @param text The text of this {@link ChildObject3} - */ - public void setText( @Nullable final String text) { - this.text = text; - } - - /** - * Get the names of the unrecognizable properties of the {@link ChildObject3}. - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link ChildObject3} instance. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { - if( !cloudSdkCustomFields.containsKey(name) ) { - throw new NoSuchElementException("ChildObject3 has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Set an unrecognizable property of this {@link ChildObject3} instance. If the map previously contained a mapping - * for the key, the old value is replaced by the specified value. - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) - { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final ChildObject3 childObject3 = (ChildObject3) o; - return Objects.equals(this.cloudSdkCustomFields, childObject3.cloudSdkCustomFields) && - Objects.equals(this.id, childObject3.id) && - Objects.equals(this.type, childObject3.type) && - Objects.equals(this.text, childObject3.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, text, cloudSdkCustomFields); - } - - @Override - @Nonnull public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class ChildObject3 {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" text: ").append(toIndentedString(text)).append("\n"); - cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - -} - diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/NestedChildObject.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/NestedChildObject.java deleted file mode 100644 index a63891588..000000000 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/NestedChildObject.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. - */ - -/* - * Sample API - * API for managing root and child objects - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sap.cloud.sdk.services.anyofoneof.model; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * NestedChildObject - */ -// CHECKSTYLE:OFF -public class NestedChildObject -// CHECKSTYLE:ON -{ - @JsonProperty("id") - private String id; - - @JsonProperty("type") - private String type; - - @JsonProperty("text") - private String text; - - @JsonAnySetter - @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** - * Set the id of this {@link NestedChildObject} instance and return the same instance. - * - * @param id The id of this {@link NestedChildObject} - * @return The same instance of this {@link NestedChildObject} class - */ - @Nonnull public NestedChildObject id( @Nullable final String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id The id of this {@link NestedChildObject} instance. - */ - @Nonnull public String getId() { - return id; - } - - /** - * Set the id of this {@link NestedChildObject} instance. - * - * @param id The id of this {@link NestedChildObject} - */ - public void setId( @Nullable final String id) { - this.id = id; - } - - /** - * Set the type of this {@link NestedChildObject} instance and return the same instance. - * - * @param type The type of this {@link NestedChildObject} - * @return The same instance of this {@link NestedChildObject} class - */ - @Nonnull public NestedChildObject type( @Nullable final String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type The type of this {@link NestedChildObject} instance. - */ - @Nonnull public String getType() { - return type; - } - - /** - * Set the type of this {@link NestedChildObject} instance. - * - * @param type The type of this {@link NestedChildObject} - */ - public void setType( @Nullable final String type) { - this.type = type; - } - - /** - * Set the text of this {@link NestedChildObject} instance and return the same instance. - * - * @param text The text of this {@link NestedChildObject} - * @return The same instance of this {@link NestedChildObject} class - */ - @Nonnull public NestedChildObject text( @Nullable final String text) { - this.text = text; - return this; - } - - /** - * Get text - * @return text The text of this {@link NestedChildObject} instance. - */ - @Nonnull public String getText() { - return text; - } - - /** - * Set the text of this {@link NestedChildObject} instance. - * - * @param text The text of this {@link NestedChildObject} - */ - public void setText( @Nullable final String text) { - this.text = text; - } - - /** - * Get the names of the unrecognizable properties of the {@link NestedChildObject}. - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link NestedChildObject} instance. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { - if( !cloudSdkCustomFields.containsKey(name) ) { - throw new NoSuchElementException("NestedChildObject has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Set an unrecognizable property of this {@link NestedChildObject} instance. If the map previously contained a mapping - * for the key, the old value is replaced by the specified value. - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) - { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final NestedChildObject nestedChildObject = (NestedChildObject) o; - return Objects.equals(this.cloudSdkCustomFields, nestedChildObject.cloudSdkCustomFields) && - Objects.equals(this.id, nestedChildObject.id) && - Objects.equals(this.type, nestedChildObject.type) && - Objects.equals(this.text, nestedChildObject.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, text, cloudSdkCustomFields); - } - - @Override - @Nonnull public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class NestedChildObject {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" text: ").append(toIndentedString(text)).append("\n"); - cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - -} - diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/RootObjectQuestionsInner.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/RootObjectQuestionsInner.java deleted file mode 100644 index c3dd8933e..000000000 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/model/RootObjectQuestionsInner.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. - */ - -/* - * Sample API - * API for managing root and child objects - * - * The version of the OpenAPI document: 1.0.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sap.cloud.sdk.services.anyofoneof.model; - -import java.util.Arrays; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Set; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonTypeName; -import com.fasterxml.jackson.annotation.JsonValue; -import com.sap.cloud.sdk.services.anyofoneof.model.ChildObject1; -import com.sap.cloud.sdk.services.anyofoneof.model.ChildObject2; -import com.sap.cloud.sdk.services.anyofoneof.model.ChildObject3; -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonAnyGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * RootObjectQuestionsInner - */ -// CHECKSTYLE:OFF -public class RootObjectQuestionsInner -// CHECKSTYLE:ON -{ - @JsonProperty("id") - private String id; - - @JsonProperty("type") - private String type; - - @JsonProperty("text") - private String text; - - @JsonAnySetter - @JsonAnyGetter - private final Map cloudSdkCustomFields = new LinkedHashMap<>(); - - /** - * Set the id of this {@link RootObjectQuestionsInner} instance and return the same instance. - * - * @param id The id of this {@link RootObjectQuestionsInner} - * @return The same instance of this {@link RootObjectQuestionsInner} class - */ - @Nonnull public RootObjectQuestionsInner id( @Nullable final String id) { - this.id = id; - return this; - } - - /** - * Get id - * @return id The id of this {@link RootObjectQuestionsInner} instance. - */ - @Nonnull public String getId() { - return id; - } - - /** - * Set the id of this {@link RootObjectQuestionsInner} instance. - * - * @param id The id of this {@link RootObjectQuestionsInner} - */ - public void setId( @Nullable final String id) { - this.id = id; - } - - /** - * Set the type of this {@link RootObjectQuestionsInner} instance and return the same instance. - * - * @param type The type of this {@link RootObjectQuestionsInner} - * @return The same instance of this {@link RootObjectQuestionsInner} class - */ - @Nonnull public RootObjectQuestionsInner type( @Nullable final String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type The type of this {@link RootObjectQuestionsInner} instance. - */ - @Nonnull public String getType() { - return type; - } - - /** - * Set the type of this {@link RootObjectQuestionsInner} instance. - * - * @param type The type of this {@link RootObjectQuestionsInner} - */ - public void setType( @Nullable final String type) { - this.type = type; - } - - /** - * Set the text of this {@link RootObjectQuestionsInner} instance and return the same instance. - * - * @param text The text of this {@link RootObjectQuestionsInner} - * @return The same instance of this {@link RootObjectQuestionsInner} class - */ - @Nonnull public RootObjectQuestionsInner text( @Nullable final String text) { - this.text = text; - return this; - } - - /** - * Get text - * @return text The text of this {@link RootObjectQuestionsInner} instance. - */ - @Nonnull public String getText() { - return text; - } - - /** - * Set the text of this {@link RootObjectQuestionsInner} instance. - * - * @param text The text of this {@link RootObjectQuestionsInner} - */ - public void setText( @Nullable final String text) { - this.text = text; - } - - /** - * Get the names of the unrecognizable properties of the {@link RootObjectQuestionsInner}. - * @return The set of properties names - */ - @JsonIgnore - @Nonnull - public Set getCustomFieldNames() { - return cloudSdkCustomFields.keySet(); - } - - /** - * Get the value of an unrecognizable property of this {@link RootObjectQuestionsInner} instance. - * @param name The name of the property - * @return The value of the property - * @throws NoSuchElementException If no property with the given name could be found. - */ - @Nullable - public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { - if( !cloudSdkCustomFields.containsKey(name) ) { - throw new NoSuchElementException("RootObjectQuestionsInner has no field with name '" + name + "'."); - } - return cloudSdkCustomFields.get(name); - } - - /** - * Set an unrecognizable property of this {@link RootObjectQuestionsInner} instance. If the map previously contained a mapping - * for the key, the old value is replaced by the specified value. - * @param customFieldName The name of the property - * @param customFieldValue The value of the property - */ - @JsonIgnore - public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) - { - cloudSdkCustomFields.put(customFieldName, customFieldValue); - } - - - @Override - public boolean equals(@Nullable final java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - final RootObjectQuestionsInner rootObjectQuestionsInner = (RootObjectQuestionsInner) o; - return Objects.equals(this.cloudSdkCustomFields, rootObjectQuestionsInner.cloudSdkCustomFields) && - Objects.equals(this.id, rootObjectQuestionsInner.id) && - Objects.equals(this.type, rootObjectQuestionsInner.type) && - Objects.equals(this.text, rootObjectQuestionsInner.text); - } - - @Override - public int hashCode() { - return Objects.hash(id, type, text, cloudSdkCustomFields); - } - - @Override - @Nonnull public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class RootObjectQuestionsInner {\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" text: ").append(toIndentedString(text)).append("\n"); - cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(final java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - -} - diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java index 42f23868b..7f740af26 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/NewSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.builder.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -59,6 +57,9 @@ public class NewSoda @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for NewSoda. + */ private NewSoda() { } /** @@ -76,7 +77,8 @@ private NewSoda() { } * Get name * @return name The name of this {@link NewSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -104,7 +106,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link NewSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -132,7 +135,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link NewSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -160,7 +164,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link NewSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,7 +259,6 @@ private String toIndentedString(final java.lang.Object o) { } return o.toString().replace("\n", "\n "); } - /** * Create a type-safe, fluent-api builder object to construct a new {@link NewSoda} instance with all required arguments. */ diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/Soda.java index 2dd81618e..5bcf303da 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/Soda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/Soda.java @@ -16,11 +16,11 @@ package com.sap.cloud.sdk.services.builder.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; @@ -30,12 +30,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -65,6 +63,9 @@ public class Soda @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for Soda. + */ private Soda() { } /** @@ -82,7 +83,8 @@ private Soda() { } * Get id * @return id The id of this {@link Soda} instance. */ - @Nonnull public Long getId() { + @Nonnull + public Long getId() { return id; } @@ -110,7 +112,8 @@ public void setId( @Nullable final Long id) { * Get name * @return name The name of this {@link Soda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -138,7 +141,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link Soda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -178,7 +182,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavors * @return flavors The flavors of this {@link Soda} instance. */ - @Nonnull public List getFlavors() { + @Nonnull + public List getFlavors() { return flavors; } @@ -206,7 +211,8 @@ public void setFlavors( @Nonnull final List flavors) { * Get price * @return price The price of this {@link Soda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -302,7 +308,6 @@ private String toIndentedString(final java.lang.Object o) { } return o.toString().replace("\n", "\n "); } - /** * Create a type-safe, fluent-api builder object to construct a new {@link Soda} instance with all required arguments. */ diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java index 248fe56bf..6cf426327 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-builder/output/com/sap/cloud/sdk/services/builder/model/UpdateSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.builder.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -59,6 +57,9 @@ public class UpdateSoda @JsonAnySetter @JsonAnyGetter private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + /** + * Default constructor for UpdateSoda. + */ private UpdateSoda() { } /** @@ -76,7 +77,8 @@ private UpdateSoda() { } * Get name * @return name The name of this {@link UpdateSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -104,7 +106,8 @@ public void setName( @Nullable final String name) { * Get brand * @return brand The brand of this {@link UpdateSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -132,7 +135,8 @@ public void setBrand( @Nullable final String brand) { * Get flavor * @return flavor The flavor of this {@link UpdateSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -160,7 +164,8 @@ public void setFlavor( @Nullable final String flavor) { * Get price * @return price The price of this {@link UpdateSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,7 +259,6 @@ private String toIndentedString(final java.lang.Object o) { } return o.toString().replace("\n", "\n "); } - /** * Create a new {@link UpdateSoda} instance. No arguments are required. */ diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/NewSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/NewSoda.java index 0e58e4ad4..8fb462951 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/NewSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/NewSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.uppercasefileextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -75,7 +73,8 @@ public class NewSoda * Get name * @return name The name of this {@link NewSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -103,7 +102,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link NewSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -131,7 +131,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link NewSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -159,7 +160,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link NewSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,6 +256,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/Soda.java index 920ee5c40..f20e47df0 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/Soda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/Soda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.uppercasefileextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -78,7 +76,8 @@ public class Soda * Get id * @return id The id of this {@link Soda} instance. */ - @Nonnull public Long getId() { + @Nonnull + public Long getId() { return id; } @@ -106,7 +105,8 @@ public void setId( @Nullable final Long id) { * Get name * @return name The name of this {@link Soda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -134,7 +134,8 @@ public void setName( @Nonnull final String name) { * Get brand * @return brand The brand of this {@link Soda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -162,7 +163,8 @@ public void setBrand( @Nonnull final String brand) { * Get flavor * @return flavor The flavor of this {@link Soda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -190,7 +192,8 @@ public void setFlavor( @Nonnull final String flavor) { * Get price * @return price The price of this {@link Soda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -287,6 +290,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/UpdateSoda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/UpdateSoda.java index 6c881a5f7..8d1691b8f 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/UpdateSoda.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-uppercase-file-extension/output/com/sap/cloud/sdk/services/uppercasefileextension/model/UpdateSoda.java @@ -16,23 +16,21 @@ package com.sap.cloud.sdk.services.uppercasefileextension.model; +import java.util.Objects; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; import java.util.NoSuchElementException; -import java.util.Objects; import java.util.Set; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonValue; -import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonTypeName; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -75,7 +73,8 @@ public class UpdateSoda * Get name * @return name The name of this {@link UpdateSoda} instance. */ - @Nonnull public String getName() { + @Nonnull + public String getName() { return name; } @@ -103,7 +102,8 @@ public void setName( @Nullable final String name) { * Get brand * @return brand The brand of this {@link UpdateSoda} instance. */ - @Nonnull public String getBrand() { + @Nonnull + public String getBrand() { return brand; } @@ -131,7 +131,8 @@ public void setBrand( @Nullable final String brand) { * Get flavor * @return flavor The flavor of this {@link UpdateSoda} instance. */ - @Nonnull public String getFlavor() { + @Nonnull + public String getFlavor() { return flavor; } @@ -159,7 +160,8 @@ public void setFlavor( @Nullable final String flavor) { * Get price * @return price The price of this {@link UpdateSoda} instance. */ - @Nonnull public Float getPrice() { + @Nonnull + public Float getPrice() { return price; } @@ -254,6 +256,5 @@ private String toIndentedString(final java.lang.Object o) { return o.toString().replace("\n", "\n "); } - } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/input/sodastore.yaml b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/input/sodastore.yaml new file mode 100644 index 000000000..470276795 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/input/sodastore.yaml @@ -0,0 +1,58 @@ +openapi: 3.0.0 +info: + title: Soda Store API + version: 1.0.0 + description: API for managing sodas in a soda store +paths: + /sodas: + get: + summary: Get a list of all sodas + operationId: getSodas + responses: + '200': + description: A list of sodas + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/OneOf' +components: + schemas: + OneOfWithDiscriminatorAndMapping: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + mapping: + Cola: '#/components/schemas/Cola' + Fanta: '#/components/schemas/Fanta' + OneOfWithDiscriminator: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + OneOf: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AnyOf: + anyOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AllOf: + allOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + Cola: + type: object + properties: + sodaType: + type: string + Fanta: + type: object + properties: + sodaType: + type: string diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/AllOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/AllOf.java new file mode 100644 index 000000000..a2c60509f --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/AllOf.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * AllOf + */ +// CHECKSTYLE:OFF +public class AllOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link AllOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull public AllOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link AllOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link AllOf} instance. + * + * @param sodaType The sodaType of this {@link AllOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link AllOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AllOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AllOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AllOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AllOf allOf = (AllOf) o; + return Objects.equals(this.cloudSdkCustomFields, allOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, allOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AllOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/AnyOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/AnyOf.java new file mode 100644 index 000000000..879569438 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/AnyOf.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * AnyOf + */ +// CHECKSTYLE:OFF +public class AnyOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link AnyOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull public AnyOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link AnyOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link AnyOf} instance. + * + * @param sodaType The sodaType of this {@link AnyOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link AnyOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AnyOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AnyOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AnyOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AnyOf anyOf = (AnyOf) o; + return Objects.equals(this.cloudSdkCustomFields, anyOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, anyOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/Cola.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/Cola.java new file mode 100644 index 000000000..a2adbf686 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/Cola.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Cola + */ +// CHECKSTYLE:OFF +public class Cola +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link Cola} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull public Cola sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link Cola} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link Cola} instance. + * + * @param sodaType The sodaType of this {@link Cola} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link Cola}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Cola} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Cola has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Cola} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Cola cola = (Cola) o; + return Objects.equals(this.cloudSdkCustomFields, cola.cloudSdkCustomFields) && + Objects.equals(this.sodaType, cola.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Cola {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/DefaultApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/DefaultApi.java new file mode 100644 index 000000000..424ff2c43 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/DefaultApi.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package test; + +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; +import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; + +import test.OneOf; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import com.google.common.annotations.Beta; + +import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; + +/** + * Soda Store API in version 1.0.0. + * + * API for managing sodas in a soda store + */ +public class DefaultApi extends AbstractOpenApiService { + /** + * Instantiates this API class to invoke operations on the Soda Store API. + * + * @param httpDestination The destination that API should be used with + */ + public DefaultApi( @Nonnull final Destination httpDestination ) + { + super(httpDestination); + } + + /** + * Instantiates this API class to invoke operations on the Soda Store API based on a given {@link ApiClient}. + * + * @param apiClient + * ApiClient to invoke the API on + */ + @Beta + public DefaultApi( @Nonnull final ApiClient apiClient ) + { + super(apiClient); + } + + /** + *

    Get a list of all sodas

    + *

    + *

    200 - A list of sodas + * @return List<OneOf> + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public List getSodas() throws OpenApiRequestException { + final Object localVarPostBody = null; + + final String localVarPath = UriComponentsBuilder.fromPath("/sodas").build().toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference>() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/Fanta.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/Fanta.java new file mode 100644 index 000000000..c6359bba1 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/Fanta.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Fanta + */ +// CHECKSTYLE:OFF +public class Fanta +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link Fanta} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull public Fanta sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link Fanta} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link Fanta} instance. + * + * @param sodaType The sodaType of this {@link Fanta} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link Fanta}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Fanta} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Fanta has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Fanta} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Fanta fanta = (Fanta) o; + return Objects.equals(this.cloudSdkCustomFields, fanta.cloudSdkCustomFields) && + Objects.equals(this.sodaType, fanta.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Fanta {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOf.java new file mode 100644 index 000000000..7ad1e3e0a --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOf.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOf + */ +// CHECKSTYLE:OFF +public class OneOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link OneOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link OneOf} + * @return The same instance of this {@link OneOf} class + */ + @Nonnull public OneOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link OneOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link OneOf} instance. + * + * @param sodaType The sodaType of this {@link OneOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link OneOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OneOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OneOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OneOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OneOf oneOf = (OneOf) o; + return Objects.equals(this.cloudSdkCustomFields, oneOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, oneOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OneOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOfWithDiscriminator.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOfWithDiscriminator.java new file mode 100644 index 000000000..883ee607c --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOfWithDiscriminator.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOfWithDiscriminator + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class, name = "Cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "Fanta"), +}) +// CHECKSTYLE:OFF +public class OneOfWithDiscriminator +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link OneOfWithDiscriminator} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminator} + * @return The same instance of this {@link OneOfWithDiscriminator} class + */ + @Nonnull public OneOfWithDiscriminator sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link OneOfWithDiscriminator} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link OneOfWithDiscriminator} instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminator} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link OneOfWithDiscriminator}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OneOfWithDiscriminator} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OneOfWithDiscriminator has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OneOfWithDiscriminator} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OneOfWithDiscriminator oneOfWithDiscriminator = (OneOfWithDiscriminator) o; + return Objects.equals(this.cloudSdkCustomFields, oneOfWithDiscriminator.cloudSdkCustomFields) && + Objects.equals(this.sodaType, oneOfWithDiscriminator.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OneOfWithDiscriminator {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOfWithDiscriminatorAndMapping.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOfWithDiscriminatorAndMapping.java new file mode 100644 index 000000000..f5f8c4ebc --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-disabled/output/test/OneOfWithDiscriminatorAndMapping.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOfWithDiscriminatorAndMapping + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class, name = "Cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "Fanta"), +}) +// CHECKSTYLE:OFF +public class OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link OneOfWithDiscriminatorAndMapping} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminatorAndMapping} + * @return The same instance of this {@link OneOfWithDiscriminatorAndMapping} class + */ + @Nonnull public OneOfWithDiscriminatorAndMapping sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link OneOfWithDiscriminatorAndMapping} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link OneOfWithDiscriminatorAndMapping} instance. + * + * @param sodaType The sodaType of this {@link OneOfWithDiscriminatorAndMapping} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link OneOfWithDiscriminatorAndMapping}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OneOfWithDiscriminatorAndMapping} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OneOfWithDiscriminatorAndMapping has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OneOfWithDiscriminatorAndMapping} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OneOfWithDiscriminatorAndMapping oneOfWithDiscriminatorAndMapping = (OneOfWithDiscriminatorAndMapping) o; + return Objects.equals(this.cloudSdkCustomFields, oneOfWithDiscriminatorAndMapping.cloudSdkCustomFields) && + Objects.equals(this.sodaType, oneOfWithDiscriminatorAndMapping.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OneOfWithDiscriminatorAndMapping {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/input/sodastore.yaml b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/input/sodastore.yaml new file mode 100644 index 000000000..e7a169e45 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/input/sodastore.yaml @@ -0,0 +1,58 @@ +openapi: 3.0.0 +info: + title: Soda Store API + version: 1.0.0 + description: API for managing sodas in a soda store +paths: + /sodas: + get: + summary: Get a list of all sodas + operationId: getSodas + responses: + '200': + description: A list of sodas + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/OneOf' +components: + schemas: + OneOfWithDiscriminatorAndMapping: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + mapping: + cool_cola: '#/components/schemas/Cola' + fancy_fanta: '#/components/schemas/Fanta' + OneOfWithDiscriminator: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + discriminator: + propertyName: sodaType + OneOf: + oneOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AnyOf: + anyOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + AllOf: + allOf: + - $ref: '#/components/schemas/Cola' + - $ref: '#/components/schemas/Fanta' + Cola: + type: object + properties: + sodaType: + type: string + Fanta: + type: object + properties: + sodaType: + type: string diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/AllOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/AllOf.java new file mode 100644 index 000000000..a2c60509f --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/AllOf.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * AllOf + */ +// CHECKSTYLE:OFF +public class AllOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link AllOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link AllOf} + * @return The same instance of this {@link AllOf} class + */ + @Nonnull public AllOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link AllOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link AllOf} instance. + * + * @param sodaType The sodaType of this {@link AllOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link AllOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AllOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AllOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AllOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AllOf allOf = (AllOf) o; + return Objects.equals(this.cloudSdkCustomFields, allOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, allOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AllOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/AnyOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/AnyOf.java new file mode 100644 index 000000000..879569438 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/AnyOf.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * AnyOf + */ +// CHECKSTYLE:OFF +public class AnyOf +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link AnyOf} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link AnyOf} + * @return The same instance of this {@link AnyOf} class + */ + @Nonnull public AnyOf sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link AnyOf} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link AnyOf} instance. + * + * @param sodaType The sodaType of this {@link AnyOf} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link AnyOf}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link AnyOf} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("AnyOf has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link AnyOf} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final AnyOf anyOf = (AnyOf) o; + return Objects.equals(this.cloudSdkCustomFields, anyOf.cloudSdkCustomFields) && + Objects.equals(this.sodaType, anyOf.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class AnyOf {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/Cola.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/Cola.java new file mode 100644 index 000000000..3f3063d9d --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/Cola.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Cola + */ +// CHECKSTYLE:OFF +public class Cola implements OneOf, OneOfWithDiscriminator, OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link Cola} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link Cola} + * @return The same instance of this {@link Cola} class + */ + @Nonnull public Cola sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link Cola} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link Cola} instance. + * + * @param sodaType The sodaType of this {@link Cola} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link Cola}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Cola} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Cola has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Cola} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Cola cola = (Cola) o; + return Objects.equals(this.cloudSdkCustomFields, cola.cloudSdkCustomFields) && + Objects.equals(this.sodaType, cola.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Cola {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/DefaultApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/DefaultApi.java new file mode 100644 index 000000000..424ff2c43 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/DefaultApi.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package test; + +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; +import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; + +import test.OneOf; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import com.google.common.annotations.Beta; + +import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; + +/** + * Soda Store API in version 1.0.0. + * + * API for managing sodas in a soda store + */ +public class DefaultApi extends AbstractOpenApiService { + /** + * Instantiates this API class to invoke operations on the Soda Store API. + * + * @param httpDestination The destination that API should be used with + */ + public DefaultApi( @Nonnull final Destination httpDestination ) + { + super(httpDestination); + } + + /** + * Instantiates this API class to invoke operations on the Soda Store API based on a given {@link ApiClient}. + * + * @param apiClient + * ApiClient to invoke the API on + */ + @Beta + public DefaultApi( @Nonnull final ApiClient apiClient ) + { + super(apiClient); + } + + /** + *

    Get a list of all sodas

    + *

    + *

    200 - A list of sodas + * @return List<OneOf> + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public List getSodas() throws OpenApiRequestException { + final Object localVarPostBody = null; + + final String localVarPath = UriComponentsBuilder.fromPath("/sodas").build().toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { }; + + final ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference>() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/Fanta.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/Fanta.java new file mode 100644 index 000000000..4ec3ade18 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/Fanta.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Fanta + */ +// CHECKSTYLE:OFF +public class Fanta implements OneOf, OneOfWithDiscriminator, OneOfWithDiscriminatorAndMapping +// CHECKSTYLE:ON +{ + @JsonProperty("sodaType") + private String sodaType; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the sodaType of this {@link Fanta} instance and return the same instance. + * + * @param sodaType The sodaType of this {@link Fanta} + * @return The same instance of this {@link Fanta} class + */ + @Nonnull public Fanta sodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + return this; + } + + /** + * Get sodaType + * @return sodaType The sodaType of this {@link Fanta} instance. + */ + @Nonnull + public String getSodaType() { + return sodaType; + } + + /** + * Set the sodaType of this {@link Fanta} instance. + * + * @param sodaType The sodaType of this {@link Fanta} + */ + public void setSodaType( @Nullable final String sodaType) { + this.sodaType = sodaType; + } + + /** + * Get the names of the unrecognizable properties of the {@link Fanta}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Fanta} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Fanta has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Fanta} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Fanta fanta = (Fanta) o; + return Objects.equals(this.cloudSdkCustomFields, fanta.cloudSdkCustomFields) && + Objects.equals(this.sodaType, fanta.sodaType); + } + + @Override + public int hashCode() { + return Objects.hash(sodaType, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Fanta {\n"); + sb.append(" sodaType: ").append(toIndentedString(sodaType)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOf.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOf.java new file mode 100644 index 000000000..8100d34c3 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOf.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOf + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class), + @JsonSubTypes.Type(value = Fanta.class), +}) + +public interface OneOf { +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOfWithDiscriminator.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOfWithDiscriminator.java new file mode 100644 index 000000000..ada1c2cfe --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOfWithDiscriminator.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOfWithDiscriminator + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class, name = "Cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "Fanta"), +}) + +public interface OneOfWithDiscriminator { + String getSodaType(); +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOfWithDiscriminatorAndMapping.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOfWithDiscriminatorAndMapping.java new file mode 100644 index 000000000..e55a6a8d0 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/oneof-interfaces-enabled/output/test/OneOfWithDiscriminatorAndMapping.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * Soda Store API + * API for managing sodas in a soda store + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package test; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import test.Cola; +import test.Fanta; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OneOfWithDiscriminatorAndMapping + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "sodaType", visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Cola.class, name = "cool_cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "fancy_fanta"), + @JsonSubTypes.Type(value = Cola.class, name = "Cola"), + @JsonSubTypes.Type(value = Fanta.class, name = "Fanta"), +}) + +public interface OneOfWithDiscriminatorAndMapping { + String getSodaType(); +} + diff --git a/datamodel/openapi/openapi-api-sample/src/main/resources/sodastore.json b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/input/sodastore.json similarity index 98% rename from datamodel/openapi/openapi-api-sample/src/main/resources/sodastore.json rename to datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/input/sodastore.json index 2f2bd0412..e9ca71a1d 100644 --- a/datamodel/openapi/openapi-api-sample/src/main/resources/sodastore.json +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/input/sodastore.json @@ -136,6 +136,7 @@ "paths": { "/sodas": { "get": { + "operationId": "foo.bar.get", "summary": "Get all soda products", "tags": [ "Sodas" @@ -244,6 +245,7 @@ }, "/orders": { "post": { + "operationId": "foo2.bar2.get", "summary": "Create a new order", "tags": [ "Orders" diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/api/DefaultApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/OrdersApi.java similarity index 62% rename from datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/api/DefaultApi.java rename to datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/OrdersApi.java index 1f3288fdf..f29ee9ebd 100644 --- a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/input-spec-with-anyof-oneof/output/com/sap/cloud/sdk/services/anyofoneof/api/DefaultApi.java +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/OrdersApi.java @@ -2,14 +2,14 @@ * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. */ -package com.sap.cloud.sdk.services.anyofoneof.api; +package com.sap.cloud.sdk.services.builder.api; import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; -import com.sap.cloud.sdk.services.anyofoneof.model.RootObject; +import com.sap.cloud.sdk.services.builder.model.Order; import java.util.HashMap; import java.util.List; @@ -32,50 +32,52 @@ import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; /** - * Sample API in version 1.0.0. + * SodaStore API in version 1.0.0. * - * API for managing root and child objects + * API for managing soda products and orders in SodaStore. */ -public class DefaultApi extends AbstractOpenApiService { +public class OrdersApi extends AbstractOpenApiService { /** - * Instantiates this API class to invoke operations on the Sample API. + * Instantiates this API class to invoke operations on the SodaStore API. * * @param httpDestination The destination that API should be used with */ - public DefaultApi( @Nonnull final Destination httpDestination ) + public OrdersApi( @Nonnull final Destination httpDestination ) { super(httpDestination); } /** - * Instantiates this API class to invoke operations on the Sample API based on a given {@link ApiClient}. + * Instantiates this API class to invoke operations on the SodaStore API based on a given {@link ApiClient}. * * @param apiClient * ApiClient to invoke the API on */ @Beta - public DefaultApi( @Nonnull final ApiClient apiClient ) + public OrdersApi( @Nonnull final ApiClient apiClient ) { super(apiClient); } - - /** + /** + *

    Create a new order

    *

    - *

    - *

    201 - Something was created. - *

    400 - Request was invalid. - *

    401 - Authentication Error - * @param rootObject (optional) - The value for the parameter rootObject - * @return RootObject + *

    201 - The created order + * @param order + * The order details + * @return Order * @throws OpenApiRequestException if an error occurs while attempting to invoke the API */ @Nonnull - public RootObject someEndpointPost( @Nullable final RootObject rootObject) throws OpenApiRequestException { - final Object localVarPostBody = rootObject; + public Order get( @Nonnull final Order order) throws OpenApiRequestException { + final Object localVarPostBody = order; + + // verify the required parameter 'order' is set + if (order == null) { + throw new OpenApiRequestException("Missing the required parameter 'order' when calling get"); + } - final String localVarPath = UriComponentsBuilder.fromPath("/some/endpoint").build().toUriString(); + final String localVarPath = UriComponentsBuilder.fromPath("/orders").build().toUriString(); final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); final HttpHeaders localVarHeaderParams = new HttpHeaders(); @@ -90,23 +92,9 @@ public RootObject someEndpointPost( @Nullable final RootObject rootObject) throw }; final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - final String[] localVarAuthNames = new String[] { }; + final String[] localVarAuthNames = new String[] { "apiKeyAuth" }; - final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; return apiClient.invokeAPI(localVarPath, HttpMethod.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); } - - /** - *

    - *

    - *

    201 - Something was created. - *

    400 - Request was invalid. - *

    401 - Authentication Error - * @return RootObject - * @throws OpenApiRequestException if an error occurs while attempting to invoke the API - */ - @Nonnull - public RootObject someEndpointPost() throws OpenApiRequestException { - return someEndpointPost(null); - } } diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/SodasApi.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/SodasApi.java new file mode 100644 index 000000000..04e72726f --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/api/SodasApi.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +package com.sap.cloud.sdk.services.builder.api; + +import com.sap.cloud.sdk.services.openapi.core.OpenApiRequestException; +import com.sap.cloud.sdk.services.openapi.core.OpenApiResponse; +import com.sap.cloud.sdk.services.openapi.core.AbstractOpenApiService; +import com.sap.cloud.sdk.services.openapi.apiclient.ApiClient; + +import com.sap.cloud.sdk.services.builder.model.Soda; +import com.sap.cloud.sdk.services.builder.model.SodaWithId; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.util.UriComponentsBuilder; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import com.google.common.annotations.Beta; + +import com.sap.cloud.sdk.cloudplatform.connectivity.Destination; + +/** + * SodaStore API in version 1.0.0. + * + * API for managing soda products and orders in SodaStore. + */ +public class SodasApi extends AbstractOpenApiService { + /** + * Instantiates this API class to invoke operations on the SodaStore API. + * + * @param httpDestination The destination that API should be used with + */ + public SodasApi( @Nonnull final Destination httpDestination ) + { + super(httpDestination); + } + + /** + * Instantiates this API class to invoke operations on the SodaStore API based on a given {@link ApiClient}. + * + * @param apiClient + * ApiClient to invoke the API on + */ + @Beta + public SodasApi( @Nonnull final ApiClient apiClient ) + { + super(apiClient); + } + + /** + *

    Get all soda products

    + *

    + *

    200 - A list of soda products + * @return List<SodaWithId> + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public List get() throws OpenApiRequestException { + final Object localVarPostBody = null; + + final String localVarPath = UriComponentsBuilder.fromPath("/sodas").build().toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + final ParameterizedTypeReference> localVarReturnType = new ParameterizedTypeReference>() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + *

    Get a specific soda product by ID

    + *

    + *

    200 - The soda product + *

    404 - Soda product not found + * @param id + * ID of the soda product to retrieve + * @return SodaWithId + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nonnull + public SodaWithId sodasIdGet( @Nonnull final Long id) throws OpenApiRequestException { + final Object localVarPostBody = null; + + // verify the required parameter 'id' is set + if (id == null) { + throw new OpenApiRequestException("Missing the required parameter 'id' when calling sodasIdGet"); + } + + // create path and map variables + final Map localVarPathParams = new HashMap(); + localVarPathParams.put("id", id); + final String localVarPath = UriComponentsBuilder.fromPath("/sodas/{id}").buildAndExpand(localVarPathParams).toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + *

    Update a specific soda product by ID

    + *

    + *

    200 - The updated soda product + *

    404 - Soda product not found + *

    204 - Nothing has changed + * @param sodaWithId + * The updated soda product + * @return Soda + * @throws OpenApiRequestException if an error occurs while attempting to invoke the API + */ + @Nullable + public Soda sodasPut( @Nonnull final SodaWithId sodaWithId) throws OpenApiRequestException { + final Object localVarPostBody = sodaWithId; + + // verify the required parameter 'sodaWithId' is set + if (sodaWithId == null) { + throw new OpenApiRequestException("Missing the required parameter 'sodaWithId' when calling sodasPut"); + } + + final String localVarPath = UriComponentsBuilder.fromPath("/sodas").build().toUriString(); + + final MultiValueMap localVarQueryParams = new LinkedMultiValueMap(); + final HttpHeaders localVarHeaderParams = new HttpHeaders(); + final MultiValueMap localVarFormParams = new LinkedMultiValueMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final List localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + final String[] localVarContentTypes = { + "application/json" + }; + final MediaType localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + final String[] localVarAuthNames = new String[] { "apiKeyAuth" }; + + final ParameterizedTypeReference localVarReturnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(localVarPath, HttpMethod.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } +} diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/Order.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/Order.java new file mode 100644 index 000000000..61892d351 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/Order.java @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Order + */ +// CHECKSTYLE:OFF +public class Order +// CHECKSTYLE:ON +{ + @JsonProperty("productId") + private Long productId; + + @JsonProperty("quantity") + private Integer quantity; + + @JsonProperty("totalPrice") + private Float totalPrice; + + @JsonProperty("typelessProperty") + private Object typelessProperty = null; + + @JsonProperty("nullableProperty") + private String nullableProperty; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the productId of this {@link Order} instance and return the same instance. + * + * @param productId The productId of this {@link Order} + * @return The same instance of this {@link Order} class + */ + @Nonnull public Order productId( @Nonnull final Long productId) { + this.productId = productId; + return this; + } + + /** + * Get productId + * @return productId The productId of this {@link Order} instance. + */ + @Nonnull + public Long getProductId() { + return productId; + } + + /** + * Set the productId of this {@link Order} instance. + * + * @param productId The productId of this {@link Order} + */ + public void setProductId( @Nonnull final Long productId) { + this.productId = productId; + } + + /** + * Set the quantity of this {@link Order} instance and return the same instance. + * + * @param quantity The quantity of this {@link Order} + * @return The same instance of this {@link Order} class + */ + @Nonnull public Order quantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity The quantity of this {@link Order} instance. + */ + @Nonnull + public Integer getQuantity() { + return quantity; + } + + /** + * Set the quantity of this {@link Order} instance. + * + * @param quantity The quantity of this {@link Order} + */ + public void setQuantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + } + + /** + * Set the totalPrice of this {@link Order} instance and return the same instance. + * + * @param totalPrice The totalPrice of this {@link Order} + * @return The same instance of this {@link Order} class + */ + @Nonnull public Order totalPrice( @Nullable final Float totalPrice) { + this.totalPrice = totalPrice; + return this; + } + + /** + * Get totalPrice + * @return totalPrice The totalPrice of this {@link Order} instance. + */ + @Nonnull + public Float getTotalPrice() { + return totalPrice; + } + + /** + * Set the totalPrice of this {@link Order} instance. + * + * @param totalPrice The totalPrice of this {@link Order} + */ + public void setTotalPrice( @Nullable final Float totalPrice) { + this.totalPrice = totalPrice; + } + + /** + * Set the typelessProperty of this {@link Order} instance and return the same instance. + * + * @param typelessProperty Some typeless property, interpreted by the generator as nullable by default (because typeless) + * @return The same instance of this {@link Order} class + */ + @Nonnull public Order typelessProperty( @Nullable final Object typelessProperty) { + this.typelessProperty = typelessProperty; + return this; + } + + /** + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + * @return typelessProperty The typelessProperty of this {@link Order} instance. + */ + @Nullable + public Object getTypelessProperty() { + return typelessProperty; + } + + /** + * Set the typelessProperty of this {@link Order} instance. + * + * @param typelessProperty Some typeless property, interpreted by the generator as nullable by default (because typeless) + */ + public void setTypelessProperty( @Nullable final Object typelessProperty) { + this.typelessProperty = typelessProperty; + } + + /** + * Set the nullableProperty of this {@link Order} instance and return the same instance. + * + * @param nullableProperty Some typed property that is deliberately made nullable + * @return The same instance of this {@link Order} class + */ + @Nonnull public Order nullableProperty( @Nullable final String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Some typed property that is deliberately made nullable + * @return nullableProperty The nullableProperty of this {@link Order} instance. + */ + @Nullable + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set the nullableProperty of this {@link Order} instance. + * + * @param nullableProperty Some typed property that is deliberately made nullable + */ + public void setNullableProperty( @Nullable final String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + /** + * Get the names of the unrecognizable properties of the {@link Order}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Order} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Order has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Order} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Order order = (Order) o; + return Objects.equals(this.cloudSdkCustomFields, order.cloudSdkCustomFields) && + Objects.equals(this.productId, order.productId) && + Objects.equals(this.quantity, order.quantity) && + Objects.equals(this.totalPrice, order.totalPrice) && + Objects.equals(this.typelessProperty, order.typelessProperty) && + Objects.equals(this.nullableProperty, order.nullableProperty); + } + + @Override + public int hashCode() { + return Objects.hash(productId, quantity, totalPrice, typelessProperty, nullableProperty, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + sb.append(" productId: ").append(toIndentedString(productId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" totalPrice: ").append(toIndentedString(totalPrice)).append("\n"); + sb.append(" typelessProperty: ").append(toIndentedString(typelessProperty)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/OrderWithTimestamp.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/OrderWithTimestamp.java new file mode 100644 index 000000000..90068f114 --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/OrderWithTimestamp.java @@ -0,0 +1,329 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * OrderWithTimestamp + */ +// CHECKSTYLE:OFF +public class OrderWithTimestamp +// CHECKSTYLE:ON +{ + @JsonProperty("productId") + private Long productId; + + @JsonProperty("quantity") + private Integer quantity; + + @JsonProperty("totalPrice") + private Float totalPrice; + + @JsonProperty("typelessProperty") + private Object typelessProperty; + + @JsonProperty("nullableProperty") + private String nullableProperty; + + @JsonProperty("timestamp") + private OffsetDateTime timestamp; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the productId of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param productId The productId of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull public OrderWithTimestamp productId( @Nonnull final Long productId) { + this.productId = productId; + return this; + } + + /** + * Get productId + * @return productId The productId of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public Long getProductId() { + return productId; + } + + /** + * Set the productId of this {@link OrderWithTimestamp} instance. + * + * @param productId The productId of this {@link OrderWithTimestamp} + */ + public void setProductId( @Nonnull final Long productId) { + this.productId = productId; + } + + /** + * Set the quantity of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param quantity The quantity of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull public OrderWithTimestamp quantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity The quantity of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public Integer getQuantity() { + return quantity; + } + + /** + * Set the quantity of this {@link OrderWithTimestamp} instance. + * + * @param quantity The quantity of this {@link OrderWithTimestamp} + */ + public void setQuantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + } + + /** + * Set the totalPrice of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param totalPrice The totalPrice of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull public OrderWithTimestamp totalPrice( @Nullable final Float totalPrice) { + this.totalPrice = totalPrice; + return this; + } + + /** + * Get totalPrice + * @return totalPrice The totalPrice of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public Float getTotalPrice() { + return totalPrice; + } + + /** + * Set the totalPrice of this {@link OrderWithTimestamp} instance. + * + * @param totalPrice The totalPrice of this {@link OrderWithTimestamp} + */ + public void setTotalPrice( @Nullable final Float totalPrice) { + this.totalPrice = totalPrice; + } + + /** + * Set the typelessProperty of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param typelessProperty Some typeless property, interpreted by the generator as nullable by default (because typeless) + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull public OrderWithTimestamp typelessProperty( @Nullable final Object typelessProperty) { + this.typelessProperty = typelessProperty; + return this; + } + + /** + * Some typeless property, interpreted by the generator as nullable by default (because typeless) + * @return typelessProperty The typelessProperty of this {@link OrderWithTimestamp} instance. + */ + @Nullable + public Object getTypelessProperty() { + return typelessProperty; + } + + /** + * Set the typelessProperty of this {@link OrderWithTimestamp} instance. + * + * @param typelessProperty Some typeless property, interpreted by the generator as nullable by default (because typeless) + */ + public void setTypelessProperty( @Nullable final Object typelessProperty) { + this.typelessProperty = typelessProperty; + } + + /** + * Set the nullableProperty of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param nullableProperty Some typed property that is deliberately made nullable + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull public OrderWithTimestamp nullableProperty( @Nullable final String nullableProperty) { + this.nullableProperty = nullableProperty; + return this; + } + + /** + * Some typed property that is deliberately made nullable + * @return nullableProperty The nullableProperty of this {@link OrderWithTimestamp} instance. + */ + @Nullable + public String getNullableProperty() { + return nullableProperty; + } + + /** + * Set the nullableProperty of this {@link OrderWithTimestamp} instance. + * + * @param nullableProperty Some typed property that is deliberately made nullable + */ + public void setNullableProperty( @Nullable final String nullableProperty) { + this.nullableProperty = nullableProperty; + } + + /** + * Set the timestamp of this {@link OrderWithTimestamp} instance and return the same instance. + * + * @param timestamp The timestamp of this {@link OrderWithTimestamp} + * @return The same instance of this {@link OrderWithTimestamp} class + */ + @Nonnull public OrderWithTimestamp timestamp( @Nullable final OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * @return timestamp The timestamp of this {@link OrderWithTimestamp} instance. + */ + @Nonnull + public OffsetDateTime getTimestamp() { + return timestamp; + } + + /** + * Set the timestamp of this {@link OrderWithTimestamp} instance. + * + * @param timestamp The timestamp of this {@link OrderWithTimestamp} + */ + public void setTimestamp( @Nullable final OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * Get the names of the unrecognizable properties of the {@link OrderWithTimestamp}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link OrderWithTimestamp} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("OrderWithTimestamp has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link OrderWithTimestamp} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final OrderWithTimestamp orderWithTimestamp = (OrderWithTimestamp) o; + return Objects.equals(this.cloudSdkCustomFields, orderWithTimestamp.cloudSdkCustomFields) && + Objects.equals(this.productId, orderWithTimestamp.productId) && + Objects.equals(this.quantity, orderWithTimestamp.quantity) && + Objects.equals(this.totalPrice, orderWithTimestamp.totalPrice) && + Objects.equals(this.typelessProperty, orderWithTimestamp.typelessProperty) && + Objects.equals(this.nullableProperty, orderWithTimestamp.nullableProperty) && + Objects.equals(this.timestamp, orderWithTimestamp.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash(productId, quantity, totalPrice, typelessProperty, nullableProperty, timestamp, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class OrderWithTimestamp {\n"); + sb.append(" productId: ").append(toIndentedString(productId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" totalPrice: ").append(toIndentedString(totalPrice)).append("\n"); + sb.append(" typelessProperty: ").append(toIndentedString(typelessProperty)).append("\n"); + sb.append(" nullableProperty: ").append(toIndentedString(nullableProperty)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/Soda.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/Soda.java new file mode 100644 index 000000000..897c194df --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/Soda.java @@ -0,0 +1,353 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Soda + */ +// CHECKSTYLE:OFF +public class Soda +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("brand") + private String brand; + + @JsonProperty("quantity") + private Integer quantity; + + /** + * Gets or Sets packaging + */ + public enum PackagingEnum { + /** + * The GLASS option of this Soda + */ + GLASS("glass"), + + /** + * The CARTON option of this Soda + */ + CARTON("carton"), + + /** + * The CAN option of this Soda + */ + CAN("can"); + + private String value; + + PackagingEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * @return The enum value + */ + @JsonValue + @Nonnull public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * @return The enum value as String + */ + @Override + @Nonnull public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * @param value The String value + * @return The enum value of type Soda + */ + @JsonCreator + @Nonnull public static PackagingEnum fromValue(@Nonnull final String value) { + for (PackagingEnum b : PackagingEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("packaging") + private PackagingEnum packaging; + + @JsonProperty("price") + private Float price; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link Soda} instance and return the same instance. + * + * @param name The name of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda name( @Nonnull final String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name The name of this {@link Soda} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link Soda} instance. + * + * @param name The name of this {@link Soda} + */ + public void setName( @Nonnull final String name) { + this.name = name; + } + + /** + * Set the brand of this {@link Soda} instance and return the same instance. + * + * @param brand The brand of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda brand( @Nonnull final String brand) { + this.brand = brand; + return this; + } + + /** + * Get brand + * @return brand The brand of this {@link Soda} instance. + */ + @Nonnull + public String getBrand() { + return brand; + } + + /** + * Set the brand of this {@link Soda} instance. + * + * @param brand The brand of this {@link Soda} + */ + public void setBrand( @Nonnull final String brand) { + this.brand = brand; + } + + /** + * Set the quantity of this {@link Soda} instance and return the same instance. + * + * @param quantity The quantity of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda quantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity The quantity of this {@link Soda} instance. + */ + @Nonnull + public Integer getQuantity() { + return quantity; + } + + /** + * Set the quantity of this {@link Soda} instance. + * + * @param quantity The quantity of this {@link Soda} + */ + public void setQuantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + } + + /** + * Set the packaging of this {@link Soda} instance and return the same instance. + * + * @param packaging The packaging of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda packaging( @Nullable final PackagingEnum packaging) { + this.packaging = packaging; + return this; + } + + /** + * Get packaging + * @return packaging The packaging of this {@link Soda} instance. + */ + @Nonnull + public PackagingEnum getPackaging() { + return packaging; + } + + /** + * Set the packaging of this {@link Soda} instance. + * + * @param packaging The packaging of this {@link Soda} + */ + public void setPackaging( @Nullable final PackagingEnum packaging) { + this.packaging = packaging; + } + + /** + * Set the price of this {@link Soda} instance and return the same instance. + * + * @param price The price of this {@link Soda} + * @return The same instance of this {@link Soda} class + */ + @Nonnull public Soda price( @Nonnull final Float price) { + this.price = price; + return this; + } + + /** + * Get price + * @return price The price of this {@link Soda} instance. + */ + @Nonnull + public Float getPrice() { + return price; + } + + /** + * Set the price of this {@link Soda} instance. + * + * @param price The price of this {@link Soda} + */ + public void setPrice( @Nonnull final Float price) { + this.price = price; + } + + /** + * Get the names of the unrecognizable properties of the {@link Soda}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link Soda} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("Soda has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link Soda} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Soda soda = (Soda) o; + return Objects.equals(this.cloudSdkCustomFields, soda.cloudSdkCustomFields) && + Objects.equals(this.name, soda.name) && + Objects.equals(this.brand, soda.brand) && + Objects.equals(this.quantity, soda.quantity) && + Objects.equals(this.packaging, soda.packaging) && + Objects.equals(this.price, soda.price); + } + + @Override + public int hashCode() { + return Objects.hash(name, brand, quantity, packaging, price, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Soda {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" packaging: ").append(toIndentedString(packaging)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/SodaWithId.java b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/SodaWithId.java new file mode 100644 index 000000000..ec29ae38f --- /dev/null +++ b/datamodel/openapi/openapi-generator/src/test/resources/DataModelGeneratorIntegrationTest/remove-operation-id-prefix/output/com/sap/cloud/sdk/services/builder/model/SodaWithId.java @@ -0,0 +1,387 @@ +/* + * Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. + */ + +/* + * SodaStore API + * API for managing soda products and orders in SodaStore. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sap.cloud.sdk.services.builder.model; + +import java.util.Objects; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * SodaWithId + */ +// CHECKSTYLE:OFF +public class SodaWithId +// CHECKSTYLE:ON +{ + @JsonProperty("name") + private String name; + + @JsonProperty("brand") + private String brand; + + @JsonProperty("quantity") + private Integer quantity; + + /** + * Gets or Sets packaging + */ + public enum PackagingEnum { + /** + * The GLASS option of this SodaWithId + */ + GLASS("glass"), + + /** + * The CARTON option of this SodaWithId + */ + CARTON("carton"), + + /** + * The CAN option of this SodaWithId + */ + CAN("can"); + + private String value; + + PackagingEnum(String value) { + this.value = value; + } + + /** + * Get the value of the enum + * @return The enum value + */ + @JsonValue + @Nonnull public String getValue() { + return value; + } + + /** + * Get the String value of the enum value. + * @return The enum value as String + */ + @Override + @Nonnull public String toString() { + return String.valueOf(value); + } + + /** + * Get the enum value from a String value + * @param value The String value + * @return The enum value of type SodaWithId + */ + @JsonCreator + @Nonnull public static PackagingEnum fromValue(@Nonnull final String value) { + for (PackagingEnum b : PackagingEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("packaging") + private PackagingEnum packaging; + + @JsonProperty("price") + private Float price; + + @JsonProperty("id") + private Long id; + + @JsonAnySetter + @JsonAnyGetter + private final Map cloudSdkCustomFields = new LinkedHashMap<>(); + + /** + * Set the name of this {@link SodaWithId} instance and return the same instance. + * + * @param name The name of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull public SodaWithId name( @Nonnull final String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name The name of this {@link SodaWithId} instance. + */ + @Nonnull + public String getName() { + return name; + } + + /** + * Set the name of this {@link SodaWithId} instance. + * + * @param name The name of this {@link SodaWithId} + */ + public void setName( @Nonnull final String name) { + this.name = name; + } + + /** + * Set the brand of this {@link SodaWithId} instance and return the same instance. + * + * @param brand The brand of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull public SodaWithId brand( @Nonnull final String brand) { + this.brand = brand; + return this; + } + + /** + * Get brand + * @return brand The brand of this {@link SodaWithId} instance. + */ + @Nonnull + public String getBrand() { + return brand; + } + + /** + * Set the brand of this {@link SodaWithId} instance. + * + * @param brand The brand of this {@link SodaWithId} + */ + public void setBrand( @Nonnull final String brand) { + this.brand = brand; + } + + /** + * Set the quantity of this {@link SodaWithId} instance and return the same instance. + * + * @param quantity The quantity of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull public SodaWithId quantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get quantity + * @return quantity The quantity of this {@link SodaWithId} instance. + */ + @Nonnull + public Integer getQuantity() { + return quantity; + } + + /** + * Set the quantity of this {@link SodaWithId} instance. + * + * @param quantity The quantity of this {@link SodaWithId} + */ + public void setQuantity( @Nonnull final Integer quantity) { + this.quantity = quantity; + } + + /** + * Set the packaging of this {@link SodaWithId} instance and return the same instance. + * + * @param packaging The packaging of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull public SodaWithId packaging( @Nullable final PackagingEnum packaging) { + this.packaging = packaging; + return this; + } + + /** + * Get packaging + * @return packaging The packaging of this {@link SodaWithId} instance. + */ + @Nonnull + public PackagingEnum getPackaging() { + return packaging; + } + + /** + * Set the packaging of this {@link SodaWithId} instance. + * + * @param packaging The packaging of this {@link SodaWithId} + */ + public void setPackaging( @Nullable final PackagingEnum packaging) { + this.packaging = packaging; + } + + /** + * Set the price of this {@link SodaWithId} instance and return the same instance. + * + * @param price The price of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull public SodaWithId price( @Nonnull final Float price) { + this.price = price; + return this; + } + + /** + * Get price + * @return price The price of this {@link SodaWithId} instance. + */ + @Nonnull + public Float getPrice() { + return price; + } + + /** + * Set the price of this {@link SodaWithId} instance. + * + * @param price The price of this {@link SodaWithId} + */ + public void setPrice( @Nonnull final Float price) { + this.price = price; + } + + /** + * Set the id of this {@link SodaWithId} instance and return the same instance. + * + * @param id The id of this {@link SodaWithId} + * @return The same instance of this {@link SodaWithId} class + */ + @Nonnull public SodaWithId id( @Nullable final Long id) { + this.id = id; + return this; + } + + /** + * Get id + * @return id The id of this {@link SodaWithId} instance. + */ + @Nonnull + public Long getId() { + return id; + } + + /** + * Set the id of this {@link SodaWithId} instance. + * + * @param id The id of this {@link SodaWithId} + */ + public void setId( @Nullable final Long id) { + this.id = id; + } + + /** + * Get the names of the unrecognizable properties of the {@link SodaWithId}. + * @return The set of properties names + */ + @JsonIgnore + @Nonnull + public Set getCustomFieldNames() { + return cloudSdkCustomFields.keySet(); + } + + /** + * Get the value of an unrecognizable property of this {@link SodaWithId} instance. + * @param name The name of the property + * @return The value of the property + * @throws NoSuchElementException If no property with the given name could be found. + */ + @Nullable + public Object getCustomField( @Nonnull final String name ) throws NoSuchElementException { + if( !cloudSdkCustomFields.containsKey(name) ) { + throw new NoSuchElementException("SodaWithId has no field with name '" + name + "'."); + } + return cloudSdkCustomFields.get(name); + } + + /** + * Set an unrecognizable property of this {@link SodaWithId} instance. If the map previously contained a mapping + * for the key, the old value is replaced by the specified value. + * @param customFieldName The name of the property + * @param customFieldValue The value of the property + */ + @JsonIgnore + public void setCustomField( @Nonnull String customFieldName, @Nullable Object customFieldValue ) + { + cloudSdkCustomFields.put(customFieldName, customFieldValue); + } + + + @Override + public boolean equals(@Nullable final java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final SodaWithId sodaWithId = (SodaWithId) o; + return Objects.equals(this.cloudSdkCustomFields, sodaWithId.cloudSdkCustomFields) && + Objects.equals(this.name, sodaWithId.name) && + Objects.equals(this.brand, sodaWithId.brand) && + Objects.equals(this.quantity, sodaWithId.quantity) && + Objects.equals(this.packaging, sodaWithId.packaging) && + Objects.equals(this.price, sodaWithId.price) && + Objects.equals(this.id, sodaWithId.id); + } + + @Override + public int hashCode() { + return Objects.hash(name, brand, quantity, packaging, price, id, cloudSdkCustomFields); + } + + @Override + @Nonnull public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class SodaWithId {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" brand: ").append(toIndentedString(brand)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" packaging: ").append(toIndentedString(packaging)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + cloudSdkCustomFields.forEach((k,v) -> sb.append(" ").append(k).append(": ").append(toIndentedString(v)).append("\n")); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(final java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/datamodel/openapi/pom.xml b/datamodel/openapi/pom.xml index bc04a3cf5..4154e6ade 100644 --- a/datamodel/openapi/pom.xml +++ b/datamodel/openapi/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT openapi-parent pom diff --git a/datamodel/pom.xml b/datamodel/pom.xml index 13bd64a34..250114563 100644 --- a/datamodel/pom.xml +++ b/datamodel/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT com.sap.cloud.sdk.datamodel datamodel-parent diff --git a/datamodel/soap/pom.xml b/datamodel/soap/pom.xml index 9999b6eea..234d05958 100644 --- a/datamodel/soap/pom.xml +++ b/datamodel/soap/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.datamodel datamodel-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT soap Data Model - SOAP Queries diff --git a/dependency-bundles/bom/pom.xml b/dependency-bundles/bom/pom.xml index 65fcc4e5e..613725e1b 100644 --- a/dependency-bundles/bom/pom.xml +++ b/dependency-bundles/bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.sap.cloud.sdk sdk-bom - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT pom SAP Cloud SDK - Modules and Dependencies BOM Bill of Materials (BOM) of the SAP Cloud SDK modules and dependencies. @@ -35,28 +35,28 @@ Public Stable - 5.13.0-SNAPSHOT - 0.10.5 + 5.15.0-SNAPSHOT + 0.20.0 4.4.16 - 5.3 - 5.3.1 + 5.3.1 + 5.4.1 4.5.14 6.1.0 - 3.5.3 + 3.5.5 4.4.0 2.0.16 - 1.18.34 + 1.18.36 3.0.2 - 0.10.4 - 33.3.0-jre + 0.10.5 + 33.3.1-jre - 2.16.1 + 2.18.0 1.7.9 @@ -68,7 +68,7 @@ 2.2.0 2.11.0 - 2.17.2 + 2.18.2 1.2.3 @@ -264,13 +264,13 @@ org.checkerframework checker-qual - 3.47.0 + 3.48.3 com.google.errorprone error_prone_annotations - 2.32.0 + 2.36.0 diff --git a/dependency-bundles/modules-bom/pom.xml b/dependency-bundles/modules-bom/pom.xml index 78e725cdb..93140bce2 100644 --- a/dependency-bundles/modules-bom/pom.xml +++ b/dependency-bundles/modules-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.sap.cloud.sdk sdk-modules-bom - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT pom SAP Cloud SDK - Modules BOM Bill of Materials (BOM) of the SAP Cloud SDK modules. @@ -35,7 +35,7 @@ Public Stable - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT diff --git a/dependency-bundles/sdk-core/pom.xml b/dependency-bundles/sdk-core/pom.xml index 8ca4a5188..86f7457a0 100644 --- a/dependency-bundles/sdk-core/pom.xml +++ b/dependency-bundles/sdk-core/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT ../../pom.xml sdk-core diff --git a/latest.json b/latest.json index 5703d0978..90810bfad 100644 --- a/latest.json +++ b/latest.json @@ -1,3 +1,3 @@ { - "version": "5.13.0-SNAPSHOT" + "version": "5.15.0-SNAPSHOT" } diff --git a/pom.xml b/pom.xml index 1aa2d5511..68806aee7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT pom SAP Cloud SDK - Parent POM Parent POM of the SAP Cloud SDK. @@ -44,7 +44,7 @@ Public Stable - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT 3.5 17 true @@ -83,8 +83,8 @@ ${project.build.directory}/coverage-reports/jacoco.exec **/testclasses/** - 4.85.8 - 2.17.2 + 4.87.9 + 2.18.2 1.10 20240303 @@ -94,33 +94,35 @@ - 6.1.13 + 6.2.0 6.1.5 2.0.16 3.26.3 0.4.3 - 5.13.0 + 5.14.2 1.5.3 - 5.11.0 + 5.11.3 2.6 5.0.0 2.0.13 3.9.9 - 3.15.0 + 3.15.1 3.3.0 3.1.8 - 7.8.0 - 2.2.23 - 2.1.22 + 7.10.0 + 2.2.26 + 2.1.24 1.6.11 4.2.2 - 1.78.1 + 1.79 2.1.0 - 2.1.0 - 3.9.1 - 10.18.1 - 1.15.1 + 2.2.0 + 3.10.0 + 10.20.2 + 1.15.11 + 2.3 + 1.17.1 true @@ -392,7 +394,13 @@ commons-codec commons-codec - 1.17.1 + ${commons-codec.version} + + + + org.yaml + snakeyaml + ${snakeyaml.version} @@ -689,7 +697,7 @@ org.apache.maven.plugins maven-dependency-plugin - 3.8.0 + 3.8.1 analyze @@ -779,17 +787,17 @@ org.apache.maven.plugins maven-site-plugin - 3.20.0 + 3.21.0 org.apache.maven.plugins maven-archetype-plugin - 3.2.1 + 3.3.1 org.apache.maven.plugins maven-plugin-plugin - 3.15.0 + 3.15.1 org.codehaus.mojo @@ -849,7 +857,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.0 + 3.5.2 ${surefire.include} @@ -869,7 +877,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.5.0 + 3.6.0 com.puppycrawl.tools @@ -888,7 +896,7 @@ com.github.spotbugs spotbugs-maven-plugin - 4.8.6.4 + 4.8.6.6 ${project.rootdir}/codestyle/findbugs.xml ${project.rootdir}/codestyle/spotbugs-exclusions.xml @@ -900,7 +908,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.25.0 + 3.26.0 ${project.rootdir}/codestyle/pmd.xml @@ -949,7 +957,7 @@ org.projectlombok lombok - 1.18.34 + 1.18.36 @@ -977,7 +985,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.10.0 + 3.11.2 javadoc-jar diff --git a/release_notes.md b/release_notes.md index 7946fb8bf..cb9242caa 100644 --- a/release_notes.md +++ b/release_notes.md @@ -8,22 +8,20 @@ ### 🔧 Compatibility Notes -- Minimum required versions: - - SAP BTP Security Services Integration Libraries `com.sap.cloud.security` 3.4.3 - - CAP `com.sap.cds` 2.9.3 - - SAP Java Buildpack `com.sap.cloud.sjb` 2.10.0 -- Using IAS requires XSUAA version to be minimum `3.4.0`. -- Change the `DefaultHttpDestination.Builder` to throw an exception when the proxy configuration can not be determined for on-premise destinations. - Previously, only an error was logged to give a grace period for analyzing and fixing the underlying issue. +- ### ✨ New Functionality -- +- Add support for `TypeDefinition` entries in OData V4 EDMX files. +- Add `generateApis` and `generateModels` options to the `openapi-generator-maven-plugin` to + disable the generation of APIs and models respectively. ### 📈 Improvements -- +- Stabilize most of the remaining experimental APIs without changes, e.g. + - RequestHeaderAccessor + - ServiceBindingDestinationLoader ### 🐛 Fixed Issues -- OpenAPI QueryParameters are now encoded +- Fix ApacheHttpClient5Wrapper to propagate the configuration to Spring RestTemplate. diff --git a/s4hana/pom.xml b/s4hana/pom.xml index a8dfe1b46..be8221853 100644 --- a/s4hana/pom.xml +++ b/s4hana/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT com.sap.cloud.sdk.s4hana s4hana-parent diff --git a/s4hana/rfc/pom.xml b/s4hana/rfc/pom.xml index f712fe290..0f0b4fdff 100644 --- a/s4hana/rfc/pom.xml +++ b/s4hana/rfc/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.s4hana s4hana-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT rfc SAP S/4HANA - RFC Queries diff --git a/s4hana/s4hana-connectivity/pom.xml b/s4hana/s4hana-connectivity/pom.xml index 070216f00..50168a277 100644 --- a/s4hana/s4hana-connectivity/pom.xml +++ b/s4hana/s4hana-connectivity/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.s4hana s4hana-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT s4hana-connectivity SAP S/4HANA - Connectivity diff --git a/s4hana/s4hana-core/pom.xml b/s4hana/s4hana-core/pom.xml index dbc91eb91..9ceefe03c 100644 --- a/s4hana/s4hana-core/pom.xml +++ b/s4hana/s4hana-core/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk.s4hana s4hana-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT s4hana-core SAP S/4HANA - Core diff --git a/testutil/pom.xml b/testutil/pom.xml index e935ee3a2..033b6c9dd 100644 --- a/testutil/pom.xml +++ b/testutil/pom.xml @@ -4,7 +4,7 @@ com.sap.cloud.sdk sdk-parent - 5.13.0-SNAPSHOT + 5.15.0-SNAPSHOT testutil (Internal) Test Utilities