How ory/hydra-client-dotnet works
Project type and purpose
• This is a .NET SDK (client library) for Ory Hydra, auto-generated from an OpenAPI spec.
• It exposes REST API bindings (Api classes), model types, and authentication utilities for developers to integrate with a self-hosted Ory Hydra server.
File structure
• Top-level folders and files:
• .github/ – CI/CD and issue/pr templates via GitHub Actions.
• .bin/ – helper scripts for license management.
• api/openapi.yaml – the API definition driving code generation.
• docs/ – per-endpoint markdown docs generated from the spec.
• src/Ory.Hydra.Client – main SDK project:
– Api/ – generated service clients (JwkApi.cs, OAuth2Api.cs, etc.).
– Client/ – shared HTTP client, auth, configuration, exception handling.
– Model/ – data types matching Hydra’s request/response schemas.
• src/Ory.Hydra.Client.Test – unit tests for each Api and Model class.
• README.md, LICENSE, “.openapi-generator-ignore” – metadata and generator config.
README for additional insights
• Confirms:
• Fully auto-generated via OpenAPI Generator.
• Intended for self-hosted Ory Hydra only.
• Packaged as a NuGet library.
Main components
a. Code-generation pipeline
– Component: OpenAPI Generator
– Input: api/openapi.yaml + generator templates
– Output: src/Ory.Hydra.Client code + docs/
b. SDK runtime modules
– Api Layer (JwkApi, OAuth2Api, OidcApi, MetadataApi, WellknownApi)
– Client Core (ApiClient, Auth/OAuthAuthenticator, Configuration, ExceptionFactory)
– Model Layer (Hydra* POCOs)
c. Test harness
– Unit Tests project invoking Api and validating Model serialization
d. CI/CD & Packaging
– GitHub Actions workflows (build, test, license checks, NuGet publication)
e. External service
– Ory Hydra Server (REST endpoints, OAuth2/OIDC flows)
Relationships and interactions
• The OpenAPI Generator reads openapi.yaml → produces code modules and docs.
• SDK Api classes invoke HTTP calls via the Client Core to the Hydra server.
• Models are used for request payloads and response deserialization.
• Unit tests drive Api/Model code to validate correctness.
• GitHub workflows orchestrate generation, building, testing, and publishing to NuGet.
Architectural patterns and principles
• Client–Server: clear separation between SDK (client) and Hydra (server).
• Layered design:
• API interfaces → Client infrastructure → Model definitions.
• Single-responsibility: each subfolder/package has a distinct concern.
• Configuration and Auth are centralized in Client/Configuration and Client/Auth.
• Synchronous and asynchronous calls supported via interfaces (ISynchronousClient / IAsynchronousClient).
Technologies, frameworks, and libraries
• OpenAPI Generator (codegen)
• .NET 6+ / C#
• NuGet package management
• GitHub Actions for CI/CD
• xUnit / NUnit (or similar) for testing