Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

refactor: replace generated ApiClient with a manual one #76

Conversation

paullatzelsperger
Copy link
Member

@paullatzelsperger paullatzelsperger commented Mar 9, 2023

What this PR changes/adds

Replaces the auto-generated API client with an "explicitly" implemented one.

Why it does that

both the API controller and the client are in this repository, so it does not make much sense to generate the client.
Further, the generated one used the Java Http client, whereas now we can use the EdcHttpClient.

Further notes

  • added a smoke test against a MockWebServer to verify that the client sends the correct requests.

Linked Issue(s)

Closes #75

Checklist

  • added appropriate tests?
  • performed checkstyle check locally?
  • added/updated copyright headers?
  • documented public classes/methods?
  • added/updated relevant documentation?
  • added relevant details to the changelog? (skip with label no-changelog)
  • formatted title correctly? (take a look at the CONTRIBUTING and styleguide for details)

@paullatzelsperger paullatzelsperger added the refactoring Changes that affect the structure of the code rather than functionality label Mar 9, 2023
Copy link
Contributor

@bscholtes1A bscholtes1A left a comment

Choose a reason for hiding this comment

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

Seems that most new files are missing the legal file headers. Could you please add them?

implementation(libs.jackson.core)
implementation(libs.bundles.jackson)
implementation(libs.openapi.jackson.databind.nullable)

testImplementation("com.squareup.okhttp3:mockwebserver:4.10.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

needed?

Copy link
Member Author

@paullatzelsperger paullatzelsperger Mar 11, 2023

Choose a reason for hiding this comment

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

yes - i'm testing the client against the MockServer. An alternative would be to test directly against the RegistrationServiceApiController, but that would mean spinning up a complete connector runtime.

@paullatzelsperger
Copy link
Member Author

paullatzelsperger commented Mar 10, 2023

Seems that most new files are missing the legal file headers. Could you please add them?

Will do, thx for noticing

@paullatzelsperger paullatzelsperger force-pushed the refactor/75_replace_generated_apiclient branch from a593aa6 to 25d4f07 Compare March 12, 2023 09:03
@paullatzelsperger paullatzelsperger force-pushed the refactor/75_replace_generated_apiclient branch from 0f6ebdb to 00e0adc Compare March 12, 2023 09:13
var connectTimeout = Integer.parseInt(propOrEnv(API_CLIENT_CONNECT_TIMEOUT, "30"));
var readTimeout = Integer.parseInt(propOrEnv(API_CLIENT_READ_TIMEOUT, "60"));
public static RegistryApiClient createApiClient(String baseUri, Function<TokenParameters, Result<TokenRepresentation>> credentialsProvider, Monitor monitor, ObjectMapper objectMapper) {
var connectTimeout = Duration.ofSeconds(Integer.parseInt(propOrEnv(API_CLIENT_CONNECT_TIMEOUT, "30")));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
var readTimeout = Integer.parseInt(propOrEnv(API_CLIENT_READ_TIMEOUT, "60"));
public static RegistryApiClient createApiClient(String baseUri, Function<TokenParameters, Result<TokenRepresentation>> credentialsProvider, Monitor monitor, ObjectMapper objectMapper) {
var connectTimeout = Duration.ofSeconds(Integer.parseInt(propOrEnv(API_CLIENT_CONNECT_TIMEOUT, "30")));
var readTimeout = Duration.ofSeconds(Integer.parseInt(propOrEnv(API_CLIENT_READ_TIMEOUT, "60")));

Check notice

Code scanning / CodeQL

Missing catch of NumberFormatException

Potential uncaught 'java.lang.NumberFormatException'.
@paullatzelsperger paullatzelsperger merged commit dfc7f41 into eclipse-edc:main Mar 15, 2023
@paullatzelsperger paullatzelsperger deleted the refactor/75_replace_generated_apiclient branch March 15, 2023 08:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
refactoring Changes that affect the structure of the code rather than functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace generated ApiClient with an explicit one
2 participants