feat:Add /v2/hardware API endpoint to DeepInfra OpenAPI spec#257
feat:Add /v2/hardware API endpoint to DeepInfra OpenAPI spec#257
Conversation
WalkthroughThis pull request introduces a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/libs/DeepInfra/openapi.yaml`:
- Around line 6717-6742: The HardwareOption schema uses pricing:anyOf which
allows ambiguous mixed payloads; update the upstream OpenAPI source (not the
checked-in YAML) so HardwareOption uses pricing:oneOf with a discriminator keyed
on the existing type property (propertyName: "type") and mapping "serverless" ->
"#/components/schemas/HardwarePricingServerless" and "dedicated" ->
"#/components/schemas/HardwarePricingDedicated" so the type field
deterministically selects the pricing schema (this will eliminate the
AnyOfJsonConverter<T1,T2> ambiguity and regenerate correct discriminated union
code).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ae43bbe2-097e-4c5e-bb90-caf5ca9a2696
⛔ Files ignored due to path filters (17)
src/libs/DeepInfra/Generated/DeepInfra..JsonSerializerContext.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.GetHardware.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.GetHardware.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.HardwareOptionType.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.HardwareOptionTypeNullable.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.GetHardwareV2HardwareGetXiApiKey.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.GetHardwareV2HardwareGetXiApiKey.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareOption.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareOption.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareOptionType.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingDedicated.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingDedicated.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingServerless.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwarePricingServerless.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareResponse.Json.g.csis excluded by!**/generated/**src/libs/DeepInfra/Generated/DeepInfra.Models.HardwareResponse.g.csis excluded by!**/generated/**
📒 Files selected for processing (1)
src/libs/DeepInfra/openapi.yaml
| HardwareOption: | ||
| title: HardwareOption | ||
| required: | ||
| - id | ||
| - name | ||
| - type | ||
| - pricing | ||
| type: object | ||
| properties: | ||
| id: | ||
| title: Id | ||
| type: string | ||
| name: | ||
| title: Name | ||
| type: string | ||
| type: | ||
| title: Type | ||
| enum: | ||
| - serverless | ||
| - dedicated | ||
| type: string | ||
| pricing: | ||
| title: Pricing | ||
| anyOf: | ||
| - $ref: '#/components/schemas/HardwarePricingServerless' | ||
| - $ref: '#/components/schemas/HardwarePricingDedicated' |
There was a problem hiding this comment.
Make pricing a discriminated oneOf, not anyOf.
Right now the contract allows ambiguous payloads: a pricing object containing fields from both variants is valid per spec, and the generated AnyOfJsonConverter<T1, T2> in src/libs/DeepInfra/Generated/DeepInfra.JsonConverters.AnyOf2.g.cs:1-95 will just take the first branch that deserializes. That means mixed or mismatched type/pricing combinations can be accepted and interpreted arbitrarily by clients. Please model this as a discriminated union—ideally at the HardwareOption level with type selecting the matching pricing schema—in the upstream OpenAPI source.
As per coding guidelines, src/libs/DeepInfra/openapi.yaml: The OpenAPI spec is fetched from https://api.deepinfra.com/openapi.json and stored in src/libs/DeepInfra/openapi.yaml -- do not manually modify the spec file
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/libs/DeepInfra/openapi.yaml` around lines 6717 - 6742, The HardwareOption
schema uses pricing:anyOf which allows ambiguous mixed payloads; update the
upstream OpenAPI source (not the checked-in YAML) so HardwareOption uses
pricing:oneOf with a discriminator keyed on the existing type property
(propertyName: "type") and mapping "serverless" ->
"#/components/schemas/HardwarePricingServerless" and "dedicated" ->
"#/components/schemas/HardwarePricingDedicated" so the type field
deterministically selects the pricing schema (this will eliminate the
AnyOfJsonConverter<T1,T2> ambiguity and regenerate correct discriminated union
code).
Summary by CodeRabbit
/v2/hardwareAPI endpoint, enabling users to query and discover available hardware options with detailed pricing information. Supports both serverless hardware with per-token billing (separate input and output token costs) and dedicated hardware with per-minute billing. API key authentication and model query parameter are required for endpoint access.