-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
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-testSteps 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:
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
propertiesattribute) with other generators. For C# language (csharp-functionsgenerator) the models generated are exactly the same. For Java however the generated classes are not the same.