Open eladcandroid opened 1 year ago
@eladcandroid, Can you provide the "Swagger" specification and the command line arguments that you use?
@eladcandroid, Can you provide the "Swagger" specification and the command line arguments that you use?
my issue as the same, can you help me
"/something": {
"get": {
"operationId": "something",
"parameters": [
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/BaseResult"
},
{
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/somethingDto"
}
}
}
}
]
}
}
}
}
},
"tags": [
"something"
]
}
},```
@synasapmob
What is the definition of BaseResult
?
What CLI arguments do you use?
any updates on that? Same here with:
react-query-swagger /tanstack /input:http://localhost:8000/v3/api-docs /output:src/entities/api.ts /template:Fetch /minimal /use-recommended-configuration
@synasapmob What is the definition of
BaseResult
? What CLI arguments do you use?
I have other ideas to instead react-query-swagger m,y comment necessary to close...
I've found a solution. The issue on our side was that our swagger output has no additionalProperties: false flag. So I've customized our swagger generator to add those flags on every schema. React-query-swagger now doesn't add those [key: string]: any;
option to the types and interfaces anymore.
We use Springdoc to generate our swagger. You can add this customizer to OpenApiConfig to ensure the additionalProperties flag to be set in your swagger output:
@Bean
public OpenApiCustomizer getDefaultCustomizer() {
return openApi -> openApi.getComponents().getSchemas().values().forEach(s -> s.setAdditionalProperties(false));
}
And on Group Generators:
@Bean
public GroupedOpenApi common() {
return GroupedOpenApi.builder()
.group("common")
.pathsToMatch("/api/common/**")
.addOpenApiCustomizer(getDefaultCustomizer())
.build();
}
Thanks to https://github.com/RicoSuter/NSwag/issues/4199#issuecomment-1318678490 And https://stackoverflow.com/a/64490457
How to prevent adding [key: string]: any; ? I want to include only my schema properties but the generator adds also the general index signature.