-
Notifications
You must be signed in to change notification settings - Fork 4
INTER-1491: Migrate SDK to APIv4 #126
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
base: main
Are you sure you want to change the base?
Conversation
Renamed solution and project artifacts: - `fingerprint-pro-server-api-dotnet-sdk.sln` to `fingerprint-server-dotnet-sdk.sln`. - `src/FingerprintPro.ServerSdk*` to `src/Fingerprint.ServerSdk*`. - Updated `*.csproj` names. Updated namespaces and related code references: - `FingerprintPro.ServerSdk.*` -> `Fingerprint.ServerSdk.*` - Adjusted README code samples to use `using Fingerprint.ServerSdk;` Updated docker image and compose service names to `fingerprint-server-dotnet-sdk`. Updated `bumpConfig.mjs` path points to the new `Fingerprint.ServerSdk.csproj`. `.swagger-codegen-ignore` paths updated to the new directory. Changelog title also updated to the new project name. **BREAKING CHANGE** - All `using` directives and type references must change from `FingerprintPro.ServerSdk` to `Fingerprint.ServerSdk`. - If you reference project/solution files (or Docker images by name), update them to the new names. **MIGRATION GUIDE** - Replace namespace imports: - `using FingerprintPro.ServerSdk;` -> `using Fingerprint.ServerSdk;` - Update any fully-qualified types/references (e.g., `.Model.*`) to the new root namespace. - If you run examples/tests via Docker-Compose, rebuild with the new image/tag and use the updated `docker-compose.yml` file. - If you reference the solution or project files directly in CI pipeline/script, update the paths to `Fingerprint.ServerSdk/`. Related-Task: INTER-1491
Added `set -euo pipefail` for safer and more predictable script behavior (early fail). Made sure required directories are created before writing files (current example list doesn't have additional directory). Switched to `curl -fSL` for better error handling and redirect support. Related-Task: INTER-1491
Removes unnecessary model files for Server APIv4 Related-Task: INTER-1491
Integrates Server APIv4 with `openapi-generator`. Related-Task: INTER-1491
🦋 Changeset detectedLatest commit: 2148758 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Ignore `/bin` directory. Add `.NET` section header to the `.gitignore` file. Remove vendored `bin/openapi-generator-cli.jar` from VCS. Update `generate.sh` script to download openapi-generator-cli if it's not exists. Related-Task: INTER-1491
Adds `DecryptionKey.md`, `Sealed.md`, and `WebhookValidation.md` files to template and update `config.json` to generate them. Related-Task: INTER-1491
Removed `dotnet format` from the generate process. Renamed fields in Tests. Fixed style issues for SDK. Related-Task: INTER-1491
Removes `docs` and `src/Fingerprint.ServerSdk` before generating SDK. Related-Task: INTER-1491
Updated the Solution template to surround the project GUID with `{}` in
both the `Project` line and `ProjectConfigurationPlatforms` mapppings.
Related-Task: INTER-1491
Adds missing `errors/400_ip_address_invalid.json` mock file. Related-Task: INTER-1491
Add JsonSerializer to the `Fingerprint.ServerSdk.SealedResultExample` project. Related-Task: INTER-1491
Update OpenAPI schema to generate `EventUpdate.tags` as `Dictionary<string, object`> instead of `Object`. Related-Task: INTER-1491
Add `UPDATE_REQUEST_ID` to `.env.example` for updating different request id. Rename example project from `examples` to `Fingerprint.ServerSdk.Examples`. Add base `ExampleException` to expose `IApiResponse`. Convert examples to new structure (`async`). Validate env values before triggering tasks. Related-Task: INTER-1491
Migrate `nunit` to `xunit` for `Fingerprint.ServerSdk.FunctionalTest` project. Use Generic Host for the functional test project. Migrate functional tests to new Server API v4. Use `IAsyncLifetime` to async initialization. Remove unnecessary `Usings.cs` file. Related-Task: INTER-1491
Use correct names for bearer token. Related-Task: INTER-1491
Changes case sensitivity for `IPBlocklist`, `VPNConfidence`, `VPNMethods` Related-Task: INTER-1491
Use different case for `IPBlocklist`, `VPNConfidence`, and `VPNMethods` generated models. Related-Task: INTER-1491
Use correct case for `IPBlocklist`, `VPNConfidence`, and `VPNMethods` models. Related-Task: INTER-1491
Use different case for model names and file names. Related-Task: INTER-1491
Removes case issue model files from the VCS. Related-Task: INTER-1491
Use `en_US.UTF-8` localization for generating SDK. Related-Task: INTER-1491
Removed unnecessary `mono_nunit_test` script. Related-Task: INTER-1491
Fixes solution file name for Dockerfile image. Related-Task: INTER-1491
Use only `net8.0` target framework for the `Fingerprint.ServerSdk.Test` project. Related-Task: INTER-1491
Add missing xml docs for `HostConfiguration.cs` file. Related-Task: INTER-1491
Adds user agent testing to `DependencyInjectionTests` test file. Related-Task: INTER-1491
Replace `Array.Empty<string>()` with simple `[]` in DI test setup. Use discards for unused lambda parameters. Remove unused `System` import. Drop `net800rLater` conditions in template file because we only target `net80`. Related-Task: INTER-1491
Replace `appDescription` with `packageDescription` to generate file headers. Related-Task: INTER-1491
Replace concrete `new` lines with target-typed `new`. Use collection expressions. Remove unused `System.Collections.Generic`. Related-Task: INTER-1491
|
|
||
| # Prepare OpenAPI Generator CLI | ||
| OPENAPI_GENERATOR_FILE="./bin/openapi-generator-cli.jar" | ||
| OPENAPI_GENERATOR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.16.0/openapi-generator-cli-7.16.0.jar" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the pros of downloading it each time and not keeping it in git?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It significantly increases the VCS repo size (~30 MB), and since it's a binary file, the only real benefit I see to keeping it in VC is security (if Maven has an outage or the file gets tampered with) and also having a static mirror. Having large files can be problematic for developers. If we're concerned about security, we could host our own remote mirror and keep it up to date instead. I'm also okay to use a static JAR file, but I prefer a small repository size.
P.S. Developers (not CI) will download it once because it doesn't download the file if it exists
|
|
||
| // HttpResponseMessage | ||
| Console.WriteLine(visits.Response); | ||
| public class Program |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a complete scenario here and not just the API configuration for the DI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you review the README changes in commit #b2ae80e? Let me know if it's enough or if you'd like me to add or remove anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks good!
| @@ -0,0 +1,6 @@ | |||
| { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more of them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell from reviewing the tests, we're not using the other errors. So I kept only the ones we actually use and updated the sync.sh script accordingly.
Add csharp generic host examples for operations to `api_doc` documentation. Related-Task: INTER-1491
Reformat model docs to use unescaped description for the model. Implement conditional properties table to avoid empty markdown table. Related-Task: INTER-1491
Use unescaped summary and notes for operation descriptions. This replaces HTML entities in generated XML docs with the real character. Related-Task: INTER-1491
Replace `REQUEST_ID` and `UPDATE_REQUEST_ID` with `EVENT_ID` and `UPDATE_EVENT_ID` names. Use named arguments in example project. Related-Task: INTER-1491
Expand `README.md` example to use `TryOk` and `isOk` patterns for `GetEventAsync` and `SearchEventsAsync` operations. Also show accessing `RawContent`, `Headers` and `StatusCode`. Include an `UpdateEventAsync` example with an example `EventUpdate` instance.
Upgrade `BouncyCastle.Cryptography` from `2.4.0` to `2.6.2` version. No breaking changes for our usage, no code changes required in the SDK. Compiles cleanly and test suite passes. Change list (upstream diff) can be found [here](bcgit/bc-csharp@release-2.4.0...release-2.6.2) Related-Task: INTER-1491
Bump `System.Threading.Channels` from `8.0.0` to `9.0.10` version. No breaking changes for our usage (only `` RateLimitProvider`1.cs `` is using). No code changes required in the SDK. Related-Task: INTER-1491
Update `Microsoft.Extensions.Http` and `Microsoft.Extensions.Http.Polly` packages to `9.0.10` version. Related-Task: INTER-1491
Update `Microsoft.Extensions.Hosting` package to the `9.0.10` version. Related-Task: INTER-1491
76a4aba to
2148758
Compare
🚀 Following releases will be created using changesets from this PR:[email protected]Major Changes
|
This PR upgrades the Server SDK to the Server API v4. It removes Server APIv3 specific behavior and aligns the SDK with the new events format shared by Server API and Webhooks.
INTER-1491
❓ Why?
data/products/resultnesting), switches to Bearer auth, unifies Webhooks & Server APIeventformats, and deprecates/visitorsin favor of/v4/events.⚙️ What Changed?
FingerprintPro.ServerSdktoFingerprint.ServerSdk../bin/swagger-codegen-cli.jarand updatedgenerate.shto downloadopenapi-generator-cli.jar(if it doesn't exist).Configurationclass and implementedClient/BearerToken.cs,Client/TokenBase.cs,Client/TokenContainer`1.cs,Client/TokenProvider`1.cs,RateLimitProvider`1.cs.JsonSerializationOptions.<Operation>Asyncand<Operation>AsyncOrDefaultmethods to interact with the Server API.FingerprintApiEvents.usingdirectives and type references must change fromFingerprintPro.ServerSdktoFingerprint.ServerSdk.update them to the new names.
FingerprintApiinitialization changed. Prefer Generic Host + ConfigureApi instead of ad-hoc static configuration.SECRET_API_KEYvia DI (see Migration Guide).requestIdmust switch toeventId(e.g.,GetEventAsyncnow expectseventId)..toJson()methods in models.📦 Migration Guide (SDK Consumers)
1) Change package reference to new name
Replace
FingerprintPro.ServerSdkpackage references to new name.2) Update package/namespace imports
Replace namespace imports:
using FingerprintPro.ServerSdk;->using Fingerprint.ServerSdk;3) Switch to DI setup Generic Host (Auth and Region)
Before (v7.x, implicit
apiKeyusage):After (v8.x, Bearer + Generic Host):
4) Replace request IDs with event IDs
5) Typed API responses
FingerprintApimethods now return a typed response wrapper that models both success and error outcomes.You can check the outcome with the boolean properties and then safely access the typed payload via helpers:
IsOk,IsNotFound,IsBadRequest,IsForbidden,IsInternalServerError, ....Ok(),.NotFound(),.BadRequest(),.Forbidden(),.InternalServerError(), ....TryOk(out var ok),.TryNotFound(out var err),.TryBadRequest(out var err), ....RawContent,.StatusCode6) Remove
Tagusage inEventUpdate, useDictionary<string, object>7) Use
Tagskey instead ofTagwhen creatingEventUpdatemodelvar body = new EventsUpdateRequest() { Suspect = false, - Tag = tag, + Tags = tag, LinkedId = "<linked_id>" };8) Use new JsonConverters instead of
.toJson()methodRemoved
.toJson()method from the models. Use new special JsonConverters for models when converting models to JSON.You can also use our JsonConverters:
9) Docker image and compose changes
If you run examples/tests via Docker-Compose, rebuild with the new image/tag and use the updated
docker-compose.ymlfile.10) Check new models and types
Please check Migrating from Server API v3 to v4 migration guide.