8000 chore: [OpenAPI] Reduce Spring dependency by newtork · Pull Request #754 · SAP/cloud-sdk-java · GitHub
[go: up one dir, main page]

Skip to content

chore: [OpenAPI] Reduce Spring dependency #754

8000
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

newtork
Copy link
Contributor
@newtork newtork commented Mar 14, 2025

Context

https://github.com/SAP/cloud-sdk-java-backlog/issues/464

We want to reduce the Spring dependency.

Currently:

  • Users require explicit org.springframework:spring-core::compile
  • Users require explicit org.springframework:spring-web::compile

Expected (1):

  • Legacy users are not negatively affected by change
  • Users do not require explicit org.springframework:spring-core::compile
  • Users do not require explicit org.springframework:spring-web::compile

Expected (2):

  • Legacy users are not negatively affected by change
  • Users do not require transitive org.springframework:spring-core::compile
  • Users do not require transitive org.springframework:spring-web::compile

Feature scope:

  • Update mustache file to reduce Spring types from public API (70%)

    • Weaken openapi-core API contract to allow for non-Spring typed arguments
    • Newly generated service API classes use non-Spring typed code.
    • Sample project is updated to motivate changes.
  • Harden and improve openapi-core API contract

    • offer legacy weak API (for Spring and non-Spring typed arguments)
      • Spring classes are coming from optional-scoped dependencies.
    • offer new, improved and recommended API (for non-Spring-typed arguments)
  • Update mustache file to use recommended API

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

a-d added 7 commits March 14, 2025 14:42
# Conflicts:
#	datamodel/openapi/openapi-api-sample/pom.xml
#	datamodel/openapi/openapi-api-sample/src/test/java/com/sap/cloud/sdk/datamodel/openapi/sample/api/OneOfDeserializationTest.java
* @return The response body in chosen type
* @throws OpenApiRequestException
* Thrown in case an exception occurs during invocation of the REST API
*/
@SuppressWarnings( "unchecked" )
@Nullable
public <T> T invokeAPI(
Copy link
Contributor Author
@newtork newtork Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Comment)

Weaken API contract to allow non-Spring arguments:

image

Update in usage:

image

First step:

  • Remove Spring requirement from public API.
    • No breaking change with existing generated code.
    • Code quality must still be improved though: Deprecation, Replacement, Delegation.

Next step:

  • Improve code by offering an implementation for invokeAPI that does not require transitive Spring dependencies. While keeping legacy consumers unaffected on API contract.

Comment on lines 62 to -68
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
Copy link
Contributor Author
@newtork newtork Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Comment)

For the users, this is already a significant improvement!

@newtork newtork added do not merge Pull request must not be merged please review Request to review a pull request labels Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Pull request must not be merged please review Request to review a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0