Generic object responses should use 'any` and not generate a type
See original GitHub issueWhat are the steps to reproduce this issue?
Orval: ^6.6.1 Type: react-query
Spring Boot has a Health Check endpoint defined as below with just scheme type = Object
. because its an ANY response as a health check can have different details depending on what you are monitoring like Disk Space ,or Database Health Check etc.
OpenApiV3.json
"/actuator/health": {
"get": {
"tags": [
"Actuator"
],
"summary": "Actuator web endpoint 'health'",
"operationId": "health",
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
}
}
}
}
}
A typical response from the Health Check looks like this…
{
"status": "UP",
"details": {
"diskSpace": {
"status": "UP",
"details": {
"total": 250685575168,
"free": 188298530816,
"threshold": 10485760
}
}
}
}
However Orval is generating an empty TypeScript object like this:
export type Health200 = {};
So now in my code I have to cast Health200
to any
so I can get to the `status field.
if (healthCheck.isSuccess) {
const result = healthCheck.data as any; // cast as any to get to status
if (result.status !== "UP") {
throw new Error('REST API is currently down.');
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (20 by maintainers)
Top Results From Across the Web
generic collection type does not take any object - Stack Overflow
Let's learn about variance. Whenever you have a generic type argument, such as your T , it can be. Covariant; Contravariant.
Read more >How To Use Generics in TypeScript - DigitalOcean
In this code, you are creating a new type called User and using an array of that type ( User[] ) as the...
Read more >Documentation - Generics - TypeScript
Here, we will use a type variable, a special kind of variable that works on types rather than values. We've now added a...
Read more >Generic Methods - Java™ Tutorials
Generic methods allow type parameters to be used to express dependencies among the types of one or more arguments to a method and/or...
Read more >OpenAPI generation couldn't infer response type for generic ...
then it will not get picked up. Expected behavior. The concrete response type should be inferred and used as response schema. Actual behavior...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
fixed with
6.6.2
Also thanks to you and @CPatchane!