-
-
Notifications
You must be signed in to change notification settings - Fork 804
[OpenAPI] Support default values #8986
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
Conversation
d3aa969 to
0873da2
Compare
0873da2 to
9814c77
Compare
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.
Pull request overview
This PR implements support for default values in OpenAPI document generation. The changes enable GraphQL operations with default parameter values to be properly represented in the generated OpenAPI specification, allowing parameters with defaults to be optional in HTTP requests.
Key Changes:
- Added logic to detect and propagate default values from GraphQL variables and input object fields through to OpenAPI schemas
- Modified parameter handling to skip inserting values when defaults exist and no value is provided
- Extended OpenAPI schema generation to include default value representations
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| TestSchema.cs | Added test models (DeeplyNested, DeeplyNested2) with DefaultValue attribute for testing |
| OpenApiTestBase.cs | Added test mutation for deeply nested object with default value in query parameter |
| OpenApiIntegrationTestBase.cs | Added test case to verify default value handling in operation documents |
| HttpEndpointIntegrationTestBase.cs | Added integration tests for GET and PUT operations without query parameters that have defaults |
| OpenApiEndpointFactory.cs | Modified to extract and track whether parameters have default values |
| OpenApiEndpointDescriptor.cs | Extended VariableValueInsertionTrieLeaf to include HasDefaultValue flag |
| DynamicEndpointMiddleware.cs | Changed parameter insertion logic to skip values when defaults exist and no value provided |
| DynamicOpenApiDocumentTransformer.cs | Enhanced schema generation to include default values and reordered input/output object handling |
| Snapshot files (multiple) | Updated expected OpenAPI output to include default values in schemas |
Comments suppressed due to low confidence (1)
src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Execution/DynamicEndpointMiddleware.cs:204
- This TODO comment should be addressed before merging. If this situation should lead to a bad request, the implementation should be completed rather than leaving it as a TODO.
throw new InvalidOperationException(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Execution/DynamicEndpointMiddleware.cs
Show resolved
Hide resolved
src/HotChocolate/Adapters/src/Adapters.OpenApi.Core/Execution/DynamicEndpointMiddleware.cs
Show resolved
Hide resolved
🚀 Fusion Gateway Performance ResultsSimple Composite QueryConstant Load (50 VUs)
📊 Response Time Metrics
Ramping Load (0→50→500→50 VUs)
📊 Response Time Metrics
Executed Query fragment User on User {
id
username
name
}
fragment Review on Review {
id
body
}
fragment Product on Product {
inStock
name
price
shippingEstimate
upc
weight
}
query TestQuery {
topProducts(first: 5) {
...Product
reviews {
...Review
author {
...User
}
}
}
}Deep Recursion QueryConstant Load (50 VUs)
📊 Response Time Metrics
Ramping Load (0→50→500→50 VUs)
📊 Response Time Metrics
Executed Query fragment User on User {
id
username
name
}
fragment Review on Review {
id
body
}
fragment Product on Product {
inStock
name
price
shippingEstimate
upc
weight
}
query TestQuery {
users {
...User
reviews {
...Review
product {
...Product
reviews {
...Review
author {
...User
reviews {
...Review
product {
...Product
}
}
}
}
}
}
}
topProducts(first: 5) {
...Product
reviews {
...Review
author {
...User
reviews {
...Review
product {
...Product
}
}
}
}
}
}Variable Batching ThroughputConstant Load (50 VUs)
📊 Response Time Metrics
Ramping Load (0→50→500→50 VUs)
📊 Response Time Metrics
Executed Query query TestQuery_8f7a46ce_2(
$__fusion_1_upc: ID!
$__fusion_2_price: Long!
$__fusion_2_weight: Long!
) {
productByUpc(upc: $__fusion_1_upc) {
inStock
shippingEstimate(weight: $__fusion_2_weight, price: $__fusion_2_price)
}
}Variables (5 sets batched in single request) [
{ "__fusion_1_upc": "1", "__fusion_2_price": 899, "__fusion_2_weight": 100 },
{ "__fusion_1_upc": "2", "__fusion_2_price": 1299, "__fusion_2_weight": 1000 },
{ "__fusion_1_upc": "3", "__fusion_2_price": 15, "__fusion_2_weight": 20 },
{ "__fusion_1_upc": "4", "__fusion_2_price": 499, "__fusion_2_weight": 100 },
{ "__fusion_1_upc": "5", "__fusion_2_price": 1299, "__fusion_2_weight": 1000 }
]No baseline data available for comparison. Run 20061553251 • Commit 771aa37 • Tue, 09 Dec 2025 11:37:09 GMT |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8986 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.