Skip to content

Conversation

@brettchaldecott
Copy link
Contributor

Explain your changes

This PR implements converters to work around the json serialisation issues that affect the 7 line of OpenAPI. The changes are the following:

  1. Auto generation of converters to and from requests.
  2. Auto generation of required integration tests for the converters.
  3. Full integration testing for the converters against Kinde if configured.
  4. Full mock testing of converters if configured.

This line maintains compatibility with the 2.0.x line and does not implement any breaking changes with it.

Checklist

🛟 If you need help, consider asking for advice over in the Kinde community.

Brett Chaldecott and others added 2 commits November 7, 2025 09:14
Major Changes:
- Updated generate-converters.py to handle both Request and Response models
- Added support for required (non-Option) constructor parameters with JSON name mapping
- Generated 113 converters total (37 Request + 76 Response models)
- Enhanced ApiClient.cs with JsonPropertyNameContractResolver to respect [JsonPropertyName] attributes
- Updated OptionNewtonsoftConverter to handle null values and nested Option<> types
- Fixed CustomEnumConverter to handle nullable enums correctly
- Added Dictionary<> and List<> type support in converter generation

ApiClient Enhancements:
- JsonPropertyNameContractResolver ensures Option<> properties use correct converter
- Updated Deserialize method to route nullable enums through JSON deserializer
- Added all 37 Request converters to the converter list

ConverterTestHarness Updates:
- Added detailed output showing retrieved/updated data for each test
- Added CRUD tests for User, Organization, Role, and Application
- Added FeatureFlag and Property operation tests
- Enhanced error reporting with stack traces

Generator Improvements:
- Extracts required parameters and their [JsonPropertyName] mappings
- Handles nested generics (List<>, Dictionary<>) with proper type qualification
- Generates correct read/write code for enums, primitives, and complex types
- Escapes C# reserved keywords in variable names

Note: This approach works but requires maintaining 113 converters and a Python generator script.
Next step: Try System.Text.Json migration for a cleaner, zero-converter solution.
- Add generate_mock_responses.py to auto-generate mock responses from OpenAPI spec
- Integrate mock response generation into generate-all-apis.sh build process
- Update MockHttpHandler to support pathContains parameter for better pattern matching
- Fix ConverterIntegrationTests to use mock HttpClient in mock mode
- Update mock response generator to handle parameterized paths and readOnly properties
- Add GeneratedMockResponses.cs auto-generated file (populated by generator)
- Enhance path matching logic to handle parameterized endpoints (e.g., /api/v1/apis/{id}/scopes)

This ensures mock responses stay in sync with API changes when regenerating APIs,
enabling reliable CI/CD testing without requiring real Kinde credentials.
@brettchaldecott brettchaldecott requested a review from a team as a code owner November 11, 2025 07:34
@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Important

Review skipped

More than 25% of the files skipped due to max files limit. The review is being skipped to prevent a low-quality review.

91 files out of 262 files are above the max files limit of 100. Please upgrade to Pro plan to get higher limits.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gitguardian
Copy link

gitguardian bot commented Nov 11, 2025

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
- - Generic High Entropy Secret 8805c93 Kinde.Api.Test/appsettings.json View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant