Bug Report Checklist
Description
Code generated with typescript-fetch generator is faulty when the OpenAPI specification contains an array type that has both properties and items attributes.
openapi-generator version
7.14.0
OpenAPI declaration file content or url
<script src="https://gist.github.com/galamome/e8a64d748f442bd23ed17841480a7b20.js"></script>
Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-g typescript-fetch \
--additional-properties=supportES6=true,npmVersion=6.9.0,typescriptThreePlus=true \
-i ~/buildDev/bug_openapi/interface/openapi.json \
-o ~/buildDev/bug_openapi/typescript-client-test
Steps to reproduce
The file typescript-client-test/models/Errors.ts generated is faulty: Array<ModelError>FromJSON
export function ErrorsFromJSONTyped(json: any, ignoreDiscriminator: boolean): Errors {
if (json == null) {
return json;
}
return {
'errors': json['errors'] == null ? undefined : Array<ModelError>FromJSON(json['errors']),
};
}
and
export function ErrorsToJSONTyped(value?: Errors | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'errors': Array<ModelError>ToJSON(value['errors']),
};
}
Related issues/PRs
No related issue found.
Suggest a fix
It seems that having both properties and items in an array type is valid, but the properties should be ignored.
If so, the code generated should be the same as the one generated by the OpenAPI Specification that does not have the properties attribute:
<script src="https://gist.github.com/galamome/ad0a885dd45d3833139a79354e214dd6.js"></script>
The desired generated code:
<script src="https://gist.github.com/galamome/c21c0e5c6145bf7103932020c2d97671.js"></script>
REMARK: I have tried to generate for both specifications (with and without properties attribute) with other generators. For C# language (csharp-functions generator) the models generated are exactly the same. For Java however the generated classes are not the same.
Bug Report Checklist
Description
Code generated with
typescript-fetchgenerator is faulty when the OpenAPI specification contains an array type that has bothpropertiesanditemsattributes.openapi-generator version
7.14.0
OpenAPI declaration file content or url
<script src="https://gist.github.com/galamome/e8a64d748f442bd23ed17841480a7b20.js"></script>Generation Details
Steps to reproduce
The file
typescript-client-test/models/Errors.tsgenerated is faulty:Array<ModelError>FromJSONand
Related issues/PRs
No related issue found.
Suggest a fix
It seems that having both
propertiesanditemsin an array type is valid, but thepropertiesshould be ignored.If so, the code generated should be the same as the one generated by the OpenAPI Specification that does not have the
<script src="https://gist.github.com/galamome/ad0a885dd45d3833139a79354e214dd6.js"></script>propertiesattribute:The desired generated code:
<script src="https://gist.github.com/galamome/c21c0e5c6145bf7103932020c2d97671.js"></script>